快速配置DHCP服务:
1.关闭vmdhcp:services.msc --vmdhcp--停止
2.启动vnet1
3.设置静态永久的网络参数:
1)设置静态ip等参数
[root@dhcp ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
1
2
3
4
5
6
7
8
9
|
DEVICE=
"eth0"
HWADDR=
"00:0C:29:68:b1:0f"
NM_CONTROLLED=
"no"
ONBOOT=
"yes"
BOOTPROTO=static
IPADDR=192.168.100.100
NETMASK=255.255.255.0
GATEWAY=192.168.100.1
DNS1=192.168.100.100
|
2)主机名
[root@dhcp ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=dhcp.linuxyy.cn
3)关闭防火墙和selinux
/etc/init.d/iptables stop
vi /etc/selinux/config
SELINUX=disabled
:wq
4)设置开机启动项
chkconfig iptables off
chkconfig NetworkManager off
chkconfig network on
reboot
重启的验证:
ip a
cat /etc/resolv.conf
iptables -L
getenforce
4.安装能提供dhcp服务的软件
vi /etc/yum.repos.d/rhel.repo
1
2
3
4
5
|
[
local
]
name=
local
baseurl=
file
:
///mnt/
enabled=1
gpgcheck=0
|
:wq
mount /dev/cdrom /mnt
yum -y install dhcp
5.修改服务的配置文件:定制功能
vi /etc/dhcp/dhcpd.conf
1
2
3
4
5
6
7
8
9
10
11
|
##:r /usr/share/doc/dhcp-*/dhcpd.conf.sample; ##复制dhcp文档示例
:%g /^
#/d;%g /^$/d;修改配置文件如下
option domain-name
"linuxyy.cn"
;
option domain-name-servers 202.106.0.20;
default-lease-
time
600;
max-lease-
time
7200;
log-facility local7;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.150 192.168.1.250;
option routers 192.168.1.1;
}
|
:wq
/etc/init.d/dhcpd start
chkconfig dhcpd on
netstat -uptln |grep dhcp ##查看67号端口
6.客户机测试:
1)临时设置:
dhclient -d eth0 ##获取ip
dhclient -r eth0 ##释放ip
2)永久使用dhcp:
vi /etc/sysconfig/network-scripts/ifcfg-eth0
1
|
BOOTPROTO=dhcp
|
:wq
vi /etc/sysconfig/dhcpd ##解决启动时报网卡类问题
1
|
DHCPDARGS=eth0
|
:wq
tail -30 /var/log/messages ##看常规错误