![如何禁用 Ubuntu 22.04 中的 DNS 服务器路由?](https://linux22.com/image/1028155/%E5%A6%82%E4%BD%95%E7%A6%81%E7%94%A8%20Ubuntu%2022.04%20%E4%B8%AD%E7%9A%84%20DNS%20%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%B7%AF%E7%94%B1%EF%BC%9F.png)
在Ubuntu 22.04上,可以获取路由表:
root@jammy-test-shengxpa:~# ip route
default via 62.109.210.1 dev eth0 proto dhcp src 62.109.211.31 metric 100
10.240.240.1 via 62.109.210.1 dev eth0 proto dhcp src 62.109.211.31 metric 100
10.240.241.1 via 62.109.210.1 dev eth0 proto dhcp src 62.109.211.31 metric 100
62.109.210.0/23 dev eth0 proto kernel scope link src 62.109.211.31 metric 100
62.109.210.1 dev eth0 proto dhcp scope link src 62.109.211.31 metric 100
62.109.211.12 dev eth0 proto dhcp scope link src 62.109.211.31 metric 100
169.254.169.254 via 62.109.211.12 dev eth0 proto dhcp src 62.109.211.31 metric 100
192.168.255.0/24 dev docker0 proto kernel scope link src 192.168.255.1 linkdown
它显示我有 2 个 DNS 服务器路由 10.240.240.1 和 10.240.241.1。我想禁用这两条路由。我尝试了以下“插入式”配置:
for i in /run/systemd/network/10-netplan-*.network; do
drop_in="/etc/systemd/network/$(basename ${i}).d"
mkdir -p "${drop_in}"
cat <<EOF > "${drop_in}/override.conf"
[DHCPv4]
RoutesToDNS=false
EOF
done
但是不管用,运行命令重启后,这两条路由仍然存在,如何禁用这两条路由?