libao 2019-10-12
正向解析脚本
#!/bin/bash yum install bind -y //安装解析工具包 //修改主配置文件 sed -i '13s/127.0.0.1/192.168.17.156/' /etc/named.conf //把解析主配置文件第13行的IP地址换成192.168.17.156 sed -i '21s/localhost/any/' /etc/named.conf //把主配置文件的21行localhost换成any //添加内容到区域配置文件 sed -i '24azone "cwq.com" IN {\n type master;\n file "cwq.com.zone";\n allow-update { none; };\n };' /etc/named.rfc1912.zones //区域配置文件24行后面加入域名 cd /var/named cp -p named.localhost cwq.com.zone //复制模板到我们自己设置的数据区域配置文件 //配置数据区域配置文件 sed -i '2s/@/cwq.com/2' cwq.com.zone sed -i '2s/rname.invalid./admin.cwq.com/' cwq.com.zone sed -i '8s/@/cwq.com./' cwq.com.zone sed -i '9s/127.0.0.1/192.168.17.156/' cwq.com.zone sed -i '10aIN MX 10 mail.cwq.com.\nwww IN A 192.168.100.99\nftp IN A 192.168.100.88' cwq.com.zone systemctl stop firewalld.service //关闭防火墙 setenforce 0 //关闭增强功能 systemctl start named //开启解析服务 echo "nameserver 192.168.17.156" >/etc/resolv.conf //把你自己的Ip地址加入解析配置文件
最后只要输入hosts www.cwq.com就能解析出地址192.168.17.156