系统:
Linux Mint 18.2 Cinnamon 64 位(桌面模式,动手实践)
GNU/Linux Debian 9.2 Cinnamon 64 位(无头模式,SSH)
问题:
如何在这些 Linux 系统上从 DHCP 服务器(路由器)释放和更新 IP 地址?
答案1
我发现有以下程序在它们的网络上监听:
dhclient
引用手册页:
-r Release the current lease and stop the running DHCP client as previously recorded in the PID file. When shutdown via this method dhclient-script will be executed with the specific reason for calling the script set. The client normally doesn't release the current lease as this is not required by the DHCP protocol but some cable ISPs require their clients to notify the server if they wish to release an assigned IP address.
因此,所有接口的解决方案是:
sudo dhclient -r
sudo dhclient
或者,方便地,对于特定接口,可以说eth0
:
sudo dhclient -r eth0
sudo dhclient eth0
当然,当通过 SSH 连接到服务器时,您需要运行这两个命令内线或按照以下方式编写脚本这个答案。
答案2
在 ubuntu 上:
发布:
sudo dhclient -r
更新:
sudo dhclient -1