Tuesday, June 9, 2015

6-9-2015 BIND, DNS (status : done)

I need to install bind at home and AWS. Home first because my computers was way more powerful than then micro computers on AWS. Need two things: one as a cache server and one as a master. Then the other servers in the network will cache only from the master. Eventually, set this up in salt. Just want it work first, and then do stuff in salt after that. Salt shouldn't maintain the the main DNS, except maybe parts of it.

Links:


  • https://help.ubuntu.com/12.04/serverguide/dns-configuration.html
  • https://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-bind-zone.html
Steps:
  • apt-get install bind9
  • route -n # This gives you the ip address of your router at home with is also the DNS. For AWS I will have to use the AWS servers. 
  • In the forwards section of       /etc/bind/named.conf.options , I added my router at home and google's DNS for fun.
    forwarders {
         8.8.8.8;    
         192.168.1.1;
               };
    
    
  • Test that it works locally: nslookup google.com 192.168.1.209 
    • restart bind: service network-manager restart
    • Change the ip address to your local computer.
  • Change the resolv.conf to point to your own computer at the file: /etc/resolvconf/resolv.conf.d/head
    • search mylocaldomain
      nameserver 127.0.0.1
      nameserver 8.8.8.8
      # blank space
      
  • Restart network: sudo service network-manager restart
    • /etc/resolv.conf should have your changes. Check it. 
  • Now setup the DNS for your own network. 
    • Edit the file /etc/bind/named.conf.local and add:
      • zone "mylocaldomain" {
         type master;
                file "/etc/bind/db.mylocaldomain";
        };
        
    • Edit the file and put in your own hosts at /etc/bind/db.mylocaldomain. This worked when I tested it. I am sure technically I could make the below better. 
      • ;
        
        ;
        ; BIND data file for example.com
        ;
        $TTL    604800
        @       IN      SOA     ns1.mylocaldomain. root.mylocaldomain. (
                                      2         ; Serial
                                 604800         ; Refresh
                                  86400         ; Retry
                                2419200         ; Expire
                                 604800 )       ; Negative Cache TTL
        @       IN      NS      ns1.mylocaldomain.
        @       IN      NS      ns2.mylocaldomain.
        @       IN      NS      ns3.mylocaldomain.
        
        @       IN      A       192.168.1.158
        @       IN      AAAA    ::1
        
        ns1     IN      A       192.168.1.158
        ns2      IN      A       192.168.1.209
        ns3      IN      A       192.168.1.50
        
        
        mark  IN CNAME ns1
        mark2 IN CNAME ns2
        mark3 IN CNAME ns3
        
        salt IN CNAME ns2
        
        
        ns3   IN A 192.168.1.30
        mark4 IN CNAME ns3
        ns4   IN A 192.168.1.179
        mark5 IN CNAME ns4
        
        
        
        
      • Restart bind: service network-manager restart
      • Do an "nslookup mark", and mark2, and mark3 to see if they come up. nslookup other domains like google.com to see if them come up. 

No comments:

Post a Comment