安装DHCP服务器
***********************************************************************************************************
1.安装dhcp软件包
此包位于(第四章)光盘中,文件名称为dhcp
mount /media/cdrom
cd /media/cdrom/RedHat/RPMS
ls -l dhcp* (列出以dhcp开始的文件)
rpm -qa | grep dhcp (查看dhpc的安装情况)
rpm -ivh dhpc-3.0.1-12_EL.i386.rpm
mount /media/cdrom
cd /media/cdrom/RedHat/RPMS
ls -l dhcp* (列出以dhcp开始的文件)
rpm -qa | grep dhcp (查看dhpc的安装情况)
rpm -ivh dhpc-3.0.1-12_EL.i386.rpm
————————————————————————————————————
2. 建立配置文件
dhpcd服务将完全按照dhcpd.conf配置文件中的设置内容运行,在dhcp软件包没 有提供dhcpd.conf文件,我们可以从它提供的样例中拷贝一份,它的样例文件dhcpd.conf.sample位于/usr/share/doc/dhcp-3.0.1目录中。
cp /usr/share/doc/dhcp-3.0.1/dhcpd.conf.sample /etc/dhpcd.conf
vi /etc/dhpcd.conf 编辑dhcpd.conf文件
ddns-update-style interim;
ignore client-updates;
cp /usr/share/doc/dhcp-3.0.1/dhcpd.conf.sample /etc/dhpcd.conf
vi /etc/dhpcd.conf 编辑dhcpd.conf文件
ddns-update-style interim;
ignore client-updates;
subnet 192.168.0.0 netmask 255.255.255.0 { (subnet关键字后面设置子网的网络 地址,netmask后面设置子网掩码)
# --- default gateway
option routers 192.168.0.1; (设置路由)
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
option domain-name-servers 192.168.1.1;
option routers 192.168.0.1; (设置路由)
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
option domain-name-servers 192.168.1.1;
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;
# 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.0.128 192.168.0.254; (设置动态分配IP的地址范围)
default-lease-time 21600;
max-lease-time 43200;
default-lease-time 21600;
max-lease-time 43200;
# we want the nameserver to appear at a fixed address
host ns {
host ns {
next-server marvin.redhat.com;
hardware ethernet 12:34:56:78:AB:CD; (DHCP服务器将为符合MAC地址的主机分配设置地址)
fixed-address 207.175.42.254; (用与指定为客户端分配的固定使用的IP地址)
}
————————————————————————————————————
3.多网络接口是需要配置的文件
作为DHCP服务器使用的主机通常会用有多个网络接口,而dhcpd服务可能只需要在其中一个网络接口上提供服务,此时可以在 "/etc/sysconfig/dhcpd"文件中指定需要提供dhcpd服务的网络接口
3.多网络接口是需要配置的文件
作为DHCP服务器使用的主机通常会用有多个网络接口,而dhcpd服务可能只需要在其中一个网络接口上提供服务,此时可以在 "/etc/sysconfig/dhcpd"文件中指定需要提供dhcpd服务的网络接口
vi /etc/sysconfig/dhcpd
# Command line options here
DHCPDARGS=添加需要使用的端口
~
————————————————————————————————————
4.重启服务
service dhcpd start (或 /etc/init.d/dhcpd restart )
******************************************************************************************************************
DHCP客户端的配置
# Command line options here
DHCPDARGS=添加需要使用的端口
~
————————————————————————————————————
4.重启服务
service dhcpd start (或 /etc/init.d/dhcpd restart )
******************************************************************************************************************
DHCP客户端的配置
1.网络接口配置文件
vi /etc/sysconfig/network-scripts/ifcfg-eth0
vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes (用于设置网络接口在系统启动是生效)
BOOTPROTO=dhcp
——————————————————————————————————————————————————————————
2.重启网络接口
ifdown eth0 ; ifup eth0
ifconfig eth0 (查看接口获取的ip地址)
ONBOOT=yes (用于设置网络接口在系统启动是生效)
BOOTPROTO=dhcp
——————————————————————————————————————————————————————————
2.重启网络接口
ifdown eth0 ; ifup eth0
ifconfig eth0 (查看接口获取的ip地址)
转载于:https://blog.51cto.com/fengshangqu/201811