0

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?

2
  • You probably need to do ip route replace 192.168.42.0/24 via 192.168.57.1 dev vboxnet1 – wurtel Oct 19 '15 at 9:50
  • Ok, Thanks, But my question is conceptual: Why when can'y find my ip via ip r get my_ip I get same error? – PersianGulf Oct 19 '15 at 14:30
0

You have network address 192.168.42.0/24 in your routing table. So you have to:

ip route replace 192.168.42.0/24 via 192.168.57.1 dev vboxnet1 

Or

ip route del 192.168.42.0/24 
ip route add 192.168.42.0/24 via 192.168.57.1 dev vboxnet1 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.