I'm trying to get the IP addresses of Local Area Connection 2 in Windows.
First, I run a batch file that registers set of IP address
192.168.254.214
192.168.253.91
192.168.129.1
192.168.254.104
I'd like to check if those IP address was registered successfully using python. I've tried searching on how to get the IP address in a specific network interfaces but the answers is not the answers I'm expecting.
Question:
I'd like to know if the IP address in the batch file was successfully registered in Local Area Connection 2?
Thank you for help!
using this to get the IP address
import socket
ips=[i[4][0] for i in socket.getaddrinfo(socket.gethostname(), None)]
and then you could compare the result with the IP list you give
Note: have tested that on windows 7
Try to use arp request and parse results with the regular expression. I suppose it's most efficient way to solve that problem. You can find the code on StackOverflow.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.