RTNETLINK answers No such file or directory

1. RTNETLINK answers: No such file or directory

修改默认路由时,有如下报错:

1
2
3
[root@linux ~]#ip route change default via 192.168.1.2

RTNETLINK answers: No such file or directory

查看路由信息

1
2
3
4
5
6
[root@linux ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
192.168.1.0 0.0.0.0 255.255.240.0 U 0 0 0 eth0

解决方法:

关闭NetworkManager并取消开机自启

1
2
systemctl stop NetworkManager
systemctl disable NetworkManager

重启网卡

1
systemctl restart network

接着执行修改默认路由命令

1
ip route change default via 192.168.1.2

查看路由信息

1
2
3
4
5
6
[root@linux ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.2 0.0.0.0 UG 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
192.168.1.0 0.0.0.0 255.255.240.0 U 0 0 0 eth0

可以看到已经成功修改。

-------------本文结束感谢您的阅读-------------