I have the following situation:
route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.42.129 0.0.0.0 UG 0 0 0 usb0 192.168.0.0 0.0.0.0 255.255.255.0 U 9 0 0 wlan1 192.168.42.0 0.0.0.0 255.255.255.0 U 1 0 0 usb0
And I would want to use a one-liner to setup the gateway of 192.168.0.0/24
to be 192.168.0.1
(current secondary ip is 192.168.0.4
).
Can I use something like
sudo ip route add from 192.168.0.4 via 192.168.0.1 dev wlan1 RTNETLINK answers: File exists
?
Again, I need something temporary which forces all packets sent from 192.168.0.4
to pass from gateway 192.168.0.1
(don't want to setup a set of scripts/whatnot to do this). Is there a one liner I can use?
Cheers!