centos6.5中怎么centos配置dhcp服务器

微信公众号
CentOS 5.5 DHCP服务器环境配置指南
环境说明:
DHCP系统:CentOS 5.5
网卡接口:eth0
IP地址:192.168.21.136
网关:192.168.21.2
子网掩码:255.255.255.0
DNS:8.8.8.8& 8.8.4.4
检查DHCP服务是否安装
rpm -q dhcp
package dhcp is not installed
yum -y install dhcp
cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample& /etc/dhcpd.conf& #复制配置文件模板
vi /etc/dhcpd.conf& #编辑配置文件
ddns-update-style &&&& #设置DHCP服务器模式
ignore client-&&&&&& #禁止客户端更新
subnet 192.168.21.0 netmask 255.255.255.0 {
option routers&&&&&&&&&&&&&&&&& 192.168.21.2;& #设置网关
option subnet-mask&&&&&&&&&&&&& 255.255.255.0;& #设置子网掩码
option domain-name-servers&&&&& 8.8.8.8,8.8.4.4;& #设置dns服务器地址
range dynamic-bootp 192.168.21.200& 192.168.21.210;& #设置dhcp服务器IP地址租用的范围
default-lease-time 21600;& #默认租约时间
max-lease-time 43200;& #最大租约时间
hardware ethernet 00:0C:29:E2:82:5C;&& #保留主机的MAC地址
fixed-address 192.168.21.201;& #保留主机的IP,即绑定IP地址到主机
vi /etc/sysconfig/dhcpd&& #指定DHCP服务的网络接口
# Command line options here
& DHCPDARGS=eth0
service dhcpd start&&& #启动dhcp服务
service dhcpd restart& #重启dhcp服务
chkconfig dhcpd on&& #设置开机启动
在客户机上设置IP地址为自动获得,重启客户机,查看IP地址为192.168.21.200到192.168.21.210其中的一个,即为成功!
附件:本中的dhcpd.conf配置文件
ddns-update-
ignore client-
subnet 192.168.21.0 netmask 255.255.255.0 {
# --- default gateway
&&&&&&& option routers&&&&&&&&&&&&&&&&& 192.168.21.2;
&&&&&&& option subnet-mask&&&&&&&&&&&&& 255.255.255.0;
#&&&&&& option nis-domain&&&&&&&&&&&&&& &domain.org&;
#&&&&&& option domain-name&&&&&&&&&&&&& &domain.org&;
&&&&&&& option domain-name-servers&&&&& 8.8.8.8,8.8.4.4;
&&&&&&& 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.21.200 192.168.21.210;
&&&&&&& default-lease-time 21600;
&&&&&&& max-lease-time 43200;
&&&&&&& # we want the nameserver to appear at a fixed address
&&&&&&& host ns {
&&&&&&&&&&&&&&& next-
&&&&&&&&&&&&&&& hardware ethernet 00:0C:29:E2:82:5C;
&&&&&&&&&&&&&&& fixed-address 192.168.21.201;
其他类似的新闻
● ● ● ● ● ● ● ● ● ●
其他相关的新闻
大家感兴趣的内容
小伙伴最爱的新闻
小伙伴还关注了以下信息
小伙伴关注的焦点
小伙伴都在关注的热门词
Copyright (C) 2006- Inc. All Rights Reserved
孝感风信信息技术有限公司 ● 版权所有微信公众号:centoscn
CentOS 6.5下dhcp服务器搭建与配置
一、安装配置dhcp
[root@localhost ~]# yum -y install dhcp
[root@localhost ~]# cd /usr/share/doc/dhcp-4.1.1/
[root@localhost dhcp-4.1.1]# cp -ra dhcpd.conf.sampl /etc/dhcp/dhcpd.conf
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf
option domain-name &&;&&&&&&&&&&&&&&&&&DNS服务器域名
option domain-name-servers 192.168.1.24;&&&&& DNS服务器的IP地址
default-lease-time 360000;&&&&&&&&&&&&默认租约时间
max-lease-time 720000;&&&&&&&&&&&&&&&&最大租约时间
ddns-update-
log-facility local7;
#地址池配置
subnet 192.168.1.0 netmask 255.255.255.0 {&&&&&&&&&&&&& 分配的网段192.168.1.0/24
& range 192.168.1.100 192.168.1.230;&&&&&&&&&&&&&&&&& & 分配的ip地址区间;
& option routers 192.168.1.1;&&&&&&&&&&&&&&&&&&&&&&&&& &网关ip;
& option broadcast-address 192.168.1.255;&&&&&&&&&&&&&&&&广播地址;
#指定主机给其分配ip
host boss {&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&boss为主机名,随便取;
& hardware ethernet 00:0C:29:6C:A6:F8;&&&&&&&& 主机网卡的mac地址;
& fixed-address 192.168.1.10;&&&&&&&&&&&&&&&&& 给其分配的ip;
二、启动dhcpd服务器
[root@localhost ~]# /etc/init.d/dhcpd restart
关闭 dhcpd: & & & & & & & & & & & & & & & & & & & & & & & [确定]
正在启动 dhcpd: & & & & & & & & & & & & & & & & & & & & & [确定]
三、查看端口监听状态
[root@localhost ~]# netstat -ltunp |grep dhcpd
udp & & & &0 & & &0 0.0.0.0:67 & & & & & & & & &0.0.0.0:* & & & & & & & & & &&5346/dhcpd
------分隔线----------------------------查看:3364|回复:7
助理工程师
我安装 dhcp 后&&配置了&&/etc/dhcpd.conf 如下 ,&&可是我启动后却显示失败,仔细看了好久都没发现哪里有错呀 ,以前在红帽里也是这么弄的& && &
(66.56 KB)
(11.77 KB)
:Q 也没个提示呢
助理工程师
啊!!!!我知道 了& & 子网掩码写错了& &与主机不在同一子网&&所以失败了。。。:time:
哈哈,精彩的自问自答奖励。
高级工程师
Linuxの小凡
引用:原帖由 h_qiushu 于
10:51 发表
啊!!!!我知道 了& & 子网掩码写错了& &与主机不在同一子网&&所以失败了。。。:time: 解:(mars_20): 决了啊,赞一个,但是这种没报错的情况我没遇到过,能否贴下那错误时候的log日志文件?
助理工程师
啊没了&&当时我是在虚拟机里边玩的& &现在恢复过去了呢& &:(mars_11):
高级工程师
Linuxの小凡
引用:原帖由 h_qiushu 于
21:51 发表
啊没了&&当时我是在虚拟机里边玩的& &现在恢复过去了呢& &:(mars_11):mars_11):& /& :ldw11: 没事没事,继续加油!
最典型的错误、、、
楼主怎么解决 我也出现这个问题了 配置文件也没有错误 提示信息也没有&&就说失败了&&郁闷啊一、环境Centos5.5 32位。二、安装包dhclient-3.0.5-18.el5dhcp-3.0.5-18.el5dhcp-devel-3.0.5-18.el5三、进行主文件:1)下面配置的dhcp是A类网址,终端是某个地市的所有机顶盒。2)本机配置了dns,地址为:10.1.0.17。如果没有配的话,dhcp中可删除。3)由于是用来给机顶盒分配,因此配置了option60。 & 如果是终端是的话,则可以删除相关选项。比如最后一步的测试,我们需要拿来测试,因此删除:class &STB& 以及option vendor-class-identifier和allow members of &STB&选项,以便允许给笔记本分配ip地址。 & &以下是配置文件:vi /etc/dhcpd.conf########################################## DHCP Server Configuration file.# &see /usr/share/doc/dhcp*/dhcpd.conf.sample### DHCP Server Configuration file.# &see /usr/share/doc/dhcp*/dhcpd.conf.sample#ddns--ignore client-option domain-name-servers 10.1.0.17;default-lease-time & 25600;max-lease-time & & & 86400;class &STB& { & match if substring (option vendor-class-identifier, 0, 14) =&DTV-CHINA&;} & subnet 10.140.128.0 netmask 255.255.224.0 { & & & pool { & & & & & range 10.140.128.6 10.140.159.250; & & & & & option routers & & & & & & & & 10.140.128.1; & & & & & option subnet-mask & & & & & & 255.255.224.0; & & & & & option vendor-class-identifier &DTV-CHINA&; & & & & & allow members of &STB&; & & & } & &} & subnet 10.140.160.0 netmask 255.255.224.0 { & & & pool { & & & & & range 10.140.160.6 10.140.191.250; & & & & & option routers & & & & & & & & 10.140.160.1; & & & & & option subnet-mask & & & & & & 255.255.224.0; & & & & & option vendor-class-identifier &DTV-CHINA&; & & & & & &allow members of &STB&; & & & } & &} & #下面还有很多的subnet子网就不列举了。 & subnet 10.140.192.0 netmask 255.255.224.0 { & & & pool { & & & & & & & ... ...
& & & } & &}四、将eth1设置为自动获取ip地址:vi/etc/sysconfig/-scripts/ifcfg-eth1######################################### Intel Corporation 82574L Gigabit NetworkConnectionDEVICE=eth1BOOTPROTO=dhcpHWADDR=C8:60:00:EA:45:7CONBOOT=yesTYPE=EthernetUSERCTL=noIPV6INIT=noPEERDNS=yes########################################五、增加本机各个网段地址 & &如果需要实现以下的配置,则需要在中配置vlan,与之对应。 & &如果是做最后一步测试的话,则可以简单化。比如我们要压力测试下10.140.128网段的,则在以上配置文件中仅留下subnet 10.140.128.0这一项,并且可以配置为10.140.128.5 进行测试。 & &另外,最后一行为在本中启动dhcpd服务的命令,而不要将服务配置为自动启动。原因是服务器启动时,中的服务是优先于下面的脚本先启动。如果脚本上的那些ip没有配置上的话,dhcpd启动会失败。vi/etc/rc.d/rc.local########################################!//sh## This scriptwill be executed *after* all the other init scripts.# You can putyour own initialization stuff in here if you don't# want to do thefull Sys V style init stuff.touch/var/lock/subsys/localvconfig add eth1301vconfig add eth1311ifconfig eth10.0.0.0 upifconfig eth1.301 10.1.0.17 netmask 255.255.255.0 up & & & & & &#dns安装在本机ifconfig eth1.311 10.140.128.5 netmask 255.255.224.0 upifconfig eth1.312 10.140.160.5 netmask 255.255.224.0 uproute add -net0.0.0.0 netmask 0.0.0.0 gw 10.1.0.254/etc/init.d/dhcpd start在启动服务前,可以将删除/var/lib/dhcpd/dhcpd.leases*,以便能够准确的查看dhcpd.leases文件的变化。六、删除arp有时候,地址分配会出现一些问题,可以使用删除arp的命令来清空缓存:1,删除某一个ip地址缓存: & &arp -d 10.140.128.2542,删除某一段ip地址缓存; & & ((i=1;i&=255;i++));do arp -d 10.140.128.&$i& &&/dev/done3,删除所有的ip地址缓存:ip n f dev eth1 或 ip neigh flush dev eth1七、子网简单算法255.255.224.0 转换成为 11 00. 即19/0(19个1)前面的1表示的是子网,后面的0表示的是每个子网可带的ip地址。ip地址个数大概为:2的5次方×255 = 32×255。因此dhcp中的range,每一段都是32×255-1个ip地址range 10.140.128.1 10.140.159.255;range 10.140.160.1 10.140.191.255;range 10.140.192.1 10.140.223.255;range 10.140.224.1 10.140.255.255;而如果地址不够用的话,则可以将上面的地址池进行扩大,可以将子网改成18/0,即:0 00,即255.255.192.0。此时,range每一段为64×255-1个ip地址:range 10.140.128.110.140.191.255;range 10.140.192.110.140.255.255;如果配置要扩大的话,可能还需要修改核心交换机的配置。另外,A类地址的0和255居然也能被分配到,比如子网是255.255.224.0,可以在笔记本上配置 10.140.129.0或者是10.140.129.255,居然也能ping通dhcp服务器。这应该是跟c类地址不一样的地方吧。八、测试参考资料:/support/measurement-tools//p-.html/view/f5acfa1c7cd32.html由于dhcpd服务器配置了option60,只能给机顶盒分配ip地址。因此,我们不能直接进行测试。为了测试方便,我们对配置文件进行了修改(以下红色表示dhcp服务器,蓝色表示测试),将服务器的ip地址改成 10.140.128.5 :[@adp-ds ~]# more /etc/dhcpd.conf## DHCP Server Configuration file.# & see/usr/share/doc/dhcp*/dhcpd.conf.sample &#ddns-update-ignore client-option domain-name-servers 10.1.0.17;default-lease-time & & 25600;max-lease-time & & & 86400;subnet 10.140.128.0 netmask 255.255.224.0 { & & & &pool{ & & & & & & & range 10.140.128.6 10.140.156.250; & & & & & & & option routers & & & & & & & & 10.140.128.1; & & & & & & & option subnet-mask & & & & & & 255.255.224.0; & & & &}}重启下dhcpd:# service dhcpd restart准备一台测试机器,可以是centos5.5 32bit。将测试机与dhcpd服务器通过网线连接起来,并确认能够进行通讯,这里我们将测试机器连接到dhcpd服务器的10.140.128网段,测试客户端的ip地址设置为10.140.128.4。下载dhcperf-1.0.1.0-1-rhel-4-i386.tar,解压出dhcperf-1.0.1.0-1.i386.rpm进行安装:#tar -zxvf dhcperf-1.0.1.0-1-rhel-4-i386.tarcd dhcperf-1.0.1.0-1-rhel-4-i386rpm -ivh dhcperf-1.0.1.0-1-rhel-4-i386.rpmcd/usr/local/nom/bin/./dhcperf --help在dhcpd服务器再开启3个tty,用来监测两个文件(地址分配文件、系统日志文件)和系统资源使用情况:# tail -f /var/lib/dhcpd/dhcpd.leases# tail -f /var/log/# top开始测试(第一条命令是只获取一个ip地址,看看是否可以获取到):# ./dhcperf --server 10.140.128.5 --one-discoverSending DHCPDISCOVER.Received DHCPOFFER of 10.140.155.255.Sending DHCPREQUEST for 10.140.155.255.Received DHCPACK of 10.140.155.255.Acquired address: 10.140.155.255一个ip地址获取ip地址正常,继续测试:./dhcperf --server 10.140.128.5 --discover --clients 2此时,ip地址获取也正常,但过一段时间后,dhcpd服务器上系统日志有大量的错误信息:Sep &6 10:27:13 adp-ds kernel: Neighbour tableoverflow.Sep &6 10:27:13 adp-ds kernel: printk: 364messages suppressed.到上搜索“dhcpd Neighbour table”,有个资料 /2011/02/neighbour-table-overflow-sysctl-conf-tunning/中说的比较详细。对系统参数进行修改:#vi /etc/sysctl.confnet.ipv4.neigh.default.gc_thresh1= 4096net.ipv4.neigh.default.gc_thresh2 = 8192net.ipv4.neigh.default.gc_thresh3 = 8192net.ipv4.neigh.default.base_reachable_time = 86400net.ipv4.neigh.default.gc_stale_time = 86400#sysctl -p重新启动dhcpd后再次在测试客户端执行:./dhcperf --server 10.140.128.5 --discover --clients 2就不再出现上面的问题了。执行完毕后,使用perl的脚本对/var/lib/dhcpd/dhcpd.leases 进行排序。即根据分配的地址进行排序处理,然后查看排序后的文件的ip地址分配情况。我将perl安装到我工作笔记的D:/Perl64/下,将/var/lib/dhcpd/dhcpd.leases拷贝到D:/Perl64/。然后执行下面的perl脚本。如果是在其他的目录,或者是环境下,可以修改下这个脚本的4个文件的路径即可,以下共享下perl脚本,写的不好,请多多指教:#! /usr/bin/perluse 5.010;use Data::Dif(open(MYFILE,&D:/Perl64/dhcpd.leases&)==0){die (&Can't open the file! \n&);}my $my $my %######################################################################################### 本 while 循环从原始文件中读取数据,存入到hash结构中。对ip地址进行了处理,处理后的### 格式为xxx.xxx.xxx.xxx,以方便字符排序。### hash 结构的 key 为 ip 地址(最后面还有个回车符);value的格式为:### & &starts 5
03:18:52;### & &ends 5
10:25:32;### & &### & &nex### & &hardware ethernet 00:00:00:00:00:01;### & &uid &dhcperf_1&;### &}######################################################################################while(&MYFILE&){ &if (/^lease /) { & &$key = $_; & &$value = http://sandjj./1141448/ &} &else { & &$value = http://sandjj./1141448/$value.$_; &} &if (/^}/) { & &### 对key进行处理将“lease 10.140.128.10 {”格式化成“010.140.128.010” ### & &$key =~ s/lease //; & & & & & & & & & & & & & & & & & & &# 去掉“lease” & &$key =~ s/ {//; & & & & & & & & & & & & & & & & & & & & &# 去掉“ {” & &### 格式化成 &xxx.xxx.xxx.xxx & &$key=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/; & &$key =sprintf(&%03d&,$1).&.&.sprintf(&%03d&,$2).&.& & & & & &.sprintf(&%03d&,$3).&.&.sprintf(&%03d&,$4).&\n&; & & &#################### & &### 存入到hash结构中; & &$content{$key} = $ &}}close(MYFILE);############################################################################################################################################################################### 将排序后的信息先写入两个文件,并将ip地址存入另外一个hash表。### 第一个文件dhcpd2.leases 为排序后的带有原始mac地址等的信息;### 第二个文件dhcpd3.leases 为排序后的纯IP地址信息;每个ip地址为一行,从小到大排序### 而另外存入的hash表%ipdata的信息,其key为ip地址的网段,如010.140.129;### & 而value为ip地址的数组,从最小到最大排序,如 010.140.129.000一直到010.140.129.255######################################################################################if(open(WriteFILE1,& & D:/Perl64/dhcpd2.leases&)==0) { &die (&Can't open the file! \n&);}if(open(WriteFILE2,& & D:/Perl64/dhcpd3.leases&)==0) { &die (&Can't open the file! \n&);}my %my$ipkey=&&;my @ipvalue = http://sandjj./1141448/();foreach $key(sortkeys %content) { &print WriteFILE1&$key$content{$key}&; &print WriteFILE2 &$key&; &#可以将这些ip地址到一个二维数组(8×256)中,然后写入文件比较好阅读 &if (($ipkey ne substr $key, 0, 11) &&(scalar @ipvalue != 0)) &{ & &#say Dumper \@ & &$ipdata{$ipkey} = [@ipvalue]; & &@ipvalue = http://sandjj./1141448/(); &} &$ipkey = substr $key, 0, 11; &$ipvalue[(substr $key, 12, 3)] = substr $key,0, 15; &#say $ipvalue[$i];}$ipdata{$ipkey} =[@ipvalue];close(WriteFILE1);close(WriteFILE2);############################################################################################################################################################################### &将 %ipdata 这个hash表的key排序后存入到数组 @networksection######################################################################################my @networksection =();foreach $key(sortkeys %ipdata) { &push @networksection, $ }#say Dumper\@############################################################################################################################################################################### 开始写二维数组文件,以便更好的阅读### 该文件共 8 列,每 256 行为一个块,然后空一行,再继续256行。每一列第一行有头部,表示某个### 子网。类似于:###-------------------------------------------------------### 010.140.128. & &010.140.129. & & & & & &010.140.135.###-------------------------------------------------------### 010.140.128..129.000 ... ... 010.140.135.000### 010.140.128..129.001 ... ... 010.140.135.001### &... ... ... ...### 010.140.128..129.255 ... ... 010.140.135.255### (空一行)###-------------------------------------------------------### 010.140.136. & &010.140.137. & & & & & &010.140.143.###-------------------------------------------------------### 010.140.136..137.000 ... ... 010.140.143.000### &... ... ... ...### &... ... ... ...### 010.140.136..137.255 ... ... 010.140.143.255### (空一行)### &... ... ... ...### &... ... ... ...###### 如果IP地址不存在,则以空格代替。这样,看起来就方便多了######################################################################################my $step =8; & & & & & & & & & & & & & & & & &# 即 8 列if(open(WriteFILE3,& & D:/Perl64/dhcpd4.leases&)==0){ &die (&Can't open the file! \n&);}for (my $j=0;$j&@networksection/$ $j++){ &## 一行满 8 列的处理(有可能最后一个块不满 8列,则在 else 中进行处理) &if (@networksection &= ($j+1) * $step) &{ & &for (my $x=-3; $x&256; $x++) & &{ & & &my $string = &&; & & &#$string = $j. & &&; & & &for (my $k=0; $k&$ $k++) & & &{ & & & &my $temp = &&; & & & &if ($x & -1) { & & & & &$temp =${$ipdata{$networksection[$j*$step+$k]}}[$x] ; & & & &} & & & &elsif (($x == -3) || ($x == -1)) { & & & & &$temp = &---------------&; & & & & & & & & &} & & & &elsif ($x == -2){ & & & & &$temp = $networksection[$j*$step+$k]; & & & & &$temp = $temp . &. & &; & & & &} & & & &if (! defined &$temp) & & & &{ & & & & &# 如果ip地址不存在,则使用相同长度的空格代替 & & & & &$temp=& & & & & & & & &; & & & &} & & & &$string = $string . $temp . & &&
& & &} & & &$string =~ s/ +$//; & & & & & & & & & & & & & # 截掉最后的空格 & & &#say $ & & &print WriteFILE3 &$string\n&; & &} & &#say &&; & &print WriteFILE3 &\n&; &} &else &# 最后一块不满 8列情况的处理 &{ & &for (my $x=-3; $x&256; $x++) & &{ & & &my $string = &&; & & &#$string = $j. & &&; & & &for (my $k=0; $k&(@networksection - $j* $step); $k++) & & &{ & & & &my $temp = &&; & & & &if ($x & -1) { & & & & &$temp = ${$ipdata{$networksection[$j*$step+$k]}}[$x]; & & & &} & & & &elsif (($x == -3) || ($x == -1)) { & & & & &$temp = &---------------&; & & & & & & & & &} & & & &elsif ($x == -2){ & & & & &$temp = $networksection[$j*$step+$k]; & & & & &$temp = $temp . &. & &; & & & &} & & & &if (! defined &$temp) & & & &{ & & & & &$temp=& & & & & & & & &; & & & &} & & & &$string = $string . $temp . & &&
& & &} & & &$string=~s/ +$//; & & &#say $ & & &print WriteFILE3 &$string\n&; & &} &}}close(WriteFILE3);九、后记 & &使用以上perl脚本,对正式系统上的的dhcpd.leases进行处理效果很显著,对已经分配的ip地址查看非常方便。不过由于正式系统正在运营,因此,不好进行压力测试。 & &不过发现一个奇怪的现象,正式系统中,centos5.5下的dhcp服务,分配出去的ip地址是从最后开始分配的。而且呈现三角的形状。如,10.140.128.6 10.140.156.250 网段,分配出去的地址为:10.140.132 &254 25510.140.133 &252 253 254 25510.140.134 &250 251 252 253 254 25510.140.135 &248 249 250 251 252 253 254 255... &...10.140.158 &203 &.... & & & & & & & & & & & & & & & & & & & & & &25510.140.159 &201 .... & & & & & & & & & & & & & & & & & & & & & & 255 & &搞不清楚系统为何怎么分配。按照这个规律,从132到159共有28层,第一层为2个ip地址,理论上共有ip地址为(1+28)×28=812个,如果是这样的话,生产环境ip地址肯定不够用。正式系统的系统日志也有说地址不够用的异常,待下次出现用户投诉我再研究。 & &不过,在以上的测试系统中,如果人为的搞几台客户端进行验证,ip地址确实是从后面进行分配了。网上查了下有关的资料,也证实了这一点。而在测试系统的压力测试时,发现所有的地址都已被分配出去。因此,我想地址分配应该是正常的。正式系统需要继续观察是否分配了以上现象中提到的ip地址之外的地址。十、参考资料/2011/02/neighbour-table-overflow-sysctl-conf-tunning/Neighbour table overflow – sysctl.conf tunningIf you have a big network with the hundreds of hosts youcan expect “Neighbour table overflow” error which occurs in large networks whenthere are two many ARP requests which the server is not able to reply. Forexample you’re using server as a DHCP server, cable modems provisioning, etc.Nov 10 03:18:17 myhost Neighbour table overflow.Nov 10 03:18:23 myhost printk: 12 messages suppressed.Of curse, this can be fixed. The solution is to increasethe threshhold values in /etc/sysctl.conf. Add following lines to/etc/sysctl.conf (RH based distros)net.ipv4.neigh.default.gc_thresh1 = 4096net.ipv4.neigh.default.gc_thresh2 = 8192net.ipv4.neigh.default.gc_thresh3 = 8192net.ipv4.neigh.default.base_reachable_time = 86400net.ipv4.neigh.default.gc_stale_time = 86400Save sysctl.conf and execsysctl -p. You can also reboot but it isn’t necessary.The default sysctl.conf filenet.ipv4.ip_forward=0kernel.shmmax=kernel.msgmax=65536kernel.msgmnb=65536net.ipv4.conf.default.rp_filter=1kernel.sysrq=0net.ipv4.conf.default.accept_source_route=0kernel.shmall=kernel.core_uses_pid=1net.ipv4.tcp_syns=1“Tuned” systctl.confnet.ipv4.ip_forward=0kernel.shmmax=kernel.msgmax=65536kernel.msgmnb=65536net.ipv4.conf.default.rp_filter=1kernel.sysrq=0net.ipv4.conf.default.accept_source_route=0kernel.shmall=kernel.core_uses_pid=1net.ipv4.tcp_syncookies=1net.ipv4.neigh.default.gc_thresh1 = 4096net.ipv4.neigh.default.gc_thresh2 = 8192net.ipv4.neigh.default.gc_thresh3 = 8192net.ipv4.neigh.default.base_reachable_time = 86400net.ipv4.neigh.default.gc_stale_time = 86400Explanation…The neighbour table is generally known as ARP table andthe default value for gc_thresh1 is 128 (Adjust where the gc will leave arptable alone)[root@myServer ~]# cat /proc/sys/net/ipv4/neigh/default/gc_thresh1128which is not enough for large networks (more than 128hosts). Thats why we need to tune this value. The gc_thresh2 is a soft limit(Tell the gc when to become aggressive with arp table cleaning.) and thegc_thresh3 is a hard limit (Don’t allow the arp table to become bigger thanthis).To enlarge the ARP cache table width="456"># sysctl -w net.ipv4.neigh.default.gc_thresh3=8192# sysctl -w net.ipv4.neigh.default.gc_thresh2=8192# sysctl -w net.ipv4.neigh.default.gc_thresh1=4096It is possible that after distro update your systctl.confwill be replaced with the default values. Check this file periodically..

我要回帖

更多关于 centos配置dhcp服务器 的文章

 

随机推荐