Linux rename vlan tagged interface – routes stick around from the old one

linux-networking

We use a 10Gig NIC with two vlans on it (private network and internet facing), and I am changing the routing on our private network via renaming the network-scripts for it. This is on CentOS 6.0.

Basically, I took what was eth4.401, renamed it (both the script and interface name inside the script) to eth4.403. Then I did 'service network restart', and the new interface comes up and I can ping its gateway. However, both ifconfig and route still show the old interface (eth4.401). I can do 'ifconfig eth4.401 down' to get it out of ifconfig but the routing table still keeps its directly attached route. In addition, when running service network restart, I see this error:

Bringing up interface eth4.408:  RTNETLINK answers: File exists
                                                           [  OK  ]

If I restart, it fixes everything, but any idea on how to get it to drop the old interface (particularly its routes) without restarting the machine?

Best Answer

Your networking scripts are almost certainly calling the vconfig command.

To remove a VLAN interface use the command vconfig rem interface or vconfig rem eth4.401. This will remove all the associated addresses and routes.

I can do 'ifconfig eth4.401 down' to get it out of ifconfig but the routing table still keeps its directly attached route

You could run a command like ip route flush dev eth4.401 and ip addr flush eth4.401, to flush all the routes and addresses associated with an interface without removing it. But you don't really need to do this in your case.

Related Topic