以前都是使用 ifconfig down/up,但是后来发现这个命令并不会试网卡去获取dhcp地址,而是仅仅的打开关闭网口,后来在Ubuntu中发现ifdown/ifup可以实现在关闭网卡的时候,会释放dhcp,在打开网卡的时候会获取dhcp。
在Gentoo 下使用ifdown/ifup功能的对应命令是:
/etc/init.d/net.eth0 start/stop/restart
xw-gentoo ~ # /etc/init.d/net.eth0 restart
* Stopping eth0
* Bringing down eth0
* Stopping dhcpcd on eth0 ... [ ok ]
* Shutting down eth0 ... [ ok ]
* Starting eth0
* Configuration not set for eth0 - assuming DHCP
* Bringing up eth0
* dhcp
* Running dhcpcd ... [ ok ]
* eth0 received address 192.168.0.2/24