Use hostnames from second network interface

To solve your problem you need to install a local DNS server.

The DNS server should then simply be setup to use your current DNS server for all lookups, except those that belong to the "custom hostnames" (*.myuni.co.uk for example) that you want to force to be looked up via the alternative DNS server.

For example here's the way to set it up with the the very popular "bind" DNS-server software:

You install "bind" by using HomeBrew. If you have HomeBrew installed already, you can open the Terminal and use this command to install it:

brew install bind

To configure bind, you need to edit the named.conf configuration file. First you need to define your local IPs (your own computers). This ensures that only you can do DNS lookups using your computer:

  acl mycomputers {
    localhost;
    localnets;
  }

This is a simple configuration that just allows your own computer to do lookups. If you have other devices that you want to use this computer for DNS as well, you can add their IPs or a whole subnet to the list as well.

Then in the existing "options" block, you make it look like this:

options {
  [...]
  recursion yes;
  allow-query { mycomputers };
  zone "myuni.co.uk" in { type forward; forward only; forwarders { 1.1.1.1; 2.2.2.2; }; };
  forwarders {
      8.8.8.8;
      8.8.4.4;
  }

}

Recursion means that you allow clients to lookup "other people's domains" - i.e. not just host names and IP addresses defined on your computer, but by looking other domain names up on the internet.

Allow-query restricts access to only your own computers.

The zone line means that the specific domain myuni.co.uk is going to be handled by a specific set of DNS-servers. I.e. all queries for *.myuni.co.uk is forwarded to these servers. You need to replace 1.1.1.1/2.2.2.2 with the IP addresses of your Uni's DNS servers.

The next line "forwarders" means that all other queries are forwarded to other DNS servers. In this case I just put in the IP addresses for Google's DNS service, but you can your existing DNS server IPs here.

Note that "bind" does come with lots of options and configuration possibilities - it might be a bit hard to grasp at first.

Another option would be install the more limited, but easier to setup "dnsmasq" software. It is also available from HomeBrew with brew install dnsmasq.

With dnsmasq you can essentially keep defaults to use your ordinary DNS servers, and then use the following option:

--server=/myuni.co.uk/1.1.1.1

to forward queries for *.myuni.co.uk to your Uni's DNS server (replace that IP for 1.1.1.1).

Note that dnsmasq also does other things than just DNS - like for example being a DHCP server. This functionality you do not want, so keep it disabled.