Method 1:echo "192.168.1.0/24 via 172.17.100.1" >/etc/sysconfig/network-scripts/route-eth0
[[email protected] ~]# echo "192.168.1.0/24 via 172.17.100.1" > / Etc/sysconfig/network-scripts/route-eth0[[email protected] ~]# route -nkernel ip routing tableDestination Gateway genmask flags metric ref Use Iface192.168.1.0 172.17.100.1 255.255.255.0 UG 0 0 0 eth0172.17.100.0 0.0.0.0 255.255.255.0 u 0 0 0 eth0169.254.0.0 0.0.0.0 255.255.0.0 u 1002 0 0 eth00.0.0.0 172.17.100.1 0.0.0.0 ug 0 0 0 eth0[[email protected] ~]#
Method 2:
[[email protected] ~]# echo -e "Address0=192.168.1.0\nnetmask0=255.255.255.0\ ngateway0=172.17.100.1 " > /etc/sysconfig/network-scripts/route-eth0[[email protected] ~ ]# cat /etc/sysconfig/network-scripts/route-eth0address0=192.168.1.0netmask0=255.255.255.0gateway0= 172.17.100.1[[email protected] ~]# /etc/init.d/network restartshutting down interface eth0: [ ok ]Shutting down loopback interface: [ OK ]Bringing up loopback interface: [ OK ]Bringing up interface eth0: Determining if ip address 172.17.100.240 is already in use for device eth0... [ ok ][[email protected] ~]# route -nkernel IP routing tableDestination Gateway Genmask Flags Metric Ref use iface192.168.1.0 172.17.100.1 255.255.255.0 UG 0 0 0 eth0172.17.100.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0169.254.0.0 0.0.0.0 255.255.0.0 u 1002 0 0 eth00.0.0.0 172.17.100.1 0.0.0.0 UG 0 0 0 eth0[[email protected] ~]#
This article is from the "Hezhang" blog, make sure to keep this source http://hezhang.blog.51cto.com/1347601/1633122
Add a Route entry (permanent)