如何配置 DHCP 服务器以分配 IP 路由?

ble*_*tin 10 dhcp linux route ipcop

我有一台 DHCP 服务器(Linux、IPCop、dnsmasq)在我的默认网关服务器 192.168.0.1 上运行。我在网络中的另一台服务器上有一个 VPN 端点 (192.168.0.4)。是否可以配置 DHCP 服务器,使其在请求 IP 地址时不仅向 DHCP 客户端发送默认网关,还向其发送 VPN (192.168.1.*) 的路由信息​​?DHCP 客户端运行 Windows 和 Linux。

我试图在官方文档(http://www.ipcop.org/2.0.0/en/admin/html/custom-dnsmasq-local.html)中找到一些东西但失败了。RFC3442的存在表明它可能以某种方式成为可能。

ble*_*tin 10

这可以通过将以下几行添加到dhcpd.conf

option rfc3442-classless-static-routes code 121 = array of integer 8;
option rfc3442-classless-static-routes 24, 192, 168, 1, 192, 168, 0, 4;
option ms-classless-static-routes code 249 = array of integer 8;
option ms-classless-static-routes 24, 192, 168, 1, 192, 168, 0, 4;
Run Code Online (Sandbox Code Playgroud)

这将使用网关 192.168.0.4 分发网络 192.168.1.0/24 的路由条目。

字节的含义是(括号中是上例中的值):

WW, D1, D2, D3, R1, R2, R3, R4
WW      = destination network mask width (24)
D1..D3  = destination network address (192.168.1.*)
R1..R4  = router address (192.168.0.4)
Run Code Online (Sandbox Code Playgroud)

注意:D1..DN字节数因网络掩码而异。有关详细信息,请参阅RFC3442

  • 困惑 - 很确定 OP 将 dnsmasq 指定为服务器 (2认同)