dns
安装# yum install bind bind-chroot caching-nameserver -y# cd /var/named/chroot/etc# mkdir backup[root@teacher etc]# cp -p named.caching-nameserver.conf ./backup[root@teacher etc]# cp -p named.rfc1912.zones ./backup# pwd/var/named/chroot/etc# mv named.caching-nameserver.conf named.conf
# vim named.confoptions {
directory "/var/named";};include "/etc/named.rfc1912.zones";
# vim named.rfc1912.zones
zone "google.com" IN { type master; file "google.com.zone";};//zone "0.0.127.in-addr.arpa" IN {
// type master;// file "named.local";// allow-update { none; };//};# cd /var/named/chroot/var/named
# cp -p localhost.zone google.com.zone# vim google.com.zone$TTL 86400
@ IN SOA dns.google.com. root.dns.google.com. ( 42 ; serial (d. adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimumIN NS dns.google.com.
dns IN A 192.168.3.2www IN A 192.168.3.3ftp IN A 192.168.3.4启动服务
# service named restart客户端修改
# vim /etc/resolv.confnameserver 192.168.3.2# nslookup
Server: 192.168.3.2Address: 192.168.3.2#53Name:
Address: 192.168.3.3[root@teacher etc]# nslookup
Server: 192.168.3.2Address: 192.168.3.2#53Name:
Address: 192.168.3.4 ------------反向解析# vim /var/named/chroot/etc/named.rfc1912.zones
zone "google.com" IN { type master; file "google.com.zone";};zone "3.168.192.in-addr.arpa" IN {
type master; file "192.168.3.file";};# cd /var/named/chroot/var/named
[root@teacher named]# cp -p named.local 192.168.3.file
[root@teacher named]# vim 192.168.3.file$TTL 86400
@ IN SOA dns.google.com. root.dns.google.com. ( 1997022700 ; Serial 28800 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Minimum IN NS dns.google.com.2 IN PTR dns.google.com.3 IN PTR .4 IN PTR .服务重启
# service named restart# nslookup 192.168.3.3
Server: 192.168.3.2Address: 192.168.3.2#533.3.168.192.in-addr.arpa name = .
[root@teacher named]# nslookup 192.168.3.4
Server: 192.168.3.2Address: 192.168.3.2#534.3.168.192.in-addr.arpa name = .
----------------
# cd /var/named/chroot/var/named # vim google.com.zone$TTL 86400
@ IN SOA dns.google.com. root.dns.google.com. ( 42 ; serial (d. adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimumIN NS dns.google.com.
dns IN A 192.168.3.2www IN A 192.168.3.5www IN A 192.168.3.6www IN A 192.168.3.7www IN A 192.168.3.8www IN A 192.168.3.9www IN A 192.168.3.11ftp IN A 192.168.3.4服务重启
# service named restart # ping---------------------------
主从同步[root@teacher named]# cd /var/named/chroot/etc
[root@teacher etc]# lsbackup localtime named.conf named.rfc1912.zones rndc.key[root@teacher etc]# dnssec-keygen -a hmac-md5 -b 128 -n host 3key K3key.+157+65317[root@teacher etc]# ls# cat K3key.+157+65317.key
3key. IN KEY 512 3 157 tb69ZLlWPvQ+LHOjIYG6yQ== //复制密钥# vim named.conf
options { directory "/var/named";};key 3key {
algorithm hmac-md5; secret "tb69ZLlWPvQ+LHOjIYG6yQ=="; }; include "/etc/named.rfc1912.zones";# vim named.rfc1912.zones
zone "google.com" IN {
type master; file "google.com.zone"; allow-transfer { key 3key; };};zone "3.168.192.in-addr.arpa" IN {
type master; file "192.168.3.file"; allow-transfer { key 3key; };};启动域名服务
# service named restart------------------------------从域名服务器安装bind# yum install bind bind-chroot caching-nameserver -y从主域名服务器把配置文件拷过来
# scp 192.168.3.2:/var/named/chroot/etc/named* /var/named/chroot/etc/# cd /var/named/chroot/etc
# ls -l# chown root:named named.conf# vim named.conf
options { directory "/var/named/slaves";};key 3key {
algorithm hmac-md5; secret "tb69ZLlWPvQ+LHOjIYG6yQ=="; }; include "/etc/named.rfc1912.zones";# vim named.rfc1912.zones
zone "google.com" IN {
type slave; file "google.com.zone.slave"; masters { 192.168.3.2 key 3key; };};zone "3.168.192.in-addr.arpa" IN {
type slave; file "192.168.3.file.slave"; masters { 192.168.3.2 key 3key; };};启动域名服务
# service named restart# cd /var/named/chroot/var/named/slaves# ls192.168.3.file.slave google.com.zone.slave-------------------------------------------
子域授权在父域名服务器
[root@teacher etc]# pwd/var/named/chroot/# vim named.confoptions { directory "/var/named";};include "/etc/named.rfc1912.zones";
# vim named.rfc1912.zones
zone "google.com" IN {
type master; file "google.com.zone";};# cd /var/named/chroot/var/named
# vim google.com.zone $TTL 86400@ IN SOA dns.google.com. root.dns.google.com. ( 42 ; serial (d. adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimumIN NS dns.google.com.
dns IN A 192.168.3.2develop.google.com. IN NS dns.develop.google.com.dns.develop.google.com. IN A 192.168.3.5www IN A 192.168.3.6启动服务
# service named restart----------------------------------子域名服务器# cd /var/named/chroot/etc# scp 192.168.3.2:/var/named/chroot/etc/named* ./# chown root:named named.conf
[root@teacher etc]# chown root:named named.rfc1912.zones# vim named.rfc1912.zones
zone "develop.google.com" IN { type master; file "develop.google.com.zone";};# cd /var/named/chroot/var/named
# scp 192.168.3.2:/var/named/chroot/var/named/google.com.zone ./# mv google.com.zone develop.google.com.zone
# chown root:named develop.google.com.zone # vim develop.google.com.zone$TTL 86400
@ IN SOA dns.develop.google.com. root.dns.develop.google.com. ( 42 ; serial (d. adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimumIN NS dns.develop.google.com.
dns IN A 192.168.3.5www IN A 192.168.3.100启动服务
# service named restart用客户端测试----------------------------视图域名服务器
eth0 192.168.3.2eth1 172.16.3.1eth2 8.8.8.8# vim /etc/sysctl.conf
net.ipv4.ip_forward = 1
# sysctl -p修改配置文件
# cd /var/named/chroot/etc# vim named.conf
options {
directory "/var/named";}; acl "unicom" { 172.16.3.0/24; }; acl "telcom" { 192.168.3.0/24; };view "unicom" {
match-clients { unicom; }; recursion yes; zone "163.com" IN { type master; file "unicom.163.com"; }; }; view "telcom" { match-clients { telcom; }; recursion yes; zone "163.com" IN { type master; file "telcom.163.com"; }; }; # cd /var/named/chroot/var/named[root@teacher named]# cp -p google.com.zone unicom.163.com[root@teacher named]# vim unicom.163.com$TTL 86400
@ IN SOA dns.163.com. root.dns.163.com. ( 42 ; serial (d. adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimumIN NS dns.163.com.
dns IN A 8.8.8.8www IN A 172.16.3.100www IN A 172.16.3.200[root@teacher named]# cp -p unicom.163.com telcom.163.com
[root@teacher named]# vim telcom.163.com$TTL 86400
@ IN SOA dns.163.com. root.dns.163.com. ( 42 ; serial (d. adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimumIN NS dns.163.com.
dns IN A 8.8.8.8www IN A 192.168.3.100www IN A 192.168.3.200[root@teacher named]# service named restart
--------------------------
在电信客户端上用真机 设置网关 192.168.3.2 //这个ip地址是域名服务器桥接的网卡地址。 设置dns 服务器 8.8.8.8
点击开始--运行---cmd 回车
在命令行 nslookup 可以看到 电信的IP地址-------------------网通客户端# cd /var/sysconfig/network-scripts# vim ifcfg-eth0DEVICE=eth0BOOTPROTO=noneIPADDR=172.16.3.5ONBOOT=yesGATEWAY=172.16.3.1# service network restart
# vim /etc/resolv.confnameserver 8.8.8.8# nslookup