您好,登錄后才能下訂單哦!
很有用 )
實驗環境搭建
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
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。