ip-address

Sorting CSV with IP address column in pandas

Sorting CSV with IP address column in pandas Question: I have a CSV file with a column of IP addresses, MAC addresses and some other data. I want to sort all of the data by the IP addresses in ascending order Input: | IP Address | MAC Address | ID | | — | — …

Total answers: 1

Python Socket to connect over Global Public IP Address

Python Socket to connect over Global Public IP Address Question: I have been working on a project to connect computers located in different locations together through Python. Initially, while testing, I used my private IP address (I did not know it was private at the time) to connect computers on the same network as mine. …

Total answers: 1

ipaddress module ValueError('%s has host bits set' % self)

ipaddress module ValueError('%s has host bits set' % self) Question: I am trying to list valid hosts for given network range via Python3, ipaddress module but I am getting ValueError ValueError(‘%s has host bits set’ % self) while trying to list all valid hosts. >>> ip_range=input(“Enter IP Range:”) Enter IP Range:192.168.56.101/16 >>> list(ipa.ip_network(ip_range).hosts()) Traceback (most …

Total answers: 4

How to get the IP address of the request to a Heroku app?

How to get the IP address of the request to a Heroku app? Question: Heroku has a routing system to forward requests to the dynos. My application needs to know from where the request came, but it always gets random addresses in a network, probably Heroku’s internals. And I see that in the logs, it …

Total answers: 2

Parsing IP address and port in python

Parsing IP address and port in python Question: Using python, I’d like to accomplish two things: Need to split an ipv6 address and port combination in the format [fec2::10]:80 to fec2::10 and 80. Given an IP address and port combination, I need to determine if the IP is a v4 or v6 address. Eg: 1.2.3.4:80 …

Total answers: 3

Python randomly generated IP address as string

Python randomly generated IP address as string Question: In Python, what should I do if I want to generate a random string in the form of an IP address? For example: “10.0.1.1”, “10.0.3.14”, “172.23.35.1” and so on. Could someone give me some help? Asked By: changzhi || Source Answers: >>> import random >>> import socket …

Total answers: 11

How to convert a list of IP addresses to a list of address ranges?

How to convert a list of IP addresses to a list of address ranges? Question: There are multiple ways to convert a list of IP address to a list of CIDR (netaddr, ipaddr-py). Is there a way to convert a list of IP address ranges to a merged IP range? The following examples return a …

Total answers: 1

Get IP address of visitors using Flask for Python

Get IP address of visitors using Flask for Python Question: I’m making a website where users can log on and download files, using the Flask micro-framework (based on Werkzeug) which uses Python (2.6 in my case). I need to get the IP address of users when they log on (for logging purposes). Does anyone know …

Total answers: 12

Convert "little endian" hex string to IP address in Python

Convert "little endian" hex string to IP address in Python Question: What’s the best way to turn a string in this form into an IP address: “0200A8C0″. The “octets” present in the string are in reverse order, i.e. the given example string should generate 192.168.0.2. Asked By: Matt Joiner || Source Answers: You could do …

Total answers: 5

Find method to store an IP in MySQL for better performance

Find method to store an IP in MySQL for better performance Question: We’ve got a healthy debate going on in the office this week. We’re creating a Db to store proxy information, for the most part we have the schema worked out except for how we should store IPs. One camp wants to use 4 …

Total answers: 7