Score:1

How to disable routes for the DNS servers in Ubuntu 22.04?

sx flag

On Ubuntu 22.04,the route table can be gotten:

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

It shows I have 2 routes for the DNS Servers 10.240.240.1 & 10.240.241.1. I want to disable the two routes. I tried the "drop-in" configuration below:

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

But it doesn’t work. After run the command and reboot, the two routes still exist. How can I disable the two routes?

Andrew Lowther avatar
jp flag
How are you configuring networking? It is netplan? If there are files in `/etc/netplan` or `/run/systemd/network` you should share the content. The interface being named `eth0` suggests a specialized network setup may be in use.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.