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?