您的位置:首页 > 运维架构 > Shell

快速配置DHCP中继(shell脚本)

2010-07-24 14:30 417 查看
在DHCP服务器上执行以下脚本
#!/bin/sh
INSTALL_DIR=`pwd`
rpm -ivh dhcp-3.0.5-3.el5.i386.rpm &>/dev/null
echo 'ddns-update-style none;
default-lease-time 36000000;
max-lease-time 43200000;
option domain-name "xxx.com";
option domain-name-servers 61.134.1.4;
subnet 172.16.100.0 netmask 255.255.255.0 {
range dynamic-bootp 172.16.100.10 172.16.100.254;
option routers 172.16.100.1;
option subnet-mask 255.255.0.0;
host manager {
next-server marvin.redhat.com;
hardware ethernet 12:34:56:78:AB:CD;
fixed-address 172.16.100.88;
}
}
subnet 192.168.1.0 netmask 255.255.255.0 {
range dynamic-bootp 192.168.1.111 192.168.1.191;
option routers 192.168.1.1;
option subnet-mask 255.255.255.0;
host manager1 {
next-server marvin.redhat.com;
hardware ethernet 12:34:56:78:AB:CD;
fixed-address 172.16.100.88;
}
}
subnet 10.1.10.0 netmask 255.255.255.0 {
range dynamic-bootp 10.1.10.200 10.1.10.250;
option routers 10.1.10.1;
option subnet-mask 255.0.0.0;
host manager2 {
next-server marvin.redhat.com;
hardware ethernet 12:34:56:78:AB:CD;
fixed-address 172.16.100.88;
}
}' > /etc/dhcpd.conf
echo '# Command line options here
DHCPDARGS="eth0" ' >/etc/sysconfig/dhcpd
service dhcpd restart &>/dev/null
rm -rf $INSTALL_DIR/*

在dhcp中继服务器上执行下面的脚本
#!/bin/sh
INSTALL_DIR=`pwd`
rpm -ivh dhcp-3.0.5-3.el5.i386.rpm &>/dev/null
vi /etc/sysctl.conf << EOF &>/dev/null
/net.ipv4.ip_forward = 0
:s/0/1/
:wq
EOF
sysctl -p &>/dev/null
echo '# Command line options here
INTERFACES="eth0 eth1 eth2"
DHCPSERVERS="172.16.100.10" ' > /etc/sysconfig/dhcrelay
service dhcrelay start &>/dev/null
chkconfig --level 35 dhcrelay on
rm -rf INSTALL_DIR/dhcrelay.sh

注意:在做之前需要准备DHCP软件包(RPM包),可以下载最新版本的,也可以通过挂载Red Hat 5的光盘,然后找到DHCP软件包,进行安装。脚本里面的配置你只需根据实际情况进行修改即可使用。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  DHCP 脚本 shell 休闲 中继