cat /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/ip_forward
vi /etc/sysctl.conf
net.ipv4.ip_forward = 1
vi /etc/sysconfig/sysctl
IP_FORWARD="yes"
netstat -rn
vi /etc/rc.d/rc.local
route add -net default gw 192.168.1.1
route add -net 192.168.2.0 netmask 255.255.255.0 gw 10.1.1.3
route add -net 192.168.3.0 netmask 255.255.255.0 gw 10.1.1.5
可以把route add加入
vi /etc/rc.d/rc.local
/sbin/route add -net 192.168.2.0 netmask 255.255.255.0 gw 10.1.1.3
這樣就會在系統啟動時,自動加入
更好的方法
/etc/sysconfig/network-scripts/route-$1
因為
if [ -f "/etc/sysconfig/network-scripts/route-$1" ]; then
while read line; do
/sbin/ip route add $line
done < "/etc/sysconfig/network-scripts/route-$1"
fi
所以
route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.1.1
要寫成
192.168.100.0/24 via 192.168.168.1
ping 192.168.2.2
traceroute 192.168.2.2
netstat -rn
route del -net 192.168.2.0 netmask 255.255.255.0 gw 10.1.1.3 #flush all the currently defined static routes
redhat-config-network
less /etc/sysconfig/network/routes #??? no found this file
ifconfig eth0 up
*** dynamic routing
ifconfig eth0:0 192.168.11.1 netmask 255.255.255.0 up
service routed start
while true; do
clear netstat -rn
sleep 1
done
service routed stop