DHCP中继:
主要用于不同VALN通过一个dhcp server获得不同的ip地址。
valn间的通信必须使用三层的设备,用一台服务器做vlan间的中继。

一 dhcp server的配置:
 1,准备工作:
   安装dhcp软件包: rpm -ivh dhcp-3.0.5-23.el5.i386.rpm
   chkconfig --list |grep dhcp ---查看服务的启动情况。
   chkconfig dhcpd on  ---启动服务。
   setup --配置网关为直连网卡的地址。
 
 2,编辑dhcp的配置文件:
   vim /etc/dhcpd.conf
   作用域1:可有多个作用域。
   subnet 192.168.30.0 netmask 255.255.255.0 { ---网段或子网

# --- default gateway
        option routers                  192.168.30.254;   ----网关
        option subnet-mask              255.255.255.0;    ----子网掩码

        option nis-domain               "domain.org";
        option domain-name              "mak.org";        ----DNS域名
        option domain-name-servers      222.88.88.88;     ----DNS服务器

        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't change this unless
# -- you understand Netbios very well
#       option netbios-node-type 2;

        range dynamic-bootp 192.168.30.10 192.168.30.20;  ----地址范围
        default-lease-time 21600;
        max-lease-time 43200;

        # we want the nameserver to appear at a fixed address
}
subnet 192.168.100.0 netmask 255.255.255.0{
}---空的作用域,必须有,且与dhcp服务器在一个网段

 

 3,检测:
   service dhcpd configtest。
   在检测没有出错时,重启服务。
   service dhcpd restart

二 路由中继的配置
  在此,以一台linux主机做dhcp的中继,在一台pc上添加多块网卡。
1,安装中继服务。
   中继服务包装在dhcp软件包中,所以安装软件包。
    rpm -ivh dhcp-3.0.5-23.el5.i386.rpm

2,启动中继服务,转发功能。
   chkconfig dhcrelay on
   vim /etc/sysct1.conf
   在第七行,0改为1 ----启动转发功能
   sysctl -p ---使转发功能生效

3,编辑中继文件。
   vim /etc/sysconfig/dhcrelay
   INTERFACES="eth0 eth1 eth2"   ---网卡编号
   DHCPSERV="192.168.100.10"  ---dhcp服务器地址
4,配置各个网卡的地址。
   setup
   设置各个网卡的地址为网段的网关。

三 客户端的设置
    setup 设置获得ip地址的方式为dhcp
    重启服务:service network restart