Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Configuring WEB SERVER and BIND 9 in a chroot jail on Debian 7
- Sample scenario notes to help you ready with this howto:
- this server will use hade.biz.tm as domain , a subdomain from biz.tm. 3600 IN A 69.197.18.174.
- biz.tm is a public domain at afraid.org
- hade.biz.tm and www.hade.biz.tm is already setup and ready to use with public ip 110.136.159.200
- Local ip 192.168.1.100
- gateway 192.168.1.1
- hostname : hade
- domain : biz.tm
- authoritative nameservers for hade.biz.tm zone is
- ns.hade.biz.tm itself
- ns1.afraid.org. 50.23.197.95
- ns2.afraid.org. 208.43.71.243
- ns3.afraid.org. 72.20.15.61
- ns4.afraid.org. 70.39.97.253
- apt-get -y install bind9 dnsutils
- /etc/init.d/bind9 stop
- mkdir -p /var/chroot/bind9/{etc,dev,var/cache/bind,var/run/bind/run}
- chown -R bind:bind /var/chroot/bind9/var/*
- mknod /var/chroot/bind9/dev/null c 1 3
- mknod /var/chroot/bind9/dev/random c 1 8
- chmod 666 /var/chroot/bind9/dev/{null,random}
- mv /etc/bind /var/chroot/bind9/etc
- ln -s /var/chroot/bind9/etc/bind /etc/bind
- chown -R bind:bind /etc/bind/*
- echo "\$AddUnixListenSocket /var/chroot/bind9/dev/log" >> /etc/rsyslog.d/bind-chroot.conf
- nano /etc/default/bind9
- edit bind9 to use the chroot (file /etc/default/bind9):
- from OPTIONS="-u bind" to OPTIONS="-u bind -t /var/chroot/bind9"
- We will edit
- * /etc/bind/named.conf.local
- * /etc/bind/named.conf.options
- * /etc/resolv.conf
- and create 2 files.
- * /etc/bind/db.hade.biz.tm
- * /etc/bind/1.168.192.in-addr.arpa.rev
- First step.
- nano /etc/bind/named.conf.local
- zone "hade.biz.tm" {
- type master;
- file "/etc/bind/db.hade.biz.tm";
- allow-transfer {
- 110.136.159.200; # ns.hade.biz.tm
- 50.23.197.95; # ns1.afraid.org
- 208.43.71.243; # ns2.afraid.org
- 72.20.15.61; # ns3.afraid.org
- 70.39.97.253; # ns4.afraid.org
- };
- notify no;
- };
- zone "1.168.192.in-addr.arpa" {
- type master;
- file "/etc/bind/1.168.192.in-addr.arpa.rev";
- };
- // Consider adding the 1918 zones here, if they are not
- // used in your organization
- include "/etc/bind/zones.rfc1918";
- Save file. Exit.
- Let’s add the DNS servers from your ISP to make make our server accessable from internet. and dont forget to forwarding port 80,22 (just port you need) from modem or router.
- In my case, I’m using telkom.net.id and google DNS servers. You can place the primary and secondary DNS servers here separated by semicolons.
- nano /etc/bind/named.conf.options
- options {
- directory "/var/cache/bind";
- // If there is a firewall between you and nameservers you want
- // to talk to, you may need to fix the firewall to allow multiple
- // ports to talk. See http://www.kb.cert.org/vuls/id/800113
- // If your ISP provided one or more IP addresses for stable
- // nameservers, you probably want to use them as forwarders.
- // Uncomment the following block, and insert the addresses replacing
- // the all-0's placeholder.
- forwarders {
- 8.8.8.8; 8.8.4.4; 203.130.208.18; 203.130.193.74;
- };
- //========================================================================
- // If BIND logs error messages about the root key being expired,
- // you will need to update your keys. See https://www.isc.org/bind-keys
- //========================================================================
- dnssec-validation auto;
- // Listen on local interfaces only(IPV4)
- listen-on { 127.0.0.1; };
- // Do not make public version of BIND
- version none;
- auth-nxdomain no; # conform to RFC1035
- listen-on-v6 { none; };
- };
- Save file. Exit.
- Now, let’s modify the resolv.conf file found in /etc and place the IP address of our DNS server which is set to 192.168.1.1 ( main Gateway ) and add 127.0.0.1 for cache
- cat > /etc/resolv.conf << "EOF"
- # Begin /etc/resolv.conf
- domain hade.biz.tm
- nameserver 127.0.0.1
- # End /etc/resolv.conf
- EOF
- nano /etc/network/interfaces
- # This file describes the network interfaces available on your system
- # and how to activate them. For more information, see interfaces(5).
- # The loopback network interface
- auto lo
- iface lo inet loopback
- # The primary network interface
- allow-hotplug eth0
- iface eth0 inet static
- address 192.168.1.100
- netmask 255.255.255.0
- network 192.168.1.0
- broadcast 192.168.1.255
- gateway 192.168.1.1
- # dns-* options are implemented by the resolvconf package, if installed
- dns-nameservers 127.0.0.1
- dns-search hade.biz.tm
- nano /etc/bind/db.hade.biz.tm
- ; hade.biz.tm
- $TTL 3600
- hade.biz.tm. IN SOA hade.biz.tm. [email protected]. (
- 2012042801 ; Serial
- 3H ; refresh after 3 hours
- 1H ; retry after 1 hour
- 1W ; expire after 1 week
- 1D) ; minimum TTL of 1 day
- ; Name Server
- IN NS ns.hade.biz.tm. ; ns.hade.biz.tm
- IN NS ns1.afraid.org. ; ns1.afraid.org
- IN NS ns2.afraid.org. ; ns2.afraid.org
- IN NS ns3.afraid.org. ; ns1.afraid.org
- IN NS ns4.afraid.org. ; ns2.afraid.org
- hade.biz.tm. IN A 110.136.159.200
- www IN CNAME 110.136.159.200
- ns IN NS 110.136.159.200
- ns1 IN NS 50.23.197.95
- ns2 IN NS 208.43.71.243
- ns3 IN NS 72.20.15.61
- ns4 IN NS 70.39.97.253
- ; EOF
- nano /etc/bind/1.168.192.in-addr.arpa.rev
- $TTL 1h
- @ IN SOA hade.biz.tm. [email protected]. (
- 2012042801 ; Serial
- 3H ; refresh after 3 hours
- 1H ; retry after 1 hour
- 1W ; expire after 1 week
- 1D) ; minimum TTL of 1 day
- IN NS ns.hade.biz.tm.
- IN PTR hade.biz.tm.
- IN A www.hade.biz.tm.
- ; EOF
- restart rsyslogd and start bind9.
- /etc/init.d/rsyslog restart ; /etc/init.d/bind9 start
- Finally, let’s test our new domain and DNS entries.
- root@hade:~# dig hade.biz.tm
- ; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> hade.biz.tm
- ;; global options: +cmd
- ;; Got answer:
- ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 42219
- ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 5, ADDITIONAL: 0
- ;; QUESTION SECTION:
- ;hade.biz.tm. IN A
- ;; ANSWER SECTION:
- hade.biz.tm. 3600 IN A 192.168.1.100
- ;; AUTHORITY SECTION:
- hade.biz.tm. 3600 IN NS ns1.afraid.org.
- hade.biz.tm. 3600 IN NS ns.hade.biz.tm.
- hade.biz.tm. 3600 IN NS ns2.afraid.org.
- hade.biz.tm. 3600 IN NS ns4.afraid.org.
- hade.biz.tm. 3600 IN NS ns3.afraid.org.
- ;; Query time: 9 msec
- ;; SERVER: 127.0.0.1#53(127.0.0.1)
- ;; WHEN: Mon Jul 1 10:17:32 2013
- ;; MSG SIZE rcvd: 144
- http://www.dnswatch.info
- MORE INFO http://wiki.debian.org/Bind9
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement