ip route save/restore not working

I’m working with a Fedora 32 (F32) host with the KDE/Plasma spin. I’m writing some scripts where I’d like to save/restore the system’s routing tables. On other Linux systems I can use ip route commands to accomplish this:

$ sudo su -
# ip route save table all > backup
# ip route flush table all
# ip route restore < backup

When I try this on my F32 host, the restore step always fails with the error message

Error: Invalid rtm_flags - can not contain DEAD or LINKDOWN.

Can anyone enlighten me as to why the restore step is failing? Or is this a bug?

It looks like some of the interfaces that were up during backup, are currently down or missing.

@vgaetera, you are correct that some of the links are in the DOWN state:

$ ip link show | grep -i down
4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000
5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN mode DEFAULT group default qlen 1000

Apparently, link virbr0-nic is DOWN, and possibly this is the troublemaker.

NB: On my F32 host, the set of links / addresses that are present, and their respective states, does not change before/after I save/restore the routing state.

$ sudo su -
# ip route save table all > tables
# ip address show > address1
# ip link show > link1
# ip route flush table all
# ip address show > address2
# ip link show > link2
# ip route restore < tables
# ip address show > address3
# ip link show > link3

The contents of files address{1,2,3} are identical, as are the contents of files link{1,2,3}.

See also
[1] xhienne, “ip link and ip addr output meaning,” StackExchange: Unix & Linux, Jan. 5. 2017 [Online]. Available: https://unix.stackexchange.com/a/335082/121145

1 Like