![使用dhcpcd重置手動設定的接口](https://rvso.com/image/1254812/%E4%BD%BF%E7%94%A8dhcpcd%E9%87%8D%E7%BD%AE%E6%89%8B%E5%8B%95%E8%A8%AD%E5%AE%9A%E7%9A%84%E6%8E%A5%E5%8F%A3.png)
- 使用 dhcpcd 取得 IP 位址 (
dhcpcd -p eth0
) - 手動更改 IP 位址 (
ifconfig eth0 x.x.x.x
) - 殺死 dhcpcd (
dhcpcd -k eth0
) - 重新啟動 dhcpcd (
dhcpcd -p eth0
)
在這種情況下,dhcpcd 將不會設定介面的 IP 位址,介面將顯示手動設定的 IP 位址。為什麼沒有配置介面?
dhcpcd -d eth0
顯示:
eth0: dhcpcd 4.0.0-beta6 starting
eth0: hardware address = ##:##:##:##:##:##
eth0: broadcasting for a lease
eth0: sending DHCP_DISCOVER with xid 0x25fc838b
eth0: waiting for 3.241 seconds
eth0: offered 192.168.228.180 from 192.168.50.10
eth0: sending DHCP_REQUEST with xid 0x25fc838b
eth0: waiting for 7.224 seconds
eth0: lease of 192.168.228.180 acknowledged
eth0: sending ARP probe #1
eth0: waiting for 1.563 seconds
eth0: sending ARP probe #2
eth0: waiting for 1.442 seconds
eth0: sending ARP probe #3
eth0: waiting for 2.000 seconds
eth0: leased 192.168.228.180 for 691200 seconds
eth0: renew in 345600 seconds
eth0: rebind in 604800 seconds
eth0: adding IP address 192.168.228.180/23
eth0: adding route to 0.0.0.0/0 via 192.168.228.1
eth0: exec `/libexec/dhcpcd-run-hooks'
eth0: forking to background
答案1
結果是,如果介面分配了有效的靜態 IP 位址,則 dhcpcd 將不會配置該介面。
透過新增步驟:3b。將 eth0 IP 變更為無效值 (ifconfig eth0 0.0.0.0)
重新啟動 dhcpcd 時,介面將配置為 DHCP 指派的 IP 位址。