分类: LINUX
2015-08-10 11:45:17
实验环境:
服务器端:Super63 VMnet4 192.168.1.0网段
客户端: Super64
VMnet4
搭建dhcp服务器动态分配ip地址:
服务端安装dhpc
[root@super63 ~]# yum install -y dhcp
拷贝配置文件:
[root@super63 dhcp-4.1.1]# cp
/usr/share/doc/dhcp*/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
修改配置文件:
[root@super63 dhcp-4.1.1]# vim
/etc/dhcp/dhcpd.conf
#前面关于subnet删除
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option domain-name-servers 8.8.8.8;
option domain-name "internal.example.org";
option routers 192.168.1.1;
option broadcast-address 192.168.1.255;
default-lease-time 600;
max-lease-time 7200;
}
启动dhcp:
[root@super63 dhcp]# /etc/init.d/dhcpd
restart
客户端设置默认获取ip方式为dhcp:
setup 、 /etc/sysconfig/network-script/ifcfg-eth0。。。
启动网络:
[root@super64 ~]# service network restart
查看ip
[root@super64 ~]# ifconfig
查看租约:
[root@super63 ~]# vim
/var/lib/dhcpd/dhcpd.leases
保留地址的使用:
服务端:
[root@super63 ~]# vim /etc/dhcp/dhcpd.conf
#改为以下内容:
host super63 {
hardware ethernet 00:0C:29:20:B0:69;
fixed-address 192.168.1.66;
}
重启dhcp服务:
[root@super63
~]# service dhcpd restart
Shutting down dhcpd: [ OK ]
Starting dhcpd:
[ OK ]
客户端重启网络服务
[root@super64 ~]# service network restart
查看ip
[root@super64 ~]# ifconfig
eth0
Link encap:Ethernet HWaddr
00:0C:29:20:B0:69
inet addr:192.168.1.66 Bcast:192.168.1.255 Mask:255.255.255.0