Reload the network configuration directly from a python sript ?

HIL nomail at free.fr
Thu Oct 13 06:07:04 EDT 2005


Hi everybody,

I wrote a python script to setup my network interface under Linux. To
perform it, I use directly from my python script external programs as
'ifconfig' and 'route' ans I fill the file /etc/resolv.conf with the good
nameserver IP. So, it it works and my network is up.

My problem is that when I use the function socket.gethostbyaddr just after
setting up the network and without getting out of my script, I get an
exception socket.herror. If I start my script again, now the function
socket.gethostbyaddr works correctly.

Python seems to load the network configuration at startup, and if network is
not set at this moment, it does not reload changes.

So, does someone know how to reload the network configuration directly from
my script without restarting it ?

Thanks by advance.

HIL



More information about the Python-list mailing list