Linux下DHCP服务器配置详解

1、服务器环境node

静态IP地址ios

2、需安装软件服务器

dhcp-3.0.5-23.el5_5.2.i386.rpm网络

3、相关文件app

/etc/dhcpd.conf 主配置文件less

/usr/share/doc/dhcp-*/dhcpd.conf.sample 模板文件dom

/usr/sbin/dhcpd 执行文件tcp

/var/lib/dhcpd/dhcpd.lease 租约文件,中记录着DHCP服务器向DHCP客户机提供租用的每一个IP地址的信息ide

/etc/sysconfig/dhcpd 在哪一个网络接口启动DHCP服务文件this

/etc/sysconfig/dhcrelay 中继代理配置文件

4、主配置文件/etc/dhcpd.conf详解

ddns-update-style interim; #动态dns服务器更新方式

ignore client-updates; #忽略客户端动态更新


subnet 192.168.0.0 netmask 255.255.255.0 { #声明子网及掩码


# --- 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; #DNS服务器地址


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.0.128 192.168.0.254; #地址池

default-lease-time 21600; #默认租约时间(秒)

max-lease-time 43200; #最大租约时间(秒)


# we want the nameserver to appear at a fixed address

host ns { #定义主机名称

next-server marvin.redhat.com; #下一服务地址

hardware ethernet 12:34:56:78:AB:CD; #根据主机网卡mac地址分配IP地址

fixed-address 207.175.42.254; #分配的固定IP地址

}

}

5、/etc/sysconfig/dhcpd文件

DHCPDARGS=eth0 #仅在eth0上提供dhcp服务

6、DHCP中继代理服务器

1.安装DHCP服务

2.启动路由功能

临时启动:echo 1 > /proc/sys/net/ipv4/ip_forward

永久启动:修改/etc/sysctl.conf文件中net.ipv4.ip_forward = 1

3.修改dhcrelay配置文件

INTERFACES="eth0 eth1" #当收到客户端请求,使用哪一个网卡向DHCP服务器发送消息

DHCPSERVERS="" #设定DHCP服务器IP地址

4.启动中继服务

service dhcrelay start

7、客户端

1.网卡配置文件/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0

BOOTPROTO=dhcp #设为dhcp

HWADDR=00:0C:29:D1:08:E0

ONBOOT=yes

2.命令:dhclient 获取动态IP

dhclient -r 释放IP

dhclient eth0 指定网卡eth0获取IP

8、DHCP冗余

简要举例以下:

在两个不一样网段搭建DHCP服务,配置文件以下图:

191553889.jpg

9、备注:

DHCP服务端口:

bootps 67/tcp # BOOTP server

bootps 67/udp

bootpc 68/tcp dhcpc # BOOTP client

bootpc 68/udp dhcpc

相关文章
相关标签/搜索