I have the following routing table:
# 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 enx6a58445c5d43
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 enx6a58445c5d43
192.168.42.0 0.0.0.0 255.255.255.0 U 0 0 0 enx6a58445c5d43
192.168.57.0 0.0.0.0 255.255.255.0 U 0 0 0 vboxnet1
When I use the following command I get error:
# ip route add 192.168.42.0/24 via 192.168.57.1 dev vboxnet1
RTNETLINK answers: File exists
But When I use from net-tools I don't get any error:
# route add -net 192.168.42.0/24 gw 192.168.57.1 dev vboxnet1
# 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 enx6a58445c5d43
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 enx6a58445c5d43
192.168.42.0 192.168.57.1 255.255.255.0 UG 0 0 0 vboxnet1 ####add here
192.168.42.0 0.0.0.0 255.255.255.0 U 0 0 0 enx6a58445c5d43
192.168.57.0 0.0.0.0 255.255.255.0 U 0 0 0 vboxnet1
Question is : How can I add by iproute2?
ip route replace 192.168.42.0/24 via 192.168.57.1 dev vboxnet1
– wurtel Oct 19 '15 at 9:50ip r get my_ip
I get same error? – PersianGulf Oct 19 '15 at 14:30