一、DHCP服务
1、软件包:dhcp
2、服务名:dhcpd(主程序)、dhcrelay(中继服务)
3、端口:udp 67udp 68
4、配置文件:
/etc/dhcp/dhcpd.conf主配置文件 /etc/sysconfig/dhcrelay中继配置文件 /usr/share/doc/dhcp*/dhcpd.conf.sample主配置文件模板
5、常见配置项
……
6、搭建DHCP和DHCP中继服务
实验过程:
实验环境:
DHCP服务器复制IP以及网关192.168.1.3
网关192.168.1.2
中继,配置两个不同的网卡的IP并且激活
Eth0 192.168.1.2 eth1 200.200.200.1
网关192.168.1.2 网关200.200.200.1
客户端:设置网卡自动获取
192.168.
搭建DHCP服务器:
服务器端:
1、yum -yinstall dhcp 2、cp/usr/share/doc/dhcp*/dhcpd.conf.sample /etc/dhcp/dhcpd.conf 3、vim /etc/dhcp/dhcpd.conf删除多余配置,保留一个subnet区域 subnet192.168.1.0 netmask 255.255.255.0 { option routers192.168.1.2;#中继eth0的ip地址 option subnet-mask255.255.255.0; optiondomain-name-servers 192.168.1.2;DNS range 192.168.1.10192.168.1.100; default-lease-time21600; max-lease-time23200; } 4、servicedhcpd restart
客户端:
1、vim/etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 ONBOOT=yes BOOTPROTO=dhcp 2、servicenetwork restart
搭建DHCP中继服务:
服务器端:
1、yum -yinstall dhcp 2、cp/usr/share/doc/dhcp*/dhcpd.conf.sample /etc/dhcp/dhcpd.conf 3、vim/etc/dhcp/dhcpd.conf 删除多余配置,保留一个subnet区域 subnet192.168.1.0 netmask 255.255.255.0 { option routers192.168.1.2;#中继eth0的ip地址 option subnet-mask255.255.255.0; optiondomain-name-servers 192.168.1.2; range 192.168.1.10192.168.1.100; default-lease-time21600; max-lease-time23200; } subnet200.200.200.0 netmask 255.255.255.0 { option routers200.200.200.1;#中继eth1的IP地址 option subnet-mask255.255.255.0; optiondomain-name-servers 200.200.200.1; range200.200.200.10 200.200.200.100; default-lease-time21600; max-lease-time23200; } host faa { 声明MAC绑定 hardware ethernet 00:0c:29:25:ed:0c;要绑定ip的mac fixed-address 200.200.200.25; 绑定的IP } 4、servicedhcpd restart 5、route adddefault gw 192.168.1.2#中继eth0的ip地址
中继端:
1、yum -yinstall dhcp 2、vim/etc/sysctl.conf ip.net.ipv4_forward1 3、sysctl -p 4、vim/etc/sysconfig/dhcrelay INTERFACE= "eth0 eth1" DH7CPSERVER= "192.168.1.3"#DHCP的ip地址 5、servicedhcrelay restart
客户端:
1、vim/etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 ONBOOT=yes BOOTPROTO=dhcp 2、servicenetwork restart
二、MAC绑定IP地址
在DHCP服务器上声明,
host faa { hardware ethernet 00:0c:29:25:ed:0c; fixed-address 200.200.200.25; }
7 subnet 地址段 netmask mac地址 { 48 range 10.5.5.26 10.5.5.30;(地址池) 49 option domain-name-servers ns1.internal.example.org;(dns地址) 50 option domain-name "internal.example.org"; 51 option routers 10.5.5.1;(网关) 52 option broadcast-address 10.5.5.31;(广播地址) 53 default-lease-time 600;(最短时间) 54 max-lease-time 7200;(最长时间) 55 }