Chinaunix首页 | 论坛 | 博客
  • 博客访问: 124764
  • 博文数量: 21
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 235
  • 用 户 组: 普通用户
  • 注册时间: 2014-07-10 11:25
个人简介

及时行乐

文章分类

全部博文(21)

文章存档

2014年(21)

我的朋友

分类: LINUX

2014-07-11 09:21:13

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