linux 修改静态ip立即生效,无需重启

1、修改/etc/network/interfaces文件内容

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto eth1
iface eth1 inet static

address 192.168.0.20
gateway 192.168.0.1
netmask 255.255.255.0

2、刷新ip地址

ip addr flush eth1   

3、重启网络接口

ifdown eth1
ifup eth1

你可能感兴趣的:(Linux,linux,服务器,运维)