歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> VMware下Linux虛擬機實現DHCP功能

VMware下Linux虛擬機實現DHCP功能

日期:2017/2/28 16:26:00   编辑:Linux教程

基於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即可查看相關信息

Copyright © Linux教程網 All Rights Reserved