Thursday, January 17, 2013

route add on Redhat/CentOS

 [root@my32GB images]# wget http://192.168.10.110/ks.cfg
--2013-01-18 22:10:28--  http://192.168.10.110/ks.cfg

[root@my32GB images]# ping 192.168.10.110



[root@my32GB images]# route add -net 192.168.10.0 netmask 255.255.255.0 gw 192.168.10.1 dev wlan0


[root@my32GB images]# ping -c 2 192.168.10.110
PING 192.168.10.110 (192.168.10.110) 56(84) bytes of data.
From 192.168.10.1: icmp_seq=1 Redirect Host(New nexthop: 192.168.10.110)
64 bytes from 192.168.10.110: icmp_seq=1 ttl=64 time=1.78 ms
From 192.168.10.1: icmp_seq=2 Redirect Host(New nexthop: 192.168.10.110)
64 bytes from 192.168.10.110: icmp_seq=2 ttl=64 time=1.79 ms

--- 192.168.10.110 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1003ms
rtt min/avg/max/mdev = 1.783/1.791/1.799/0.008 ms
[root@my32GB images]#

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Route add and make it persistent

Route add,

# route add -net 192.168.10.0 netmask 255.255.255.0 gw 192.168.10.1 eth0
or
# route add -net 192.168.10.0 netmask 255.255.255.0 eth0

To make it persistent,
Add entry to /etc/sysconfig/network-scripts/route-eth0 file.

echo "192.168.10.0/24 via 192.168.10.1 dev eth0" >> /etc/sysconfig/network-scripts/route-eth0
or
"192.168.10.0/24 dev eth0" >> /etc/sysconfig/network-scripts/route-eth0

Verify the changes using netstat -rn or ip route command.
# netstat -rn
or
# ip route

No comments:

Post a Comment