dns-bind/service-install.sh

raw link view readme
1 yum install firewalld -y
2 systemctl start firewalld
3 systemctl enable firewalld
4 firewall-cmd --permanent --zone=public --add-interface=eth0
5 firewall-cmd --permanent --add-service=dns --zone=public
6 firewall-cmd --reload
7
8 yum install -y bind bind-utils
9
10 sed -i.original "s/listen-on port 53 { 127.0.0.1; };/listen-on port 53 { 127.0.0.1; 10.18.0.5; };/" /etc/named.conf
11 sed -i "s/allow-query { localhost; };/allow-query { localhost; 10.18.0.0\/16; };\n forwarders {\n 168.63.129.16;\n 8.8.8.8;\n 8.8.4.4;\n };/" /etc/named.conf
12 sed -i "s/listen-on-v6 port.*/listen-on-v6 port 53 { none; };/" /etc/named.conf
13 sed -i "/dnssec/d" /etc/named.conf
14
15 sed -i "s/PEERDNS=.*/PEERDNS=no/" /etc/sysconfig/network-scripts/ifcfg-eth0
16 sed -i "s/nameserver.*/nameserver 127.0.0.1/" /etc/resolv.conf
17
18 cat >> /etc/named.conf << EOF
19 zone "lab.example.net." IN {
20 type master;
21 file "db.lab.example.net";
22 allow-transfer { none; };
23 };
24 EOF
25
26 cat > /var/named/db.lab.example.net <<\EOF
27 $TTL 3H
28 $ORIGIN lab.example.net.
29 @ IN SOA alpha.lab.example.net root.lab.example.net (0
30 1D
31 1H
32 1W
33 3H)
34 lab.example.net. NS alpha.lab.example.net.
35 alpha A 10.18.0.5
36 beta A 10.18.0.6
37 EOF
38
39 systemctl restart named
40 systemctl enable named
41