环境拓扑:
--------------RHEL5.9(vmnet4)-------------------linux系统(vmnet4)
安装DHCP前准备
1、配置主机IP地址
2、两台主机在一环境内
DHCP服务端操作:
[[email protected]~]# cat -n /etc/sysconfig/network-scripts/ifcfg-eth0
1 #Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
2 DEVICE=eth0 //设备名
3 BOOTPROTO=static //或者是dhcp(自动),static(手动)
4 ONBOOT=yes //随network服务启用
5 HWADDR=00:0c:29:ba:6b:76 //物理MAC地址
6 IPADDR=192.168.10.253 //指定的静态地址
7 NETMASK=255.255.255.0 //子网掩码
8 GATEWAY=192.168.10.254 //默认网关
[[email protected]~]# rpm -q dhcp //查看是否安装DHCP服务
dhcp-3.0.5-31.el5_8.1
[[email protected]~]# cat -n /etc/dhcpd.conf
1 ddns-update-style interim;
2 option domain-name "tarena.com"; //默认搜索域
3 option domain-name-servers 202.106.0.20;//DNS服务器地址
4 default-lease-time 21600; //默认租期
5 max-lease-time 43200; //最大租期
6 subnet 192.168.10.0 netmask 255.255.255.0 { //声明网段
7 option routers 192.168.10.254; //网关
8 option subnet-mask 255.255.255.0; //子网掩码
9 range dynamic-bootp 192.168.10.128 192.168.10.200;//IP分配范围
10 host linux { //识别名称
11 hardware ethernet00:0C:29:B2:6D:09; //客户机MAC
12 fixed-address 192.168.10.190; //固定地址
13 }
14 }
[[email protected] ~]# service dhcpd restart //重启服务
客户端操作:
[[email protected] ~]# cat -n/etc/sysconfig/network-scripts/ifcfg-eth0
1 # Advanced Micro Devices [AMD] 79c970[PCnet32 LANCE]
2 DEVICE=eth0
3 BOOTPROTO=dhcp //自动获取
4 HWADDR=00:0c:29:b2:6d:09
5 IPV6INIT=yes
6 IPV6_AUTOCONF=yes
7 ONBOOT=yes
8 TYPE=Ethernet
[[email protected] ~]# service network restart //重启网卡
[[email protected] ~]# ifconfig //验证查看是否获取到地址