Installasi
install dns mask dengan menggunakan perintah berikut
1
| sudo dnf install dnsmasq
|
Konfigurasi
copy default config dnsmasq dengan perintah berikut
1
| sudo cp /etc/dnsmasq.conf /etc/dnsmasq.conf.origin
|
kosong file konfigurasi dengan perintah
1
| echo '' > /etc/dnsmasq.conf
|
selanjutnya isikan konfigurasi berikut
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| ## prevent packets private ip leaving local network
domain-needed
bogus-priv
## limits your name services exclusively to dnsmasq
no-resolv
## interface configuration
interface=eth0
bind-interfaces
listen-address=127.0.0.1, 172.275.50.1
cache-size=1000
no-poll
## local server
domain=fahmaya.com
server=/fahmaya.com/127.0.0.1
server=/fahmaya.com/172.275.50.1
## upstream dns
server=1.1.1.1
server=8.8.8.8
## Can append below two parameters to log host queries
# log-queries
# log-facility=/var/log/dnsmasq.log
|
Lakukan pengencekan konfigurasi dengan perintah
1
| sudo dnsmasq --no-daemon --log-queries
|
aktivkan service dan auto enable saat proses booting
1
| systemctl enable --now dnsmasq
|
konfigurasi firewall
1
| sudo firewall-cmd --permanent --zone=public --add-service=dns
|
1
| sudo firewall-cmd --permanent --zone=public --add-service=dhcp
|
jika ada zone lainya pada firewalld silahkan tambahkan. setelah itu reload konfigurasi firewalld dengan perintah
Pengujian
Troubleshoot
failed start service on boot
cek status dengan perintah
1
| sudo systemctl status dnsmasq
|
contoh status service seperti contoh berikut
1
2
3
4
5
6
7
8
9
10
11
12
13
| × dnsmasq.service - DNS caching server.
Loaded: loaded (/usr/lib/systemd/system/dnsmasq.service; enabled; preset: disabled)
Active: failed (Result: exit-code) since Wed 2023-12-27 18:10:51 EST; 55s ago
Process: 884 ExecStart=/usr/sbin/dnsmasq (code=exited, status=2)
CPU: 33ms
Dec 27 18:10:51 turing systemd[1]: Starting DNS caching server....
Dec 27 18:10:51 turing dnsmasq[884]: dnsmasq: failed to create listening socket for 172.27.5.101: Cannot assign requested address
Dec 27 18:10:51 turing dnsmasq[884]: failed to create listening socket for 172.27.5.101: Cannot assign requested address
Dec 27 18:10:51 turing dnsmasq[884]: FAILED to start up
Dec 27 18:10:51 turing systemd[1]: dnsmasq.service: Control process exited, code=exited, status=2/INVALIDARGUMENT
Dec 27 18:10:51 turing systemd[1]: dnsmasq.service: Failed with result 'exit-code'.
Dec 27 18:10:51 turing systemd[1]: Failed to start DNS caching server..
|
buka file /usr/lib/systemd/system/dnsmasq.service
dengan perintah
1
| vi /usr/lib/systemd/system/dnsmasq.service
|
jike konfigurasi file seperti di bawah ini
1
2
3
4
5
6
7
8
9
10
11
12
| [Unit]
Description=DNS caching server.
After=network.target
[Service]
ExecStart=/usr/sbin/dnsmasq
Type=forking
PIDFile=/run/dnsmasq.pid
[Install]
WantedBy=multi-user.target
~
|
maka ganti menjadi
1
2
3
4
5
6
7
8
9
10
11
12
13
| [Unit]
Description=DNS caching server.
Wants=network-online.target
After=network.target network-online.target
[Service]
ExecStart=/usr/sbin/dnsmasq
Type=forking
PIDFile=/run/dnsmasq.pid
[Install]
WantedBy=multi-user.target
~
|
selanjutnya restart virtual guest untuk menguji konfigurasi tersebut.
Reference
https://oss.segetech.com/intra/srv/dnsmasq.conf
How to configure DNS caching server with dnsmasq in RHEL - Red Hat Customer Portal
Installing DNS Server on CentOS/RHEL using dnsmasq | Zimbra - Zextras Community
Advanced Dnsmasq Tips and Tricks - Linux.com
systemd - Cause a script to execute after networking has started? - Unix & Linux Stack Exchange
networking - dnsmasq not starting on boot - Raspberry Pi Stack Exchange