Questions tagged [ip-address]

Questions related to IP addresses, IPv4 and IPv6.

Filter by
Sorted by
Tagged with
38
votes
6answers
20k views

Random IP Address Generator

randip.py I know there are probably better, easier ways to do this. It was just a bit of a learning exercise for the sake of familiarising myself with Python. It takes a single argument (positional ...
26
votes
3answers
7k views

Filtering a large (50gb+) JSON lines file matching CIDR's

I'm trying to speed up a Python script that reads a large log file (JSON lines, 50gb+) and filter out results that match 1 of 2000 CIDR ranges. Logfile 20 million lines ...
24
votes
3answers
7k views

Converting an IP

I've written a DNS tool in Node and would like to know if there's a better and more efficient way of handling the conversion from an IP to a long. I'm not too good at bitwise just yet and would like ...
16
votes
6answers
11k views

Verifying IPv6 addresses

While trying to learn Python I stumbled upon a question which asks you to write a code that is able to take an input and verify it to see whether it meets the IPv6 Criteria. I wrote the following ...
15
votes
3answers
4k views

Modeling an IPv4 Address

I've recently picked up a book that gives various "modern" C++ challenges/solutions. One of the first ones I did was on modeling an IPv4 address in C++. Below is the full implementation; it's also on ...
14
votes
2answers
2k views

IP sorting program

The purpose of this little program is to: Separate IPv4 addresses and IPv6 addresses Will be able to sort them even if the ...
11
votes
3answers
1k views

IP address detection code

I am using PHP for detecting a user's IP address and displaying their details, and I use OOP (i.e. object-oriented programming). Are there any problems in it or is it well-written? index.php: ...
9
votes
2answers
10k views

Efficiently matching IP addresses with a list of CIDRs

I am using Python3 to extract some information from a dictionary that contains 10k of CIDRs, but the running time is pretty long. Here is my purpose: I have a dictionary of CIDRs (10000) and a list ...
8
votes
3answers
24k views

Validate IP address in Java

Following is the code that I'm currently using to validate the user given IP address (IPV4 and IPV6). It makes use of apache commons-validator's InetAddressValidator...
8
votes
3answers
470 views

Update MediaWiki settings with dynamic IP address

I'm running a MediaWiki instance from a home server where the public IP address is not guaranteed to remain static. The following script is meant to run at boot time to check if the IP address has ...
8
votes
2answers
459 views

Representing IPv6 addresses with PHP per RFC 5952

I wrote the following function in PHP to represent IPv6 addresses as short as possible: ...
8
votes
0answers
458 views

IPv6 parsing in rust

Here is code to parse an IPv6 address. An IPv6 address is 128 bits long. When represented in its printable form, its hextets (1 hextet == 16 bits) are represented as hexadecimal numbers, and are ...
7
votes
3answers
2k views

Getting the current IP from the command line

I made a tiny little bash script, that prints the current IP Address to the command line. I checked the script with ShellCheck (0.4.6-1) on a local debian install and I get the following message: ...
7
votes
2answers
2k views

Validate IP4 address

Validate IP Address I got this problem during an interview. And would like to get some code review. I also wrote several tests with the expected output, and they all passed as expected. Validate an ...
7
votes
3answers
349 views

IP4 strings validator

Trying to write fast non dependency IP4 string validator for embedded system, It should counts leading zeros, values over 255 and other corrupted strings. Not sure if I missed something. Сan you guys ...
7
votes
2answers
1k views

Erlang code to list all IP addresses

This is some Erlang code I wrote to output a string of all the IP addresses of the machine. The string is simply printed to the user for him to read. ...
7
votes
4answers
284 views

IPv4 struct utilizing explicit layout

I was inspired by Processing a list to build an IP in String Format to reinvent the wheel a little bit and play around with explicit struct layouts. You see, an IP address is really made up of four,...
7
votes
2answers
229 views

Simple IP address parser in C

I have written a C function to parse an IP address that should match the regular expression ^\d+.\d+.\d+.\d+ and nothing else. Additionally all bytes are limited to ...
7
votes
3answers
144 views

Ruby module for Docker DNS updates

I wrote a Ruby module to update DNS zones on certain events of the Docker API. Its purpose is to make container reachable by their name over a network. I know this is also possible through ...
7
votes
2answers
100 views

IPv4 struct: Round 2

Summary Original Question here. Updated GitHub link here I've taken an interest in lower level data structures and I implemented an 'Ip4Address` to get familiar with Explicit structure layout. It ...
7
votes
2answers
10k views

Get host ip address behind load balancer or without lb

Description Aplication type: WEB API .NET Framework: 4.5 MVC: 5 I need caller host ip in my custom action filter and then in action. On some enviroments we have configured load balancer which ...
6
votes
3answers
2k views

IsInternetAvailable

I've written the following code to determine if an Internet connection is available in mind of this article at Microsoft's technet. In short, there are two methods of prove: Check if the response of ...
6
votes
3answers
4k views

Validating an IP address and returning the reason it's invalid

I have a method that validates a user-written IP address in an Android application. If it's invalid, I need to know why and notify the user using a Toast. I ...
6
votes
3answers
2k views

Locating a PID based on an IP address and port

I wrote a simple Python app that is given an IP address and port and the app then finds the PID listening on that IP:PORT. I would like to hear constructive criticism regarding the bellow code. <...
6
votes
1answer
204 views

Perl script to set IP settings

This is my first go at a Perl script to (semi-) automate setting the correct IP settings. I use it to configure a virtual machine after creation. It's also my first Perl script as a whole, so I'm ...
6
votes
3answers
1k views

Calculate IP Address

I created this based on this website which calculates IP address information such as hosts, netmasks etc. I'm quite new to C and I'm still grasping the idea of the whole array and pointers and bit ...
6
votes
2answers
1k views

Get external IP via email

I wrote a script for my Raspberry Pi that keeps checking my external IP. If it changes, the Raspberry Pi will send me the new IP via email. Any suggestions for improvements? ...
5
votes
3answers
6k views

Decimal-to-binary converter for IP addresses

...
5
votes
1answer
2k views

Converting IP Addresses to minimal binary formats

Once more, I come to you for assistance! I have written a significant bit of code that converts IP Addresses from strings to minimal byte-arrays. (So that you can store them in a binary format instead ...
5
votes
1answer
856 views

Removing duplicates from a file containing IP addresses

I have a big txt file containing some specific IP addresses, and all of them appear more than once (the file has around 13 million lines). The file looks like this (the first octet is set to zero for ...
5
votes
1answer
215 views

Dynamic DNS IP Checker/Changer for Google Domains in Python

I needed a way to automatically update my IP forwarding rules on Google Domains for my home web server running behind my router. (I'm not paying for a static IP!). After writing a simple functional ...
5
votes
1answer
2k views

String parsing and saving ipaddress to file in Java

Following function will parse string resp, which will be like shown in following example. I will get an IP address in the form of a hexadecimal string like "...
5
votes
1answer
185 views

Get IP info from a FreeBSD machine

I'm try to get the public IP address from my FreeBSD machine and use it for the rest of my code. Is this implementation good? Can it be optimized more? Can you see some gaps here? Something that ...
5
votes
1answer
116 views

Adding ports to a random list of IP addresses

I have created an application that I will be using for pentesting. It creates a list of random IP addresses, pings them, and adds ports to them (but it's not complete). It works exactly how it should,...
4
votes
3answers
3k views

Verify a subnet mask for validity in Python

I've written a small Python function to check whether a string is a valid IPv4 subnet mask. It works but maybe it's too convoluted and terse? Or maybe it could be improved / optimised / rewritten in ...
4
votes
2answers
252 views

/proc/net/tcp results filter and converter

Being unable to easily read the output of /proc/net/tcp I made a small C# console app that modifies the output to be in decimal notation instead of the standard hexadecimal, show the corresponding ...
4
votes
1answer
3k views

IP Whitelist function

I've just created a function to check if your IP is within an array of IPs. The IP array can contain ranges like 192.168/170.50.0/255. I have a working example, but it seems a bit clunky to me. Is ...
4
votes
2answers
267 views

Determine the third octet of an IP address based on user entered site number

I am trying to create a function for a larger script to determine the third octet of a site IP address based off a user entered site number. I have actually come up with the function, but was hoping ...
4
votes
1answer
152 views

Script to periodically Identify and act on public IP address

This script checks what the current public IP address is. The plan is for this to run every 5 minutes or so, and then change some host file configuration depending on whether we the IP is identified ...
4
votes
1answer
349 views

Dynamic IP-address logging

Inspired by Don Stewart's article on Scripting with Haskell I tried a rewrite of a shell-script I did the other day. I was really astonished how easily it worked but as a whole it is about double the ...
4
votes
1answer
46 views

Abbreviating and expanding IP v6 addresses with APL

Recently I solved a challenge (problem 1 of the 3rd easy problem set of phase 2 of the '19 APL Competition) on abbreviating and expanding IP v6 addresses. For that matter, I had to write two functions,...
4
votes
1answer
5k views

Regex to check IP address in Java

I'm toying with Regexes to parse IP Addresses. I've got it to test for anything over 255: ...
4
votes
1answer
3k views

CIDR Notation parser

I created the following code to better understand CIDR notation. Also to learn some of the Stream features in Java8. I posted my unit tests too. I'm interested in ways it might be improved ...
4
votes
2answers
222 views

Displaying IP addresses in Go using Stringer interface

I am trying out some Go code examples (while coding a private project) to get more "in-depth" knowledge about the language. I have come across an exercise from the Go Tour website about displaying ...
4
votes
0answers
68 views

Running DNS lookup over million IP addresses

I need to run over all the IP addresses on the CIDR 10.96.0.0/12 network. There are 1,048,574 IP addresses. I created a multi ...
3
votes
2answers
80 views

Code to get the IP address and format it to run in nmap

For scanning my subnet using my IP address, I need to run the following command nmap -sn 192.168.100.* I want to extend this functionality such that I don't have ...
3
votes
3answers
181 views

Evaluating a dotted quad IP address has clumsy use of inject/fold

I wrote this to consume valid IPv4 addresses in dotted-quad decimal form: ...
3
votes
1answer
90 views

Regular Expression for text that validates IPV4 or Hostname followed by a port number eg: 127.0.0.1:8080 or localhost:8080

An attempt with regular expression to do a foolproof validation of an IV4 or Hostname:port Number. Example texts that can be validated for any of the following: ...
3
votes
1answer
157 views

Finding sessions associated with an IP address using PDO

Originally Posted on Stack Overflow First of all I want to say that I'm new to PDO. I did tried it once but since I found the oop solution complicated and even impossible (...
3
votes
1answer
201 views

Get external IP and update ddns service

I've created a cli application that consists of a package with 2 functions. One to get the external ip address, and another function to update a dynamic dns record at dns.he.net. Both are then used in ...