重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
很有用 )
公司主营业务:网站制作、做网站、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联建站是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联建站推出烈山免费做网站回馈大家。
实验环境搭建
1.先对desktop,server重置
2.对虚拟机内存进行设置,防止卡机。
3.服务端配置
(1)##配置网络
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
[root@localhost ~]# systemctl restart network
(2)##修改服务器名字
[root@localhost ~]# hostnamectl set-hostname dns-server.westos.com
[root@localhost ~]# hostname
dns-server.westos.com
(3)##配置yum源
[root@localhost ~]# vim /etc/yum.repos.d/rhel_dvd.repo
[root@localhost ~]# ifconfig
(4)##安装DNS
[root@dns-server ~]# yum search dns
[root@dns-server ~]# yum install bind.x86_64 -y
(5)##配置服务端
[root@dns-server ~]# systemctl stop firewalld ###关闭火墙
[root@dns-server ~]# ll /etc/rndc.key ##查看/etc/rndc.key文件信息
[root@dns-server ~]# systemctl start named ###开启服务
[root@dns-server ~]# ll /etc/rndc.key ##查看/etc/rndc.key文件信息
[root@dns-server ~]# cat /etc/rndc.key ##查看/etc/rndc.key文件内容
[root@dns-server ~]# netstat -antlpe | grep named
[root@dns-server ~]# vim /etc/named.conf #编辑配置文件
options { ##全局设定
listen-on port 53 { any; }; ##监听本地53端口
listen-on-v6 port 53 { ::1; }; ##关闭ipv6选项
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { any; }; ##允许与本地直连的网络使用
forwarders {172.25.254.250; } ##指向dns
[root@dns-server ~]# systemctl start named ###开启服务
[root@dns-server ~]# netstat -antlpe | grep named ###过滤所有有关named的信息
[root@dns-server ~]# cat /dev/random ###查看/dev/random 内容
一 正向解析
服务端
[root@dns-server ~]# cd /var/named
[root@dns-server named]# pwd
/var/named
[root@dns-server named]# ls
data named.ca named.localhost slaves
dynamic named.empty named.loopback
[root@dns-server named]# cp -p named.localhost westos.com.zone
##用模板生成用模板生成dns配置配置文件
[root@dns-server named]# vim westos.com.zone
[root@dns-server named]# vim /etc/named.rfc1912.zones
zone "westos.com" IN { #指定要维护的域名
type master;
file "westos.com.zone"; ##指定A记录文件名
allow-update { none; }; ##没有允许更新用户
};
[root@dns-server named]# systemctl restart named ###重启服务
客户端
3 vim /etc/resolv.conf #编辑配置文件
4 dig dns.westos.com ##查询
5 dig www.westos.com
二 多向解析
1. 配置网卡
服务端
添加网卡
配置网络
48 ifconfig
50 cd /etc/sysconfig/network-scripts/ ####切换到/etc/sysconfig/network-scripts/目录
51 ls
52 cp ifcfg-eth0 ifcfg-eth2 ###复制ifcfg-eth2 模板
53 ls
54 vim ifcfg-eth2 ##编辑 ifcfg-eth2文件
55 systemctl restart network ###重启网络
56 systemctl restart named ###重启服务
57 netstat -antlpe | grep named ###过滤所有有关named的信息
2
服务端
15 cd /var/named/
16 ls
20 cp -p westos.com.zone westos.com.inter ###复制westos.com.inter模板
21 vim westos.com.inter ##编辑 westos.com.inter文件
$TTL 1D
@ IN SOA dns.westos.com. root.westos.com. (
||
dns服务器的主机名 0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns.westos.com. ##指定dns主机
dns A 172.25.254.144 ##指定dns服务器的A记录
www A 172.25.254.244 ##要添加的A记录
music CNAME music.a.westos.com.
music.a A 172.25.254.111
music.a A 172.25.254.222
westos.com. MX 1 172.25.254.244.
22 cp -p /etc/named.rfc1912.zones /etc/named.rfc1912.inter ###复制 /etc/named.rfc1912.inter 模板
23 vim /etc/named.rfc1912.inter ##编辑/etc/named.rfc1912.inter文件
zone "westos.com" IN {
type master;
file "westos.com.inter";
allow-update { none; };
};
24 vim /etc/named.conf ##编辑/etc/named.conf 文件
view localnet {
match-clients { 172.25.254.0/24; };##允许网络使用
zone "." IN {
type hint;
file "named.ca";
};
include "/etc/named.rfc1912.zones";
};
view internet {
match-clients { 172.25.44.0/24; };##允许网络使用
zone "." IN {
type hint;
file "named.ca";
};
include "/etc/named.rfc1912.inter";
};
25 man named.conf ###named的说明
26 fg
29 systemctl restart named
49 systemctl status firewalld
50 systemctl stop firewalld
3 客户端测试254和44
45 mail root@westos.com ###创建邮件
46 mailq ###发送邮件
(1)172..25.254.144
23 vim /etc/resolv.conf
24 dig music.westos.com
25 dig -t mx westos.com
(2)172.25.44.11
1 vim /etc/resolv.conf
2 dig music.westos.com
3 dig -t mx westos.com
三 反向解析
服务器
58 vim /etc/named.rfc1912.zones
48 zone "254.25.172.in-addr.arpa" IN {
49 type master;
50 file "westos.com.ptr";
51 allow-update { none; };
52 };
59 cp -p named.loopback westos.com.ptr
60 vim westos.com.ptr
$TTL 1D
@ IN SOA dns.westos.com. root.westos.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns.westos.com.
dns A 172.25.254.244
111 PTR www.westos.com
61 systemctl restart named
客户端
dig -x 172.25.254.111.
四 dns更新
服务端
更新
[root@dns-server ~]# cp -p /var/named/westos.com.zone /mnt/
[root@dns-server ~]# vim /etc/named.rfc1912.zones
zone "westos.com" IN {
type master;
file "westos.com.zone";
allow-update { 172.25.254.144; };
};
[root@dns-server ~]# chmod 770 /var/named/
[root@dns-server ~]# setsebool -P named_write_master_zones 1
[root@dns-server ~]# systemctl restart named
查看更新
[root@dns-server ~]# cd /var/named
[root@dns-server named]# vim westos.com.zone
[root@dns-server named]# systemctl restart named
[root@dns-server named]# vim westos.com.zone
删除
[root@dns-server named]# rm -fr westos.com.zone westos.com.zone.jnl
[root@dns-server named]# cp -p /mnt/westos.com.zone .
[root@dns-server named]# ll -d
drwxrwx---. 5 root named 4096 May 6 04:17 .
[root@dns-server named]# ls -l
total 32
drwxrwx---. 2 named named 22 May 5 22:09 data
drwxrwx---. 2 named named 4096 May 6 04:10 dynamic
-rw-r-----. 1 root named 2076 Jan 28 2013 named.ca
-rw-r-----. 1 root named 152 Dec 15 2009 named.empty
-rw-r-----. 1 root named 152 Jun 21 2007 named.localhost
-rw-r-----. 1 root named 168 Dec 15 2009 named.loopback
drwxrwx---. 2 named named 6 Jan 29 2014 slaves
-rw-r-----. 1 root named 410 May 6 03:35 westos.com.inter
-rw-r-----. 1 root named 204 May 6 03:53 westos.com.ptr
-rw-r-----. 1 root named 415 May 5 23:52 westos.com.zone
[root@dns-server named]# systemctl restart named
[root@dns-server named]# vim westos.com.zone
客户端
增加
[root@localhost ~]# nsupdate
> server 172.25.254.244
> update add hello.westos.com 86400 A 172.25.254.222
> send 【ctrl+d】
[root@localhost ~]# dig hello.westos.com
删除
[root@localhost ~]# nsupdate
> server 172.25.254.244
> update delete hello.westos.com 86400 A 172.25.254.222
> send 【ctrl+d】
五 加密上传 dnskey update
服务端
1
[root@dns-server ~]# dnssec-keygen -a HMAC-MD5 -b 32 -n HOST westoskey ##制作钥匙
Kwestoskey.+157+59437
[root@dns-server ~]# ls
anaconda-ks.cfg Downloads Music Templates
Desktop Kwestoskey.+157+18814.key Pictures Videos
Documents Kwestoskey.+157+18814.private Public
2
[root@dns-server ~]# cp -p /etc/rndc.key /etc/westos.key
[root@dns-server ~]# vim /etc/westos.key ##配置钥匙文件
[root@dns-server ~]# cat /etc/westos.key
key "westoskey" {
algorithm hmac-md5;
secret " HqglOQ==";
};
[root@dns-server ~]# cat Kwestoskey.+157+18814.key
[root@dns-server ~]# cat Kwestoskey.+157+18814.private
3
[root@dns-server ~]# vim /etc/named.conf ##配置DNS
42 include "/etc/westos.key";
[root@dns-server ~]# vim /etc/named.rfc1912.zones
zone"westos.com" IN {
type master;
file "westos.com.zone";
allow-update { key westoskey; };
};
[root@dns-server ~]# systemctl restart named
4
[root@dns-server ~]# scp Kwestoskey.+157+18814.* root@172.25.254.144:/mnt/ ##下放钥匙
客户端
[root@localhost ~]# cd /mnt/
[root@localhost mnt]# ls
Kwestoskey.+157+18814.key Kwestoskey.+157+18814.private
[root@localhost mnt]# nsupdate -k Kwestoskey.+157+18814.private
##用钥匙上传
10-May-2017 11:32:55.412 the key 'westoskey' is too short to be secure
> server 172.25.254.244
> update add hello.westos.com 86400 A 172.25.254.111
> send
> [root@localhost mnt]dig hello.westos.com
六 动态
服务端
1
[root@dns-server ~]# yum install dhcp -y ##安装dhcp
2
[root@dns-server ~]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
cp: overwrite ‘/etc/dhcp/dhcpd.conf’? y
[root@dns-server ~]# vim /etc/dhcp/dhcpd.conf ##配置dhcp文件
7 option domain-name "westos.com";
8 option domain-name-servers 172.25.254.244
14 ddns-update-style interim;
30 subnet 172.25.254.0 netmask 255.255.255.0 {
31 range 172.25.254.50 172.25.254.60;
32 option routers 172.25.254.250;
33 }
34
35 key westoskey {
36 algorithm hmac-md5;
37 secret " HqglOQ==";
38 };
39 zone westos.com. {
40 primary 127.0.0.1;
41 key westoskey;
42 }
客户端
[root@localhost ~]# hostnamectl set-hostname test.westos.com
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
[root@localhost ~]# systemctl restart network
[root@test ~]# icconfig
[root@test ~]# dig test.westos.com