🤖 Ai回答: In FreeBSD, DNS (Domain Name System) configuration is typically handled through the `/etc/resolv.conf` file、This file specifies the DNS servers that the system should use to resolve domain names into IP addresses.
Here's how you can configure DNS on FreeBSD:
Steps to Configure DNS in FreeBSD
1、Edit the `/etc/resolv.conf` File:
Open the `/etc/resolv.conf` file using a text editor like `nano` or `vi`、For example:
bash
sudo nano /etc/resolv.conf
2、Add DNS Servers:
Add the DNS server addresses you want to use、For example, if you want to use Google's public DNS servers, you would add:
plaintext
nameserver 8.8.8.8
nameserver 8.8.4.4
Or if you prefer Cloudflare's DNS servers:
plaintext
nameserver 1.1.1.1
nameserver 1.0.0.1
3、Save and Exit:
After adding the necessary entries, save the file and exit the editor.
4、Verify DNS Configuration:
You can verify your DNS settings by checking the contents of `/etc/resolv.conf`:
bash
cat /etc/resolv.conf
Or you can test DNS resolution using tools like `nslookup`, `dig`, or `host`:
bash
nslookup 65.hk
dig 65.hk
host 65.hk
5、Persistent DNS Configuration:
By default, the `/etc/resolv.conf` file may be overwritten by DHCP if your system is configured to use DHCP for network settings、To prevent this, you can mark the file as immutable so it won't be overwritten:
bash
sudo chflags schg /etc/resolv.conf
If you need to modify it later, you can remove the immutable flag with:
bash
sudo chflags noschg /etc/resolv.conf
6、Using NetworkManager or dhclient:
If you're using a tool like `NetworkManager` or `dhclient`, you might want to ensure that these tools aren't overwriting your DNS settings、You can configure the `/etc/dhclient.conf` file to specify custom DNS servers: