系统:
Linux Mint 18.2 Cinnamon 64 位(桌面模式,动手操作)
GNU/Linux Debian 9.2 Cinnamon 64 位(无头模式,SSH)
题:
如何在这些 Linux 系统上从 DHCP 服务器(路由器)释放和更新 IP 地址?
我发现有以下程序在他们两个的网络上侦听:
dhclient
Run Code Online (Sandbox Code Playgroud)
引用手册页:
Run Code Online (Sandbox Code Playgroud)-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
Run Code Online (Sandbox Code Playgroud)
或者,方便地,对于特定的接口,说eth0:
sudo dhclient -r eth0
sudo dhclient eth0
Run Code Online (Sandbox Code Playgroud)
当然,当通过 SSH 连接到服务器时,您需要运行这两个命令oneliner或按照此答案编写脚本。