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

后端 未结 5 1085
闹比i
闹比i 2020-12-10 18:48

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 o

5条回答
  •  鱼传尺愫
    2020-12-10 19:21

    Get address of all NICs without any external package

    import socket
    print socket.gethostbyname_ex(socket.gethostname())[2]
    

提交回复
热议问题