How do I route requests for an entire subnet over a VPN connection on Ubuntu?

6

I have an Ubuntu machine connected to a VPN, with the IP address 172.16.1.250. I want to tunnel all the requests for 172.16.1.* through the VPN, but nothing else. If I try to use sudo route -net add 172.16.1.0/24 dev ppp0, I get the error message:

netmask 00000fff doesn't make sense with host route

However, simply adding a route for one address on that subnet works. What is the correct way of doing this?

Joe Altair

Posted 2014-04-23T19:39:23.920

Reputation: 61

Why wouldn't a route to the remote network already exist in the routing table when the VPN is connected? Have you looked at the routing table while the VPN is connected? – joeqwerty – 2014-04-23T22:17:06.937

Answers

3

You have the arguments swapped around, the correct syntax is: sudo route add -net 172.16.1.0/24 dev ppp0

mtak

Posted 2014-04-23T19:39:23.920

Reputation: 11 805

1Did this answer solve the problem for you? – mtak – 2014-06-12T09:27:06.293