Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Seems a bit dodgy that it leaves entries in the route table .. but if you want to work around it you may want to look at creating a udev rule to clean up the route table on unplug.
We can tell when we get a hotplug by using netlink sockets.
I understand that netlink is probably not the most modern thing to use.
But, we are where we are.
So, what functions could I use to clear out the route table from within a 'C' program ?
Just guessing here .. if you're using netlink sockets maybe you can send a NETLINK_ROUTE message to update the table? Not sure how you'd trigger it though.
When I want the wifi to be used I kill the dhclient on eth0.
But, that doesn't clear it's IP address. This can be seen by doing 'ifconfig' at that point.
So, I could do 'ifconfig eth0 down', followed quickly by 'ifconfi eth0 up' .
But, a better way is to use 'ifconfig eth0 0.0.0.0' .
That clears the IP address from the eth0. And, sometimes it refreshes the route table (but not every time).
So, now I need to discover a way to check when the route table is foobared - then try my new method.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.