Cara Setting resolv.conf Permanen di Ubuntu

File */etc/resolv.conf* adalah file yang berisi DNS resolver atau IP address dari DNS server (nameserver) yang berfungsi untuk mentranslasi dari nama domain menjadi IP address.

Di Ubuntu 20.04, nameserver default yang digunakan yaitu 127.0.0.53.

[INPUT]

1 2 3 4 5 6 7 cat /etc/resolv.conf   # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) #     DO NOT EDIT THIS FILE BY HAND — YOUR CHANGES WILL BE OVERWRITTEN # 127.0.0.53 is the systemd-resolved stub resolver. # run “systemd-resolve –status” to see details about the actual nameservers. nameserver 127.0.0.53

Misalnya ingin menggunakan DNS server milik Cloudflare (1.1.1.1) dan Google (8.8.8.8) sebagai primary dan secondary nameserver, pasang IP address tersebut di baris pertama dan kedua.

[INPUT]

1 sudo nano /etc/resolv.conf

Update menjadi seperti di bawah ini

[INPUT]

1 2 3 4 5 6 7 8 # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) #     DO NOT EDIT THIS FILE BY HAND — YOUR CHANGES WILL BE OVERWRITTEN # 127.0.0.53 is the systemd-resolved stub resolver. # run “systemd-resolve –status” to see details about the actual nameservers.   nameserver 1.1.1.1 nameserver 8.8.8.8 nameserver 127.0.0.53

*Masalah*

Masalah yang terjadi adalah file resolv.conf akan berubah kembali seperti semula setelah komputer direstart, yaitu hanya berisi IP address 127.0.0.53. Di file resolv.conf pun terdapat komentar *DO NOT EDIT THIS FILE BY HAND — YOUR CHANGES WILL BE OVERWRITTEN*, yang artinya jangan mengubah file ini secara manual karena akan ditimpa kembali konfigurasinya.

*Solusi*

Untuk mengatasi masalah di atas adalah dengan cara menggunakan *resolvconf service*.

Install paket resolvconf.

[INPUT]

1 sudo apt install resolvconf

Kemudian aktifkan dan jalankan resolvconf service.

[INPUT]

1 2 3 sudo systemctl enable resolvconf sudo systemctl start resolvconf sudo systemctl status resolvconf

Hasilnya seperti di bawah ini.

[INPUT]

1 2 3 4 5 6 “— resolvconf.service – Nameserver information manager      Loaded: loaded (/lib/systemd/system/resolvconf.service; enabled; vendor preset: enabled)      Active: active (exited) since Sun 2020-07-26 18:08:17 WIB; 14h ago        Docs: man:resolvconf(8)     Process: 329 ExecStart=/sbin/resolvconf –enable-updates (code=exited, status=/SUCCESS)    Main PID: 329 (code=exited, status=/SUCCESS)

Kemudian masukkan IP address nameserver di dalam file *head* konfigurasi resolvconf.

[INPUT]

1 sudo nano /etc/resolvconf/resolv.conf.d/head

Masukkan nameserver di bawah komentar.

[INPUT]

1 2 nameserver 1.1.1.1 nameserver 8.8.8.8

Lalu jalankan update resolv.conf.

[INPUT]

1 2 sudo resolvconf –enable-updates sudo resolvconf -u

Verifikasi dengan menampilkan isi file resolv.conf.

[INPUT]

1 2 3 4 5 6 7 8 9 10 cat /etc/resolv.conf   # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) #     DO NOT EDIT THIS FILE BY HAND — YOUR CHANGES WILL BE OVERWRITTEN # 127.0.0.53 is the systemd-resolved stub resolver. # run “systemd-resolve –status” to see details about the actual nameservers.   nameserver 1.1.1.1 nameserver 8.8.8.8 nameserver 127.0.0.53

Jika ingin mengubah atau menambahkan IP address nameserver lain, ubah kembali file *head*, dan jalankan update resolvconf.

[INPUT]

1 sudo resolvconf -u

Selamat mencoba 🙂

Leave a Reply

Your email address will not be published.