I have an Ubuntu machine that I'm using as my home Internet router. It uses a USB mobile broadband modem as its Internet connection, and shares this with another router (via the router's "Internet" port) which I use as my LAN.

How do I redirect requests from within my LAN for a given URL to a custom IP address (ex have google.com redirect to x.x.x.x)?

  • 1
    Using DNS would be the way to do this, but as I have not successfully set up bind9 DNS, I am not providing this information as an answer. – Thomas Ward Jul 18 '11 at 2:58
  • Ugh, me neither... guess I can try bind9 again :) – yuttadhammo Jul 18 '11 at 3:03
  • Okay, I've got bind9 setup and working (maybe?), how do I make a rule to redirect the url? – yuttadhammo Jul 18 '11 at 3:23
  • as i've said, i havent ever configured bind9 correctly, so I can't help you unfortunately. You might wait for someone else to come around – Thomas Ward Jul 18 '11 at 3:26

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:


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

llp@cerberus:~$ nslookup hotmail.com

Name:   hotmail.com


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

| improve this answer | |
  • 2
    Thanks, I knew it could be done! Just a note, don't install dnsmasq! Ubuntu comes with dnsmasq-base, which provides the same functionality, I think. Config file is /etc/dnsmasq.conf, just add address= for each entry, as above. – yuttadhammo Jul 22 '11 at 14:40
  • I want to do the same thing, but the problem is I'm behind a proxy. This solution is not working for me. – prince Jan 13 '16 at 9:13
  • did you try cname? – Edik Mkoyan Jan 20 '17 at 11:50
  • Is there a way to add multiple IPs? – vikas027 Mar 1 '18 at 6:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.