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
时间: 2024-10-01 03:10:04