CentOS5.6 安装配置dhcp
组网图:
eth0:192.168.0.11/24 (模拟外网)
eth1:192.168.200.254/24 (模拟LAN1)
eth2:172.16.100.254/24 (模拟LAN2)
搭建环境准备
iptables
dhcpd
配置文件
[root@test ~]# cat /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
subnet 192.168.200.0 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.200.254;
option subnet-mask 255.255.255.0;
option domain-name "test.com";
option domain-name-servers 60.191.244.5,8.8.8.8; #dns
option time-offset -18000;
range dynamic-bootp 192.168.200.100 192.168.200.250;
default-lease-time 21600;
max-lease-time 43200;
}
#
subnet 172.16.100.0 netmask 255.255.255.0 {
# ---- default gateway
option routers 172.16.100.254;
option subnet-mask 255.255.255.0;
option domain-name "test.com";
option domain-name-servers 60.191.244.5,8.8.8.8;#dns
option time-offset -18000;
range dynamic-bootp 172.16.100.100 172.16.100.200;
default-lease-time 21600;
max-lease-time 43200;
}
#
[root@test ~]# cat /etc/sysconfig/dhcpd
# Command line options here
DHCPDARGS="eth1 eth2"
[root@test ~]# service dhcpd restart
[root@test ~]# iptables -t nat -A POSTROUTING -s 192.168.200.0/24 -j SNAT --to-s 192.168.0.11
[root@test ~]# iptables -t nat -A POSTROUTING -s 172.16.100.0/24 -j SNAT --to-s 192.168.0.11
配置结束,局域网客户机 可以自动获取ip了