如果你的DHCP服务只监听一个网卡,这个网卡绑定多个IP,比如 192.168.0.1,192.168.1.1
而想要DHCP同时可以分配2个网段的IP请求,像下面这样的配置(dhcpd.conf)
subnet 192.168.0.0 netmask 255.255.255.0 { range 192.168.0.100 192.168.0.200 ; option routers 192.168.0.1 ; option domain-name-servers 192.168.2.1,202.112.31.58 ; } subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.100 192.168.2.200 ; option routers 192.168.1.1 ; option domain-name-servers 192.168.2.1,202.112.31.58 ; } | DHCP 服务是启动不起来的,会提示 Interface eth0 matches multiple shared networks
此时只要把上面的配置放到 shared-network中就行了,像下面这样:
shared-network network_tag { ... } | 一般情况下,单网卡DHCP服务器分配多网段主要用于VLAN场合,当然DHCP服务器本生也要能支持VLAN,linux内核已经对802.1q支持了,只需要下载vconfig软件包进行配置下就行了,具体就不说了,网上很多关于这样的帖子。下面是一个典型的应用例子:
Client Area A -----Switch -----VLAN 1-----------, Client Area B -----Switch -----VLAN 2-------- Switch ----Trunk --- DHCP Server
Client Area C -----Switch -----VLAN 3-----------' | DHCP 服务器在分配IP时,会根据 DHCP 请求数据包中VLAN 的标识来决定分配哪个网段的IP,这样可以保证同一VLAN的用户分配的IP始终是同一网段的,当然交换机必须得支持VLAN和DHCP relay功能
我的配置文件(Ubuntu下)
1:/etc/network/interface
auto eth0 iface eth0 inet static address 192.168.0.1 netmask 255.255.255.0 network 192.168.0.0 broadcast 192.168.0.255 gateway 192.168.0.254 auto eth0:0 iface eth0:0 inet static address 192.168.1.1 netmask 255.255.255.0 network 192.168.0.0 broadcast 192.168.0.255 gateway 192.168.1.254
2:/etc/dhcpd.conf
default-lease-time 21600; max-lease-time 21600; option domain-name-servers 222.92.109.230,61.177.7.1,61.147.37.1; option domain-name "glfsoft.com";
shared-network network_tag { subnet 192.168.0.0 netmask 255.255.255.0 { # range 192.168.0.21 192.168.0.31; option broadcast-address 192.168.0.255; option subnet-mask 255.255.255.0; option routers 192.168.0.254; next-server 192.168.0.254; host kook { hardware ethernet 00:1A:4B:58:36:9D; fixed-address 192.168.0.9; } } subnet 192.168.1.0 netmask 255.255.255.0 { # range 192.168.1.21 192.168.1.31; option broadcast-address 192.168.1.255; option subnet-mask 255.255.255.0; option routers 192.168.1.254; next-server 192.168.1.254; host kook2 { hardware ethernet 00:E0:A0:11:BE:21;
fixed-address 192.168.1.9; } } } |
|
阅读(192) | 评论(0) | 转发(0) |