Dhcp中继
配置运行环境
1.
DHCP server 在Linux 192.168.10.100上
2.
router 在windows server 2003上使用远程与路由实现
3.
区域192.168.20.x 192.168.30.x通过router向DHCP server申请地址
Linux中必须做Dhcp服务器的作用域,即服务器必须在作用域中,可以是空作用域
1.安装dhcp server
[root@localhost Server]# rpm -qa dhcp
dhcp-3.0.5-18.el5.i386.rpm dhcpv6-1.0.10-16.el5.i386.rpm
dhcp-devel-3.0.5-18.el5.i386.rpm dhcpv6-client-1.0.10-16.el5.i386.rpm
[root@localhost Server]# rpm -qa dhcp
[root@localhost Server]#
[root@localhost Server]# rpm -ivh dhcp-3.0.5-18.el5.i386.rpm
2.配置dhcpd.conf文件
[root@localhost ~]# vim /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
#定义区域192.168.20.0
subnet 192.168.20.0 netmask 255.255.255.0 {
option routers 192.168.20.254;--设置客户端的默认网关
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.20.1 192.168.20.10;
default-lease-time 21600;
max-lease-time 43200;
}
#定义区域192.168.30.0
subnet 192.168.30.0 netmask 255.255.255.0 {
option routers 192.168.30.254;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.30.1 192.168.30.10;
default-lease-time 21600;
max-lease-time 43200;
}
#定义区域192.168.10.0 dhcp server所在的区域,可以是空区域
subnet 192.168.10.0 netmask 255.255.255.0 {
}
#定义配置信息的参考模板可以从下面的文件读入
:r /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample
#检查配置信息是否有错
[root@localhost ~]# service dhcpd configtest
Syntax: OK
3.配置server的ip
[root@localhost Server] vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
IPADDR=192.168.10.100
NETWORK=255.255.255.0
GATEWAY=192.168.10.254
ONBOOT=yes
HWADDR=00:0c:29:7d:c7:28
[root@localhost Server]# service network restart.
4.启动dhcpd
[root@localhost ~]# chkconfig --list dhcpd
dhcpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@localhost ~]# chkconfig dhcpd on
[root@localhost ~]# chkconfig --list dhcpd
dhcpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
5.查看server的路由
[root@localhost ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 192.168.10.254 0.0.0.0 UG 0 0 0 eth0
[root@localhost ~]#
6.测试到达路由是否联通
[root@localhost ~]# ping 192.168.10.254
PING 192.168.10.254 (192.168.10.254) 56(84) bytes of data.
64 bytes from 192.168.10.254: icmp_seq=1 ttl=128 time=0.304 ms
[root@localhost ~]# ping 192.168.20.254
PING 192.168.20.254 (192.168.20.254) 56(84) bytes of data.
64 bytes from 192.168.20.254: icmp_seq=1 ttl=128 time=0.460 ms
[root@localhost ~]# ping 192.168.30.254
PING 192.168.30.254 (192.168.30.254) 56(84) bytes of data.
64 bytes from 192.168.30.254: icmp_seq=1 ttl=128 time=0.177 ms
[root@localhost ~]#
Route通过在Windows server 2003上设置路由和远程访问实现
1.添加网卡
三个区域需要添加三块网卡。
2.分配区域
Network 1 192.168.10.254/24 vm1
Network 2 192.168.20.254/24 vm2
Network 3 192.168.30.254/24 vm3
3.路由与远程访问
1)开始-所有程序-管理工具-路由和远程访问
18-1
2)本地服务器—配置启用路由和远程访问
选择选项
自定义配置
Lan 路由(l)
18-2
18-3
3)ip路由选择-常规-新增路由协议-dhcp中继代理程序
18-4
4)dhcp中继代理程序-新建接口-添加vm2和vm3新接口
5)dhcp中继代理程序-属性-dhcp中继代理程序向下列服务器地址发送消息
添加server dhcp ip :192.168.10.100
18-5
6)查看路由
18-6
客户端自动获取地址:
通过windows xp主机实现不同区域自动获取地址:
18-7