如何禁用 Ubuntu 22.04 中的 DNS 服务器路由?

如何禁用 Ubuntu 22.04 中的 DNS 服务器路由?

在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

但是不管用,运行命令重启后,这两条路由仍然存在,如何禁用这两条路由?

相关内容