How to redirect a URL to a custom IP address?

Solution 1:

The easiest way to come about this is properly installing dnsmasq (which is a DNS cacheing server) then in the folder /etc/dnsmasq.d add a file for each domain you want to redirect.

For instance this is the contents of /etc/dnsmasq.d/hotmail.com on my system:

address=/hotmail.com/127.0.0.1
address=/www.hotmail.com/127.0.0.1

If I then ask the DNS server for the IP of hotmail.com i get 127.0.0.1 like this:

llp@cerberus:~$ nslookup hotmail.com
Server:     192.168.0.10
Address:    192.168.0.10#53

Name:   hotmail.com
Address: 127.0.0.1

llp@cerberus:~$

There are a bit more options you can set, they can all be found described in /etc/dnsmasq.conf