系統:Red Hat Enterprise Linux 4 AS 4.0實現:DHCP+DNS
1、生成KEY
# dnssec-keygen -a HMAC-MD5 -b 128 -n USER DHCP_UPDATER
這時當前目錄下會生成Kdhcp_updater.+xxx+xxxxx.key及.private兩個文件
# cat Kdhcp_updater.+xxx+xxxxx.key
DHCP_UPDATER. IN KEY 0 2 157 qSSpjerAuaPE/X3JJyxSww==
其中qSSpjerAuaPE/X3JJyxSww==下面要用到的
2、DHCP
在dhcpd.conf後加上
# ----------- DDNS -----------------
key DHCP_UPDATER {
algorithm HMAC-MD5;
secret "qSSpjerAuaPE/X3JJyxSww==";
}
zone scott.home. {
primary 127.0.0.1;
key DHCP_UPDATER;
}
ps:PXE安裝中option domain-name及option domain-name-servers前面的“#”也 可以去掉了,因為下面我們來設DNS
3、DNS
# rpm -qa | gerp bind
看有沒有bind-xx及bind-chroot-xx理論上chroot可以提高安全性但設置時繁瑣一點
# rpm -qa | gerp caching-name
看caching-nameserver是否也已經裝了,這個不裝的話就要自己寫named.ca等幾個文 件了
# vi /etc/named.conf 在最後加上
key DHCP_UPDATER {
algorithm HMAC-MD5;
secret "qSSpjerAuaPE/X3JJyxSww==";
};
zone "scott.home" IN {
type master;
file "scott.home.zone";
allow-update { key DHCP_UPDATER; };
};
# cd /var/named/chroot/var/named
# cp localdomain.zone scott.home.zone
# chown named:named scott.home.zone
# cd /var/named/chroot/var
# chown named:named named/
# cd /var/named
# ln -s /var/named/chroot/var/named/scott.home.zone
# vi scott.home.zone (修改成你自己的DNS設置,不要抄我)
$TTL 86400
@ IN SOA scott.home. root.scott.home. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
@ IN NS scott.home.
@ IN A 192.168.1.100
4、防火牆iptables
# iptables -F
# iptables -P INPUT DROP
# iptables -A INPUT -i lo -j ACCEPT
# iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
# iptables -A INPUT -s 192.168.1.0/24 -p tcp -m multiport --dports 53,953 -j ACCEPT
# iptables -A INPUT -s 192.168.1.0/24 -p udp -m multiport --dports 53,953 -j ACCEPT
# /etc/init.d/iptables save 實際實驗中可關閉iptables:service iptables stop
5、啟動服務
# /etc/init.d/dhcpd restart
# chkconfig dhcpd on
# /etc/init.d/named restart
# chkconfig named on
6、測試(主要講講LINUX,實驗過程中發現windows作客戶機還不行)
在客戶機上加入一個文件/etc/dhclient.conf內容如下
send fqdn.fqdn "test"; //test為本機的hostname
send fqdn.encoded on;
send fqdn.server-update off;
運行dhclient或重新啟動
正常的話DNS服務器主機的/var/named/chroot/var/named下會多出一個以jnl結尾的
文件如:scott.home.zone.jnl 這時ping test.scott.home看看能否PING通
測試均已通過