1,能够用route命令暂时改动:
route add default gw <gateway ip>
2, 通过改动/etc/sysconfig/network 文件永久改动:
脚本:
#!/bin/sh
#configure default gw
# $1 is ip of gateway
defgw=$1
sed -i "s/NETWORKING.*/NETWORKING=yes/"
/etc/sysconfig/network
sed -i "s/HOSTNAME.*/HOSTNAME=`hostname`/"
/etc/sysconfig/network
echo "GATEWAY=$defgw" >>
/etc/sysconfig/network
service network restart
事实上终于的/etc/sysconfig/network的格式是:
~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=c902f02x44
GATEWAY=60.0.0.202
然后重新启动network服务:service network restart
永久改动redhat的default route,布布扣,bubuko.com
原文地址:http://www.cnblogs.com/mengfanrong/p/3763765.html