Linux DHCP服务器维护修改DNS服务器
2016-05-09 15:27
525 查看
Linux 做网关,由于是PPPOE拨号,遇到过DNS服务器变动的情况导致DHCP获得的DNS失败的案例。
由于DHCPD平时承担MAC地址绑定工作,所以配置文件很大。今天修改了一下,可以使用。
需求
1.双网卡,DHCP平时放在192.168.0.0网段,另外一个网卡不用;
2.根据PPPOE拨号软件,自动使用/etc/resolve.conf里面的DNS服务器
解决方案:
修改 /etc/sysconfig/dhcpd
#Command line options here
inetwork=192.168.0.0
inetface=`route -n | grep $inetwork | awk '{print $8}'`
dnsfile=/etc/resolv.conf
if [ -e $dnsfile ] ;then
if grep nameserver $dnsfile > /dev/null ;then
dns1=`cat $dnsfile |grep nameserver | cut -d' ' -f2 |tail -n1 | head -n1` > /dev/null
dns2=`cat $dnsfile |grep nameserver | cut -d' ' -f2 |tail -n2 | head -n1` > /dev/null
sed -e "s/\(^[ \t]\+option domain-name-servers[ \t]\)\+.\+/\1 $dns1,$dns2;/g" /etc/dhcpd.conf > /tmp/dhcpd.conf
DHCPDARGS="$inetface -cf /tmp/dhcpd.conf"
fi
fi
在/tmp/dhcpd.conf 保存新文件,
以上在Centos 5.10上调试通过。
由于DHCPD平时承担MAC地址绑定工作,所以配置文件很大。今天修改了一下,可以使用。
需求
1.双网卡,DHCP平时放在192.168.0.0网段,另外一个网卡不用;
2.根据PPPOE拨号软件,自动使用/etc/resolve.conf里面的DNS服务器
解决方案:
修改 /etc/sysconfig/dhcpd
#Command line options here
inetwork=192.168.0.0
inetface=`route -n | grep $inetwork | awk '{print $8}'`
dnsfile=/etc/resolv.conf
if [ -e $dnsfile ] ;then
if grep nameserver $dnsfile > /dev/null ;then
dns1=`cat $dnsfile |grep nameserver | cut -d' ' -f2 |tail -n1 | head -n1` > /dev/null
dns2=`cat $dnsfile |grep nameserver | cut -d' ' -f2 |tail -n2 | head -n1` > /dev/null
sed -e "s/\(^[ \t]\+option domain-name-servers[ \t]\)\+.\+/\1 $dns1,$dns2;/g" /etc/dhcpd.conf > /tmp/dhcpd.conf
DHCPDARGS="$inetface -cf /tmp/dhcpd.conf"
fi
fi
在/tmp/dhcpd.conf 保存新文件,
以上在Centos 5.10上调试通过。
相关文章推荐
- Linux socket 初步
- Linux Kernel 4.0 RC5 发布!
- linux lsof详解
- linux 文件权限
- Linux 执行数学运算
- 10 篇对初学者和专家都有用的 Linux 命令教程
- Linux 与 Windows 对UNICODE 的处理方式
- Ubuntu12.04下QQ完美走起啊!走起啊!有木有啊!
- 解決Linux下Android开发真机调试设备不被识别问题
- 运维入门
- 运维提升
- Linux 自检和 SystemTap
- Ubuntu Linux使用体验
- c语言实现hashmap(转载)
- Linux 信号signal处理机制
- linux下mysql添加用户
- Scientific Linux 5.5 图形安装教程
- Linux 下无损图片压缩小工具介绍