A detailed description of DHCP server and deployment Relay Agent under Linux
Build DHCP server, native eth0 network card IP is 1.1.1.18/24, gateway is 1.1.1.20
Yum install-y DHCP Install DHCP RPM package
Cp/usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample/etc/dhcpd.conf
vim/etc/dhcpd.conf, mainly modified in several lines :
Subnet 1.1.1.0 netmask 255.255.255.0 {#设置子网段
Option routers 1.1.1.20; # Gateway
Option Subnet-mask 255.255.255.0; #掩码
Option Domain-name "willow.com"; #域名
Option Domain-name-servers 1.1.1.18; #DNS服务器
Range DYNAMIC-BOOTP 1.1.1.100 1.1.1.150; #分配地址池
}
#以下2.2.2.0/24 Subnet for relay Agent preparation
Subnet 2.2.2.0 netmask 255.255.255.0 {#设置子网段
option routers 2.2.2.20; # Gateway
Option Subnet-mask 255.255.255.0; #掩码
Option Domain-name "willow.com"; #域名
Option Domain-name-servers 1.1.1.18; #DNS服务器
Range DYNAMIC-BOOTP 2.2.2.100 2.2.2.150; #分配地址池
}
Chkconfig DHCPD on #开机自启动
Service DHCPD Start #启动DHCP服务
2. Deploying DHCP relay Agents
How to get the host from the 2.2.20/24 subnet to the DHCP server (1.1.1.18) to obtain the IP address automatically?
Because the cross-subnet is an isolated DHCP broadcast request, if you need to obtain IP, you must use the DHCP relay Agent
Prepare a Linux host as a relay Agent service host, two NICs, ETH0:1.1.1.20/24,ETH1:2.2.2.20/24
2.1.vim/etc/sysctl #修改以下一条语句
Net.ipv4.ip_forward = 1 #相当于启动路由功能
Sysctl-p #重新让内核加载sysctl文件
2.2.yum install-y DHCP installation DHCP RPM package
Vim/etc/sysconfig/dhcrelay
interfaces= "eth0 eth1"
dhcpservers= "1.1.1.18" #DHCP服务器IP地址
Chkconfig Dhcrelay on #开机自启动
Servcie Dhcrelay Start #启动中继服务
Note: The DHCP server gateway must point to the relay Agent host 1.1.1.20
3.dhclient Client tool to view client requests for IP and lease procedures
Killall Dhclient can only be run once by dhclient, must kill this process, and then rerun
Dhclient-d front-end operation, you can view the client request to obtain IP and lease process, if need to abort, must press CTRL + C
This article is from the "Xavier Willow" blog, please be sure to keep this source http://willow.blog.51cto.com/6574604/1774896
A detailed description of DHCP server and deployment Relay Agent under Linux