The Python netifaces module
From the Blog ayaz Three years ago I wrote about a couple of methods for obtaining public interface IPs on a system using Python. Last week I had the need again to find IP addresses of all public interfaces on a given server using Python. Accidentally, I came across the netifaces Python module. It is succinct and provides a clean interface. Getting addresses of network interfaces in a portable manner is an extremely difficult task, but this library gets most of the job done. All one needs to do is pip install netifaces and start using it. As a bonus, I have a pice of code to extract a list of IPs from a system’s ethX interfaces: import netifaces def get_public_ip_list(): interfaces = netifaces.interfaces() public_ip_list = [] for interface in interfaces: # Only keep ethX intpakistanblogs.blogspot.comRead Full Post

0 comments :
Post a Comment