详细说明参照:
(四)跟我一起玩Linux网络服务:DHCP服务配置之中继代理
vm1的脚本是:
#! /bin/bash HIPSEG="10.10.10"
SIPSEG="192.168.128"
HRoute="10.10.10.10"
SRoute="192.168.128.8"
DN="ns.gr.org" cat > /etc/dhcpd.conf << +END+
ddns-update-style interim;
ignore client-updates; subnet $HIPSEG. netmask 255.255.255.0 {
option routers $HRoute;
option subnet-mask 255.255.255.0;
option domain-name "$DN";
option domain-name-servers $HRoute;
option time-offset ;
range dynamic-bootp $HIPSEG. $HIPSEG.;
default-lease-time ;
max-lease-time ;
}
subnet $SIPSEG. netmask 255.255.255.0 {
option routers $SRoute;
option subnet-mask 255.255.255.0;
option domain-name "$DN";
option domain-name-servers $HRoute;
option time-offset ;
range dynamic-bootp $SIPSEG. $SIPSEG.;
default-lease-time ;
max-lease-time ;
}
+END+
service dhcpd restart
ps -ax | grep dhcpd route add -net $SIPSEG./ gw $HRoute
vm2的脚本是:
#! /bin/bash
IP="10.10.10"
RIP="10.10.10"
DN="gr.org"
Name="10.10.10.10"
cat >> /etc/named.conf << +END+
zone "$DN." IN {
type master;
file "gr.org.db";
};
zone "$RIP.in-addr.arpa" IN{
type master;
file "$IP.db";
};
+END+
cat > /var/named/$DN.db <<+END+
\$TTL
@ IN SOA ns.$DN. root.$DN. (
6H 30M 1W 15M)
IN NS ns.$DN.
IN MX mail.$DN.
bbs IN CNAME www.$DN.
ns IN A $IP.
www IN A $IP.
mail IN A $IP.
+END+
cat > /var/named/$IP.db <<+END+
\$TTL
@ IN SOA ns.$DN. root.$DN.(
6H 30M 1W 15M)
IN NS ns.$DN.
IN PTR ns.$DN.
IN PTR www.$DN.
IN PTR mail.$DN.
+END+
cat > /etc/resolv.conf <<+END+
nameserver $Name
+END+ service named start