nic

Python, How to get all external ip addresses with multiple NICs

…衆ロ難τιáo~ 提交于 2019-11-28 11:33:55
What is the most efficient way to get all of the external ip address of a machine with multiple nics, using python? I understand that an external server is neeeded (I have one available) but am un able to find a way to find a good way to specify the nic to use for the connection (So I can use a for loop to iterate through the various nics). Any advice about the best way to go about this? You should use netifaces . It is designed to be cross-platform on Mac OS X, Linux, and Windows. >>> import netifaces as ni >>> ni.interfaces() ['lo', 'eth0', 'eth1', 'vboxnet0', 'dummy1'] >>> ni.ifaddresses(

Python, How to get all external ip addresses with multiple NICs

心已入冬 提交于 2019-11-27 06:14:51
问题 What is the most efficient way to get all of the external ip address of a machine with multiple nics, using python? I understand that an external server is neeeded (I have one available) but am un able to find a way to find a good way to specify the nic to use for the connection (So I can use a for loop to iterate through the various nics). Any advice about the best way to go about this? 回答1: You should use netifaces. It is designed to be cross-platform on Mac OS X, Linux, and Windows. >>>

How can I get the IP address from NIC in Python?

与世无争的帅哥 提交于 2019-11-26 02:08:20
问题 When an error occurs in a Python script on Unix , an email is sent. I have been asked to add {Testing Environment} to the subject line of the email if the IP address is 192.168.100.37 which is the testing server. This way we can have one version of a script and a way to tell if the email is coming from messed up data on the testing server. However, when I google I keep finding this code: import socket socket.gethostbyname(socket.gethostname()) However, that\'s giving me the IP address of 127