![為什麼在子介面上啟動 ISC DHCP 伺服器時會出現「無子網路聲明」?](https://rvso.com/image/658340/%E7%82%BA%E4%BB%80%E9%BA%BC%E5%9C%A8%E5%AD%90%E4%BB%8B%E9%9D%A2%E4%B8%8A%E5%95%9F%E5%8B%95%20ISC%20DHCP%20%E4%BC%BA%E6%9C%8D%E5%99%A8%E6%99%82%E6%9C%83%E5%87%BA%E7%8F%BE%E3%80%8C%E7%84%A1%E5%AD%90%E7%B6%B2%E8%B7%AF%E8%81%B2%E6%98%8E%E3%80%8D%EF%BC%9F.png)
我在以下位置創建了兩個子介面eth0
:
eth0:0
有IP192.168.10.1/24
eth0:1
有IP192.168.11.1/24
/etc/dhcp/dhcpd.conf
像這樣配置:
option domain-name-server 194.204.159.1;
subnet 192.168.10.0 netmask 255.255.255.0 {
option routers 192.168.10.1;
option subnet-mask 255.255.255.0;
range 192.168.10.10 192.168.10.100;
}
subnet 192.168.11.0 netmask 255.255.255.0 {
option routers 192.168.11.1;
option subnet-mask 255.255.255.0;
range 192.168.11.10 192.168.11.100;
}
但是當我嘗試啟動 DHCP 伺服器時,我得到:
No subnet declaration for eth0:0 (no IPv4 addresses).
** Ignoring requests on eth0:0. If this is not what
you want, please write a subnet declaration
in your dhcpd.conf file for the network segment
to which interface eth0:0 is attached. **
No subnet declaration for eth0:1 (no IPv4 addresses).
** Ignoring requests on eth0:1. If this is not what
you want, please write a subnet declaration
in your dhcpd.conf file for the network segment
to which interface eth0:1 is attached. **
配置在/etc/default/isc-dhcp-server
:
INTERFACES="eth0:0 eth0:1"
這有什麼問題嗎?
更新:
忘記提及我正在嘗試在子介面(別名?)上設定路由器。我設定了 2 台主機,192.168.10.2
並192.168.11.2
在配置了具有子介面的第三台主機後eth0:0
,eth0:1
在這 2 台主機之間轉送封包。但現在我正在嘗試設定 DHCP 伺服器,它可以動態地將 IP 指派給 2 個子網路中的 2 台主機。
答案1
這不起作用,因為 IP 別名只是將位址新增至現有介面的一種方法。您可能應該在這裡做的是 VLAN。
答案2
您不需要有子介面來為這些網路的 DHCP 請求提供服務。 http://manpages.ubuntu.com/manpages/hardy/man5/dhcpd.conf.5.html
DHCP 是一個像 TCP/IP 一樣的協議,因此它在機器擁有 IP 位址之前的層級上工作,因此您不需要在子介面上偵聽 DHCP 請求,您需要偵聽實際的實體接口,在您的情況下可能是eth0 來滿足這些請求。
然後,您需要定義向這些群組出租 IP 位址的規則 - 透過靜態 MAC 位址映射,或任何(我猜 ubuntu)會讓您做的事情。
eth0:1 和 eth0:0 介面僅是 NAT 路由所必需的,不應出現在 DHCP 設定中的任何位置。