Nameserving the Virtual Network

  1. apprentice@xenserver:~$ sudo apt-get install bind10

  2. In /etc/bind/named.conf.options, put the following near the end:

    listen-on { 10.0.17.253 };
    	  

    This command does just that (don't run it more than once):

    apprentice@xenserver:~$ sudo sed -i.bak 's/^};$/\tlisten-on { 10.0.17.253;  };\n};/g' /etc/bind/named.conf.options

    Then include the files for xen network ranges in /etc/bind/named.conf.local:

    <snip>
    include "/etc/bind/zone.xennet";
    include "/etc/bind/zone.10.0.17";
    	  

    Create /etc/bind/zone.xennet:

    zone "xennet" {
            type master;
            file "/etc/bind/db.xennet";
    };
    	  

    and /etc/bin/zone.10.0.17:

    zone "17.0.10.in-addr.arpa"  { type master; file "/etc/bind/db.10.0.17"; };
    	  

    Create the zone 'databases' /etc/bind/db.xennet:

    $ORIGIN xennet.
    $TTL 86400
    @    IN    SOA  ns1.xennet.     apprentice.example.com. (
         8 ; serial                     
         21600      ; refresh after 6 hours                     
         3600       ; retry after 1 hour                     
         604800     ; expire after 1 week                     
         86400 )    ; minimum TTL of 1 day  
    
            IN      NS        ns1
            IN      MX 10     mail
    
    ns1     IN      A         10.0.17.253
    mail    IN      A         10.0.17.253
    
    
    dom0            IN      A       10.0.17.253
    
    vhost1          IN      A       10.0.17.1
    vhost2          IN      A       10.0.17.2
    vhost3          IN      A       10.0.17.3
    vhost4          IN      A       10.0.17.4
    vhost5          IN      A       10.0.17.5
    vhost6          IN      A       10.0.17.6
    vhost7          IN      A       10.0.17.7
    vhost8          IN      A       10.0.17.8
    vhost9          IN      A       10.0.17.9
    vhost10         IN      A       10.0.17.10
    
    puppet          IN      A       vhost1
    	  

    and /etc/bind/db.10.0.17:

    $ORIGIN 17.0.10.in-addr.arpa. 
    $TTL 86400 
    @    IN    SOA  ns1     apprentice.example.com. (
               2 ; serial                     
               21600      ; refresh after 6 hours                     
               3600       ; retry after 1 hour                     
               604800     ; expire after 1 week                     
               86400 )    ; minimum TTL of 1 day        
    
    $GENERATE 1-255 $ PTR vhost$.xennet.
    	  

  3. apprentice@xenserver:~$ sudo /etc/init.d/bind9 restart

  4. To make them use the new nameserver, on each client, put in /etc/resolv.conf

    nameserver 10.0.17.253
    search xennet
    	  

    :

  5. root@vhost1:~$ apt-get install -y dnsutils
    root@vhost1:~$ host vhost2
    vhost2.xennet has address 10.0.17.2
    root@vhost1:~$ ping www.google.com
    PING www.google.com (173.194.66.105) 56(84) bytes of data.
    64 bytes from we-in-f105.1e100.net (173.194.66.105): icmp_req=1 ttl=49 time=8.43 ms
    64 bytes from we-in-f105.1e100.net (173.194.66.105): icmp_req=2 ttl=49 time=8.58 ms
    ^C
    --- www.google.com ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1002ms
    rtt min/avg/max/mdev = 8.439/8.513/8.588/0.118 ms