Linux系统配置DHCP服务以及DHCP中继代理实验

目标功能:
   使用一台RHEL5服务器[Server1]连接A、B、C三个网段,A网段中有一台DHCP服
务器[Server2]。需要在Server1上配置dhcp中继代理,以使Server2能够给三个网
段的客户机自动分配IP地址,给A网段的网络打印机绑定永久IP地址。
   实验参数如下: 
 Server1:
    eth0: 172.17.17.1/24
    eth1: 192.168.1.1/24
    eth2: 192.168.2.1/24
 Server2:
    eth0: 172.17.17.2/24
注意:dhcp也就是Server2上要配置默认网关172.17.17.1
实验环境:一台有三块网卡的RHEL5充当dhcp中继,eth0在vmnet2中,eth1在
vmnet3中,eth2在vmnet5中。分别在三个不同的网段。另一台RHEL5为dhcp服务器
,eth0的网段在vmnet2中,其中有一台WINDOWS客户机在vmnet3中为动态获取IP,
获得192.168.1.0网段中的IP地址。另一台为linux客户机在vmnet5中为动态获取
IP,获得192.168.2.0网段中的ip地址。

1.搭建测试环境
2.配置DHCP(Server2)服务器
   vim /etc/sysconfig/network-scripts/ifcfg-eth0
     DEVICE=eth0
     BOOTPROTO=none
     HWADDR=00:0c:29:9b:bf:b9
     ONBOOT=yes
     NETMASK=255.255.255.0
     IPADDR=172.17.17.2
     GATEWAY=172.17.17.1        //配置DHCP的网关为:中继的和DHCP服务器相连的IP地址
   service network restart               //重启网络服务
   vim /etc/dhcpd.conf
     ddns-update-style interim;
     ignore client-updates;
     default-lease-time 21600;          //全局配置
     max-lease-time 43200;

subnet 172.17.17.0 netmask 255.255.255.0 {
        option routers                  172.17.17.1;
        option subnet-mask              255.255.255.0;
        option time-offset              -18000; # Eastern Standard Time

        range dynamic-bootp 172.17.17.3 172.17.17.254;

        host ns {
                hardware ethernet 12:34:56:78:AB:CD;
                fixed-address 172.17.17.3;
        }
}
subnet 192.168.1.0 netmask 255.255.255.0 {
        option routers                  192.168.1.1;
        option subnet-mask              255.255.255.0;
        option time-offset              -18000; # Eastern Standard Time

        range dynamic-bootp 192.168.1.2 192.168.1.254;
}
subnet 192.168.2.0 netmask 255.255.255.0 {
        option routers                  192.168.2.1;
        option subnet-mask              255.255.255.0;
        option time-offset              -18000; # Eastern Standard Time

        range dynamic-bootp 192.168.2.2 192.168.2.254;
}
   3.vim /etc/sysconfig/dhcpd              //指定网络接口启动dhcp服务
        # Command line options here
        DHCPDARGS=eth0
   4.service dhcpd restart                 //重启dhcp服务
   5.配置中继代理(Server1)
       vim /etc/sysconfig/dhcrelay
        INTERFACES=”eth0 eth1 eth2”
        DHCPSERVERS=”172.17.17.2”
     service dhcrelay restart             //重启中继服务
   6.中继代理启动网卡转发
       vim /etc/sysctl.conf               //永久启用(需重启机器)
        # Controls IP packet forwarding
        net.ipv4.ip_forward = 1
        echo 1 > /proc/sys/net/ipv4/ip_forward  //临时启用转发
   7.测试(winxp)

 

你可能感兴趣的:(linux,Dhcp服务,dhcp中继代理)