Summary
In this challenge, you learned how to configure both static and dynamic hostname resolution on a Linux system. You practiced setting up the /etc/hosts
file for static hostname resolution and configuring a DNS server for dynamic hostname resolution. By the end of this challenge, you should have a better understanding of how to manage basic networking and hostname resolution on a Linux system.
If you need to initialize the challenge environment, you can use the following setup.sh
script:
#!/bin/bash
## Set the hostname
hostnamectl set-hostname myhost.example.com
## Create the /etc/hosts file
cat << EOF | sudo tee /etc/hosts
127.0.0.1 localhost
192.168.1.100 myhost.example.com
EOF
## Install and configure the DNS server (e.g., BIND)
sudo dnf install -y bind bind-utils
sudo systemctl start named
sudo systemctl enable named
## Configure the DNS server
sudo tee /etc/named.conf << EOF
options {
listen-on port 53 { 127.0.0.1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
allow-query { localhost; };
};
zone "example.com" IN {
type master;
file "example.com.zone";
allow-update { none; };
};
EOF
sudo tee /var/named/example.com.zone << EOF
$TTL 86400
@ IN SOA myhost.example.com. root.example.com. (
2023040601 ; serial
3600 ; refresh (1 hour)
1800 ; retry (30 minutes)
604800 ; expire (1 week)
86400 ; minimum (1 day)
)
IN NS myhost.example.com.
myhost IN A 192.168.1.100
EOF
sudo systemctl restart named