Skip to content

RTNETLINK answers: File exists – the route already exists

Networkingtested on Ubuntu 24.04, iproute2

The kernel rejects ip route add because there already is an entry for exactly this destination (same prefix, same table, same metric). It never overwrites silently – you have to ask for it.

Symptom

sudo ip route add 192.0.2.0/24 via 10.10.10.254
RTNETLINK answers: File exists

In the course the route to 192.0.2.0/24 is already in the table; running the same command a second time ends with this message.

Diagnosis

Read the whole table and look for the existing entry for the destination.

ip r
default via 172.16.0.1 dev eth0 proto dhcp src 172.16.0.123 metric 100
10.10.10.0/24 dev spiel0 proto kernel scope link src 10.10.10.1
172.16.0.0/24 dev eth0 proto kernel scope link src 172.16.0.123 metric 100
192.0.2.0/24 via 10.10.10.254 dev spiel0
198.51.100.0/24 dev spiel0 scope link metric 50

Causes

same prefixThe route is already in the table

A script runs for the second time, or netplan or another service has already set the route. The key is destination plus table plus metric – a different gateway alone does not make a new entry.

other tableYou mean a different table

With policy routing, routes live in their own tables. Forget table and you write into main – where the entry may already exist.

Fix

Replace instead of add. replace creates or overwrites without an error.
sudo ip route replace 192.0.2.0/24 via 10.10.10.253
ip r show 192.0.2.0/24
192.0.2.0/24 via 10.10.10.253 dev spiel0

Don't: Hiding the message in scripts with 2>/dev/null. Then you do not know which gateway really applies – use replace.

▶
Break it yourself and find it – free
Linux networking hands-on, Day 1: addresses, routes and netplan – every command with real output.
Go to day 1 →

FAQ

Which path does the kernel really take?

ip route get DEST shows the gateway, outgoing interface and source address the kernel picks for exactly this destination.

Why is my route gone after a reboot?

Routes set with ip only live in the kernel. They become permanent only in the netplan configuration.

Related error patterns

More