Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 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 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
up vote 7 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/ on my system:


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

llp@cerberus:~$ nslookup



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
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 at 9:13

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.