转自:http://blog.chinaunix.net/uid-24929997-id-3056842.html
地方
一、修改dhcp服务器ip地址:
1)修改eth0地址:
-
vim /etc/sysconfig/network-scripts/ifcfg-eth0
-
DEVICE=eth0
-
IPADDR=192.168.1.100
-
NETMASK=255.255.255.0
-
BOOTPROTO=static
-
HWADDR=........
-
ONBOOT=yes
-
TYPE=Ethernet
2)修改eth1地址
-
vim /etc/sysconfig/network-scripts/ifcfg-eth1
-
DEVICE=eth1
-
IPADDR=192.168.2.100
-
NETMASK=255.255.255.0
-
BOOTPROTO=static
-
HWADDR=.........
-
service network restart 使修改的地址生效
二、yum安装dhcp
三、复制dhcpd配置文件的样本
-
cp /usr/share/doc/dhcp*/dhcpd.conf.sample /etc/dhcpd.conf
四、编辑配置文件
-
vim /etc/dhcpd.conf
-
ddns-update-style interim;
-
ignore client-updates;
-
subnet 192.168.0.0 netmask 255.255.255.0 {
-
# --- default gateway
-
option routers 192.168.0.1;
-
option subnet-mask 255.255.255.0;
-
option nis-domain "domain.org";
-
option domain-name "domain.org"; #域名
-
option domain-name-servers 192.168.1.1;
-
option time-offset -18000; # Eastern Standard Time
-
# option ntp-servers 192.168.1.1;
-
# option netbios-name-servers 192.168.1.1;
-
# --- Selects point-to-point node (default is hybrid). Don
修改为
-
ddns-update-style interim; #dhcp服务器和dns服务器内部更新自动协商
-
ignore client-updates;
-
subnet 192.168.1.0 netmask 255.255.255.0 {
-
option routers 192.168.1.1; #网关
-
option subnet-mask 255.255.255.0; #子网掩码
-
option domain-name-servers 202.103.24.68,202.103.0.117; #DNS服务器地址
-
option time-offset -18000; # Eastern Standard Time
-
# --- Selects point-to-point node (default is hybrid). Don't change this unless
-
# -- you understand Netbios very well
-
# option netbios-node-type 2;
-
range dynamic-bootp 192.168.1.101 192.168.1.200; #地址池
-
default-lease-time 21600; #默认租约时间(秒)
-
max-lease-time 43200; #最大租约时间(秒)
-
# we want the nameserver to appear at a fixed address
-
host JTWD01-28 {
-
next-server marvin.redhat.com;
-
hardware ethernet 00:1E:90:17:CC:67; #根据主机网卡mac地址分配IP地址
-
fixed-address 192.168.1.88; #分配的固定IP地址
-
}
-
}
-
subnet 192.168.2.0 netmask 255.255.255.0 {
-
option routers 192.168.2.1;
-
option subnet-mask 255.255.255.0;
-
option domain-name-servers 202.103.24.68,202.103.0.117;
-
option time-offset -18000; # Eastern Standard Time
-
# --- Selects point-to-point node (default is hybrid). Don't change this unless
-
# -- you understand Netbios very well
-
# option netbios-node-type 2;
-
range dynamic-bootp 192.168.2.101 192.168.2.200;
-
default-lease-time 21600;
-
max-lease-time 43200;
-
}
五、应用不同的网络接口:
-
vim /etc/sysconfig/dhcpd
-
DHCPDARGS=eth0 // DHCPDARGS=eth1 #仅在eth0上提供dhcp服务
六、开启dhcp服务:
-
service dhcpd start #stop status restart
注:/var/lib/dhcpd/dhcpd.leases 中记录着DHCP服务器向DHCP客户机提供租用的每个IP地址的信息
七、DHCP中继代理
1)首先安装dhcpd服务(里面包含中继代理服务)
2)启用路由功能:
-
echo "1" > /proc/sys/net/ipv4/ip_forward
3)然后修改dhcrelay的配置文件:
-
vim /etc/sysconfig/dhcrelay
加入以下内容:
-
INTERFACES="eth0 eth1"
-
DHCPSERVERS="192.168.1.2"
4)给dhcp服务器增加新网段的地址池
5)启动中继服务
6)客户端测试
阅读(1429) | 评论(0) | 转发(0) |