To run an IPv6 DNS server (answers IPv6 resolution requests using IPv6) inside a Docker container running CentOS Linux release 7.9.2009 (Core), you can use the following steps:
- Install the required packages:
docker run -it centos:7.9.2009
yum install -y bind bind-utils
- Configure the DNS server:
Create a file named /etc/named.conf with the following content:
options {
listen-on port 53 { 127.0.0.1; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
};
zone "." IN {
type hint;
file "/etc/named.root";
};
zone "localdomain" IN {
type master;
file "/etc/named/localdomain";
};
Create a file named /etc/named/localdomain with the following content:
$TTL 604800
@ IN SOA localhost. root.localhost. (
1 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS localhost.
@ IN A 127.0.0.1
@ IN AAAA ::1
Create a file named /etc/named.root with the content of the root zone file.
- Start the DNS server:
named-checkconf /etc/named.conf
named-checkzone localdomain /etc/named/localdomain
service named start
- Verify the DNS server is running:
docker exec -it <container_id> nslookup localhost
The output should show the IPv6 address of the container:
Server: ::1
Address: ::1#53
Name: localhost.localdomain
Address: fe80::100:27ff:fe64:2125
- To check the DNS server's status, run the following command outside the Docker container:
docker logs <container_id>
The output should include lines like:
named[13214]: starting BIND 9.11.2-P4+dfsg-1+deb10u2
named[13214]: overall: 0 requests handled, 0 requests rejected, 0 dropped
References:
- BIND 9 DNS Server
- CentOS Docker Image
- Docker: BIND 9 DNS Server
- Docker: Running a DNS Server in a Container
Summary:
- Install the required packages
- Configure the DNS server in
/etc/named.conf - Create zone files for the local domain
- Start the DNS server with
service named start - Verify the DNS server is running and checking its status