VMware下Linux虚拟机实现DHCP功能


基于CentOS的Linux版本下的设置

#rpm -qa|grep dhcp(检查安装dhcp套件与否)

没有安装是话,先配置虚拟机可以上网,后进行下步骤

#yum -y install dhcp(安装dhcp套件)

接下来对主要的设定档进行设置的一个小案例:

[root@Linuxidc ~]# updatedb &(要等一段时间出现完成的提示)

[root@Linuxidc ~]# locate dhcpd.conf.sample
/usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample

[root@Linuxidc ~]# cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcp.conf

[root@Linuxidc ~]# mv /etc/dhcpd.conf /etc/dhcpd.conf.bak(备份)

[root@Linuxidc ~]# mv /etc/dhcp.conf /etc/dhcpd.conf

我所在的局域网是网关是192.168.1.1 DNS为202.102.224.68 ip范围为一个内网范围

[root@Linuxidc ~]# vi /etc/dhcpd.conf

ddns-update-style none;
ignore client-updates;

subnet 192.168.1.0 netmask 255.255.255.0 {

# --- default gateway
        option routers                  192.168.1.1;
        option subnet-mask              255.255.255.0;

        option nis-domain               "domain.org";
        option domain-name              "domain.org";
        option domain-name-servers      202.102.224.68;

        option time-offset              -18000; # Eastern Standard Time
#       option ntp-servers              192.168.1.1;
#       option netbios-name-servers     192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
#       option netbios-node-type 2;

        range dynamic-bootp 192.168.1.128 192.168.1.254;
        default-lease-time 21600;
        max-lease-time 43200;


        # we want the nameserver to appear at a fixed address

#设置固定Ip根据MAC地址
        host ns {
                 hardware ethernet MAC地址;
                 fixed-address 192.168.1.188;
#       }
}

[root@Linuxidc ~]# /etc/init.d/dhcpd restart

最后在客户端设置一下即可

在DOS下ipconfig/all即可查看相关信息

相关内容