假設一台計算機做軟路由,有三個網卡,連接3個不同的網段,192.168.1.1/24, 192.168.2.1/24,192.168.3.1/24;其中192.168.1.1/24這個網段有一個DHCP服務器,那怎麼樣設置可以使192.168.2.1/24和192.168.3.1/24這兩個網段分配IP呢?
首先得在dhcp.conf文件中添加超級作用域:
ddns-update-style interim; ;指定DHCP支持的DNS動態更新為interim
ignore client-updates; ;指定不允許客戶機更新DNS記錄。
shared-network xxxdhcp { ;超級作用域名為xxxdhcp
option subnet-mask 255.255.255.0;
option domain-name-servers 192.168.1.2,192.168.1.10,192.168.4.1;
option broadcast-address 192.168.1.255;
default-lease-time 86400;
max-lease-time 172800;
}
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.21 192.168.1.49;
option routers 192.168.1.1;
host pc1 {
hardware ethernet MAC;
fixed-address 192.168.1.20;
}
}
subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.21 192.168.2.49;
option routers 192.168.2.1;
host pc1 {
hardware ethernet MAC;
fixed-address 192.168.2.20;
}
}
subnet 192.168.3.0 netmask 255.255.255.0 {
range 192.168.3.21 192.168.3.49;
option routers 192.168.3.1;
host pc1 {
hardware ethernet MAC;
fixed-address 192.168.3.20;
}
}
linux下的DHCP客戶端:/etc/sysconfig/network-scripts/ifcfg-eth0把BOOTPROTO="none"修改為BOOTPROTO="dhcp"
如果需要在系統啟動時自動引導啟動聯網,/etc/sysconfig/networking下的networking=yes。