How can I find local IP addresses (i.e. 192.168.x.x or 10.0.x.x) in Python platform independently and using only the standard library?
How can I find local IP addresses (i.e. 192.168.x.x or 10.0.x.x) in Python platform
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This won’t work always (returns
127.0.0.1on machines having the hostname in/etc/hostsas127.0.0.1), a paliative would be what gimel shows, usesocket.getfqdn()instead. Of course your machine needs a resolvable hostname.