给DNS设置KEY

1.建立 keyfile
[root@server mnt]# cd /mnt/
[root@server mnt]#dnssec-keygen -a HMAC-MD5 -b 256 -n HOST westoskey ##设置加密, HMAC-MD5为加密方式,256 为加密字符大小,得在server机上敲键盘或者晃动鼠标
[root@server mnt]# ls
Kwestoskey.+157+44239.key  Kwestoskey.+157+44239.private  westos.com.zone

2.建立 key configfile
[root@server mnt]# cp -p /etc/rndc.key /etc/westos.key   ##复制加密模板

[root@server mnt]# cat /mnt/Kwestoskey.+157+44239.key 
westoskey. IN KEY 512 3 157 Mfc12pxQDEFKoZfZwydWJBg1BMipCiWf1GN+VSeyNPY=
[root@server mnt]# vim /etc/westos.key
key "westoskey" {     ##注意修改
        algorithm hmac-md5;
        secret "Mfc12pxQDEFKoZfZwydWJBg1BMipCiWf1GN+VSeyNPY=";
};

3.config dns
[root@server mnt]# vim /etc/named.conf 
 43 include "/etc/westos.key";    ##必须在43行加
[root@server mnt]# vim /etc/named.rfc1912.zones 
zone "westos.com" IN {
        type master;
        file "westos.com.zone";
        allow-update { key westoskey; };   ##修改本行,设置加密方式更新
};

[root@server mnt]# systemctl restart named
4. 检测
[root@server mnt]# scp /mnt/Kwestoskey.+157+44239.* root@172.25.254.10:/mnt/
root@172.25.254.10's password: 
Kwestoskey.+157+44239.key                     100%   73     0.1KB/s   00:00    
Kwestoskey.+157+44239.private                 100%  185     0.2KB/s   00:00   
在client
[root@client ~]# cd /mnt/
[root@client mnt]# ls
Kwestoskey.+157+44239.key  Kwestoskey.+157+44239.private
[root@client mnt]# nsupdate -k Kwestoskey.+157+44239.private 
> server 172.25.254.20
> update add hello.westos.com 86400 A 172.25.254.111
> send
> quit
[root@client mnt]# dig hello.westos.com

; <<>> DiG 9.9.4-RedHat-9.9.4-14.el7 <<>> hello.westos.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 42215
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;hello.westos.com.      IN  A

;; ANSWER SECTION:
hello.westos.com.   86400   IN  A   172.25.254.112

;; AUTHORITY SECTION:
westos.com.     86400   IN  NS  dns.westos.com.

;; ADDITIONAL SECTION:
dns.westos.com.     86400   IN  A   172.25.254.20

;; Query time: 0 msec
;; SERVER: 172.25.254.20#53(172.25.254.20)
;; WHEN: Tue May 09 06:33:43 EDT 2017
;; MSG SIZE  rcvd: 95

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值