DNS (IV)
Note: There is a more in-depth documentation in the DNS server
guide. Keep it handy.
Network map
localnet +-------------------------------------+ vmnet +--------------------+
------------|eth0 gateway eth1|---------|eth0 vm |
|192.168.1.44 192.168.56.101| |192.168.56.102 |
+-------------------------------------+ +--------------------+
DNS
_$: apt-get update
_$: apt-get install bind9
/etc/bind/db.example.com:
-------------------------
; example.com zone
$TTL 604800
@ IN SOA gateway.example.com. info.example.com. (
2013082601 ; Serial
7200 ; Refresh
120 ; Retry
2419200 ; Expire
604800) ; Default TTL
;
@ IN NS gateway.example.com.
@ IN MX 10 mail1.example.com.
@ IN MX 20 mail2.example.com.
@ IN TXT "v=spf1 +a +mx -all"
example.com._domainkey IN TXT "v=DKIM1; g=*; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDHPWNGNc8lKhfeywkE6gZg77oE6dIFm8EuqZ5VLyX9dbOi+zLxy7442o5bEEpXl+l1HPWfwzqjXpkbOMtK3ac5xxopgJ2U/nUpFffhM0CtDN2h3prDIfjyuAXSENHRRz4UQv4qdKyD902yQhT/nYAfuCvw9Sn8H5LCjYRSNjRVsQIDAQAB" ; ----- DKIM example.com for example.com
gateway IN A 192.168.56.101
devops1 IN A 192.168.56.102
devops2 IN A 192.168.56.103
mail1 IN A 192.168.56.104
mail2 IN A 192.168.56.105
web1 IN A 192.168.56.106
web2 IN A 192.168.56.107
/etc/bind/db.192.168.56:
------------------------
; 56.168.192 zone
; admin
$TTL 604800
@ IN SOA gateway.example.com. info.example.com. (
2013082601 ; Serial
7200 ; Refresh
120 ; Retry
2419200 ; Expire
604800) ; Default TTL
;
@ IN NS gateway.example.com.
101 IN PTR gateway.example.com.
102 IN PTR devops1.example.com.
103 IN PTR devops2.example.com.
104 IN PTR mail1.example.com.
105 IN PTR mail2.example.com.
106 IN PTR web1.example.com.
107 IN PTR web2.example.com.
_$: service bind9 restart
Configuration of the other hosts
/etc/network/interfaces:
------------------------
...
auto eth0
iface eth0 inet static
address 192.168.254.196
network 192.168.254.0
netmask 255.255.255.0
dns-nameservers 192.168.254.101
We must restart the network for the changes to take effect:
_$: /etc/init.d/networking restart # Use /etc/init.d instead of service; the latter is deprecated.
_$: ifdown -a && ifup -a # Alternatively to the previuos command.
_$: nohup sh -c "ifdown eth0 && ifup eth0" # When we are remotely connected to a host and we don't want to lose the connection.
Check
_$: ping gateway.example.com
_$: ping www.google.com