How to route traffic to my ipv4 routes except 0.0.0.0 address
because I don't want it to be the default interface
default via 192.168.5.1 dev enp7s0 proto dhcp metric 100 169.254.0.0/16 dev enp7s0 scope link metric 1000 192.168.5.0/24 dev enp7s0 proto kernel scope link src 192.168.5.84 metric 100 192.168.60.0/24 dev vpn_softether proto kernel scope link src 192.168.60.50 209.80.36.170 via 192.168.60.1 dev vpn_softether 216.117.82.227 via 192.168.60.1 dev vpn_softether
I want to make vpn_softether as default interface
What i have already tried ......
ip r add 0.0.0.0/1 via 0.0.0.0 dev vpn_softether ip r add 128.0.0.0/1 via 0.0.0.0 dev vpn_softether ip r add 0.0.0.0/1 via 192.168.5.1 ip r add 128.0.0.0/1 via 192.168.5.1 ip r add default via 192.168.60.1 ip r del 0.0.0.0/1 via 192.168.60.1 dev vpn_softether ip r del 128.0.0.0/1 via 192.168.60.1 dev vpn_softether ip r del 0.0.0.0/1 via 192.168.5.1 ip r del 128.0.0.0/1 via 192.168.5.1 ip r add 0.0.0.0/1 via 192.168.5.1 dev enp7s0 proto dhcp metric 100 ip r add 128.0.0.1/1 via 192.168.5.1 dev enp7s0 proto dhcp metric 100 ip r del 0.0.0.0/1 via 192.168.5.1 dev enp7s0 proto dhcp metric 100 ip r del default via 192.168.60.1 dev vpn_softether ip r del 128.0.0.0/1 via 192.168.5.1 dev enp7s0 proto dhcp metric 100 ip r del 0.0.0.0/1 via 192.168.60.1 dev vpn_softether proto dhcp metric 100 ip r del default via 192.168.5.1 dev enp7s0 ip r del 128.0.0.0/1 via 192.168.60.1 dev vpn_softether proto dhcp metric 100 ip r add 0.0.0.0/1 via 192.168.60.1 dev vpn_softether ip r add default via 192.168.5.1 dev enp7s0 proto dhcp metric 100 ip r add 128.0.0.0/1 via 192.168.60.1 dev vpn_softether
but it didn't worked...
Is there any other way to do it?
Thank you.
Note that you can only route "all traffic" to one interface, not to somehow all of them.
If you want to keep your default route (for whatever reasons), leave the default route alone, don't add or remove it. If you can add or remove it, you don't need to keep the default route ...
So,
ip route add 0.0.0.0/1 via 192.168.60.1 dev vpn_softether
ip route add 128.0.0.0/1 via 192.168.60.1 dev vpn_softether
should do the job, assuming the gateway on vpn_softether
is indeed 192.168.60.1
. Note you also need a rule to send whereever your VPN is connected
to out of enp7s0
, or the VPN won't be able to communicate with the other endpoint, and as a result you won't have any connection at all. So something like
ip route add 1.2.3.4/32 via 192.168.5.1 dev enp7s0
where 1.2.3.4
is the IP address of the other endpoint. Keeping the default
rule for this (if this was your motivation for that condition) will not work.