2

How can I do ip route get, but force it to ignore a specific device?

When I start my VPN, I run ip route get <vpn_server_ip> to determine what interface to use to connect to the VPN. Then I add a default route with highest priority that sends all traffic to my VPN tun device. The VPN traffic is not captured by the default route because its sockets bind to the interface obtained from the ip route get.

That's all fine, but if there are network changes and the outgoing interface goes down, I need to start using the next interface. But because the VPN is running I can't call ip route get <vpn_server_ip> because that will return the tun device. I don't want to temporarily remove the VPN route because that will leak traffic.

0

1 Answer 1

1

The ip route get command uses the actual routing information and uses the longest prefix match algo. There isn't a way to ignore specific interfaces. But if you have the several suitable routes with various metrics, you can use the other command - ip route list match <ip>. It will return all suitable routes for the particular ip address, not only the best route.

You must log in to answer this question.

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