Posts tagged ‘dns’

DNS query to find mail servers

To find which servers handle mail for a particular domain use dig:

# dig google.com MX
;; QUESTION SECTION:
;google.com.			IN	MX
 
;; ANSWER SECTION:
google.com.		561	IN	MX	100 google.com.s9a1.psmtp.com.
google.com.		561	IN	MX	100 google.com.s9a2.psmtp.com.
google.com.		561	IN	MX	10 smtp1.google.com.
google.com.		561	IN	MX	10 smtp2.google.com.
google.com.		561	IN	MX	10 smtp3.google.com.
google.com.		561	IN	MX	10 smtp4.google.com.

Setting up an IPv6 Bind DNS Server on Linux

If the DNS server isn’t installed on your Linux box, install it with the following command:

yum groupinstall "DNS Name Server"

We need to configure two things. First we need to specify the domains we’re going to resolve in named.conf. We will resolve the labplan.southpark domain.
Our DNS server will support both direct (name->ip) and reverse (ip->name) resolution.

According to APNIC the use of ip6.int is deprecated in favor of ip6.arpa for
reverse resolutions. However, since many programs still use it, we’re going to define
the ip6.int version as well. We need to add the following lines to named.conf:

zone "labplan.southpark" IN {
type master;
file "labplan.southpark.zone";
};
//deprecated
zone "0.0.0.0.0.0.0.0.0.0.0.0.1.c.e.f.ip6.int" {
type master;
file"reverse-fec1_64i.IP6.INT";
};
zone "0.0.0.0.0.0.0.0.0.0.0.0.1.c.e.f.ip6.arpa" {
type master;
file "reverse-fec1_64.IP6.ARPA";
};

Next we have to fill the zone records. The information for direct resolutions is stored on labplan.southpark.zone:

$TTL    86400
@               IN SOA  @       root (
		42              ; serial (d. adams)
		3H              ; refresh
		15M             ; retry
		1W              ; expiry
		1D )            ; minimum
 
          IN NS           ns6.labplan.southpark.
 
 
ns6		 IN      AAAA    fec0::20c:29ff:fe8f:8f16
customer	 IN      AAAA    fec0::20c:29ff:feff:4b37
npserver	 IN      AAAA    fec0::20c:29ff:fe4a:fae0
an		 IN      AAAA    fec0::20c:29ff:feb4:bee2

The PTR records used for reverse resolution are stored on reverse-fec1_64i.IP6.INT (deprecated ip6.int) and reverse-fec1_64.IP6.ARPA (recommended ip6.arpa). This is the ip6.arpa zone (to edit an ip6.int zone just replace arpa with int):

$TTL 3d ; Default TTL 
@       IN SOA 0.0.0.0.0.0.0.0.0.0.0.0.0.c.e.f.ip6.arpa. root (
                200906170       ; Serial number (YYYYMMdd)
                24h             ; Refresh time
                30m             ; Retry time
                2d              ; Expire time
                3d              ; Default TTL 
)
                                IN     NS     ns6.labplan.southpark.
7.3.b.4.f.f.e.f.f.f.9.2.c.0.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.c.e.f.ip6.arpa.   IN PTR costumer.labplan.southpark.
0.e.a.f.a.4.e.f.f.f.9.2.c.0.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.c.e.f.ip6.arpa.   IN PTR npserver.labplan.southpark.
2.e.e.b.4.b.e.f.f.f.9.2.c.0.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.c.e.f.ip6.arpa.     IN PTR an.labplan.southpark.
6.1.f.8.f.8.e.f.f.f.9.2.c.0.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.c.e.f.ip6.arpa.     IN PTR gw.labplan.southpark.
6.1.f.8.f.8.e.f.f.f.9.2.c.0.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.c.e.f.ip6.arpa.     IN PTR ns6.labplan.southpark.

From this moment on everything should work fine. We can check the name resolution with dig:

# dig @::1 -t AAAA npserver.labplan.southpark
;; QUESTION SECTION:
;npserver.labplan.southpark.    IN      AAAA
 
;; ANSWER SECTION:
npserver.labplan.southpark. 86400 IN    AAAA    fec0::20c:29ff:fe4a:fae0

To check reverse resolution use dig’s -x flag:

#dig @::1 -x fec0::20c:29ff:fe4a:fae0
;; QUESTION SECTION:
;0.e.a.f.a.4.e.f.f.f.9.2.c.0.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.c.e.f.ip6.arpa.INPTR
 
;; ANSWER SECTION:
0.e.a.f.a.4.e.f.f.f.9.2.c.0.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.c.e.f.ip6.arpa. 259200  IN  PTR  npserver.labplan.southpark.

DynDNS or how to host Internet services with a dynamic IP address

Sometimes you need to set up some service at home (e.g., a Web Server or a Mail Server). In my case, my IP address is dynamic and likely to change. You can always pay for a static IP address but there other valid solutions. For instance you can use a dynamic DNS service such as DynDNS. Service setup is easy; you have to follow these steps:

  • Register an account at dyndns.org and configure a hostname (e.g., myhost.dyndns.org).
  • Download the DynDNS client and configure it with your registered hostname. There are versions for Windows, Linux and Mac.

Now every time your IP address changes, the DynDNS client updates the corresponding DNS records and your services are accessible again. This mode of operation has a drawback related to DNS catching. All records in DNS have a Time to Live (TTL) value. This value dictates how long a record should be stored locally before a new copy of the record must be retrieved from DNS. Sometimes the information in DNS changes, but the old information is still stored in the DNS caches. When the cached record is different from the newest information in DNS, it is called a caching error.
DynDNS allows you to set the TTL value to 60s or 4h. If your IP is dynamic you should use the 60s value.
picture12 DynDNS or how to host Internet services with a dynamic IP address
In summary, if availability and grade of service are key aspects for you, pay for a static IP. Otherwise you can always use services like DynDNS.