Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 would like to route all requests to 123.123.* normally through eth0 and everything else through VPN (tap0).

This should probably be done with iptables. Any ideas how?


share|improve this question
up vote 3 down vote accepted

You can do this with route.

route add -net netmask dev eth0
route add default gw

Assuming the gateway on your VPN network is

share|improve this answer
great. that also means dns resolving is being done through gateway? I am asking this because some (not all) subdomains from the 123.123.* cannot be found if try access them in firefox. I just get host not found. but if I "host subdomain" it resolves the right IP. I have this in my resolv.conf (if is vpn: # vpn – user49445 Jul 27 '10 at 11:39
"host subdomain" also does not resolve. that was wrong information. ideas? but if "host subdomain" is working from the gateway (it is a publicly accessible subdomain). – user49445 Jul 27 '10 at 11:45
This doesn't change the behaviour of your DNS. The servers listed in resolv.conf will be queried in the order they're listed. – theotherreceive Jul 27 '10 at 13:21
I improved your answer a little bit and now is everything OK: 1. route del default 2. route add -net gw <my current gw> eth0 3. route add default gw <my new gw> thanks. – user49445 Jul 27 '10 at 13:33

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.