Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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)?

share|improve this question
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 W. 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 W. Jul 18 '11 at 3:26

1 Answer 1

up vote 5 down vote accepted

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

share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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