For a VPN configuration, I need to route a particular public subnet via the tunnel except one of them, because that IP is assigned to the VPN server.

But, because the configuation will fall into multiple particular client setups, I need to avoid define the gateway ip or interface, so I'm looking for the way to add a route to one IP via default gw

ip route add gw vi default gw
Error: either "to" is duplicate, or "gw" is a garbage.

1 Answer 1

sudo route del default
sudo route add default gw 'gw ip'
sudo route add -net 'desired ip' netmask 'interface name'

This should do the trick.

  • 4
    Can you expand your answer at all to explain what those commands do? Also, note that 'route' is a deprecated command; you should aim to use ip from the iproute2 package instead these days.
    – fukawi2
    Dec 18, 2019 at 6:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .