Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [ip-address]

Questions related to IP addresses, IPv4 and IPv6.

3
votes
0answers
33 views

Extract the IP address from the output of ipconfig when connected to multiple wireless networks

I am trying to extract the ip address of my machine when connected to multiple wireless networks. The motivation here is then I can make a socket connection on that ip when I have two networks that ...
15
votes
3answers
3k 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 ...
7
votes
2answers
1k 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 ...
4
votes
2answers
51 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 ...
1
vote
2answers
32 views

Creating a dict with external and internal IP addresses provided a list of candidates

I created a function that finds internal and external IP addresses, returns them in dict with the keys external_ips and local_ips...
3
votes
2answers
283 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 ...
2
votes
2answers
55 views

Parse IP address from a GPRS module reply

I'm writing a parser to get the IP address from a string I get from a GPRS module. Examples of the string I get from the GPRS module: +QIACT: 1,1,1,\"10.162.143.228\"\r\n\r\nOK\r\n +QIACT: 1,1,...
3
votes
2answers
62 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 ...
1
vote
1answer
380 views

IP Scanning program Python 3

This is the code I made to scan IP addresses. I am new to python and just want to learn how I can optimize it. I know the subprocess is slower than others to IP scanning but if there is a way to make ...
3
votes
1answer
81 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: ...
36
votes
6answers
11k 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 ...
7
votes
0answers
178 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 ...
6
votes
2answers
111 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 ...
16
votes
6answers
7k 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 ...
3
votes
1answer
114 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 (...
1
vote
0answers
40 views

Logging netflow connections based on IP address ranges and blacklists

Background and assumptions: A flow corresponds to a netflow record that is written into mongodb. Each flow record has a ...
2
votes
0answers
65 views

Node.js script and systemd service to update CloudFlare on IP address change

I've created a simple Node script to read the IPv6 addresses of an interface and update a CloudFlare hostname with those addresses. I've designed it so that it can be activated via an instantiated ...
8
votes
3answers
386 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 ...
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: ...
3
votes
1answer
154 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 ...
23
votes
3answers
5k 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 ...
3
votes
1answer
43 views

Code allowed to test mail invitations by users (from another post) on an instance of Visual studio debugging

I am currently working on an application in ASP.Net MVC, with a SQL Server 2016 database and Entity Framework 6. The application can process specific data and generate forms (in DOC format), and in ...
3
votes
2answers
89 views

Extracting an IP address from a hosts file by hostname

I am currently working with Vagrant for the first time, and therefore also working with Ruby for the first time. I have a specific hostname and IP address I would like set for my VM, both of which are ...
5
votes
1answer
149 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 ...
4
votes
1answer
4k 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: ...
3
votes
0answers
73 views

Flexible port scanner library

I have tried to generalize the concept of turning an IP address into a boolean. The save format is an overly complicated way of storing consecutive IP addresses as strings of bits Example usage: <...
5
votes
1answer
141 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 ...
3
votes
1answer
78 views

Aggregate cidrs up to a limit

I have this algorithm which aggregates a list of cidrs up to a provided limit based on the distance between them. It finds the closest ones and calculates the subnet to join them. The loop repeats ...
6
votes
3answers
570 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
3answers
3k 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 ...
7
votes
2answers
8k 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 ...
4
votes
1answer
124 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 ...
2
votes
2answers
228 views

Update user country based on IPv4 decimal address

I have UserSignatures, a table with clientIPs, some of which have CountryIds that are null ...
5
votes
1answer
108 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,...
3
votes
1answer
62 views

Make pinging faster while looking for a Windows PC

This code pings 1 time every IP while using TTL to identify if it's a Windows PC. If so, it outputs it. It's very slow, so is there any way to make it go faster (1-255 in 12 min)? ...
3
votes
1answer
2k 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 ...
6
votes
3answers
1k 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 ...
14
votes
2answers
1k 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 ...
2
votes
2answers
4k views

Resolving IP to hostname in Python 2

This piece of script will take one argument (file which contain list of ip, one per line) and convert it to its hostname. For now this will only work with IPv4. This definitely doesn't look good and ...
5
votes
1answer
1k 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 "...
7
votes
3answers
136 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
92 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
4answers
236 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,...
5
votes
1answer
1k 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 ...
1
vote
3answers
105 views

Implementation of IpV4Address

For legacy reason (guys here LOVE immutable object), I need a struct that contain an IpV4. I can't use System.Net.IPAddress because it's not a struct. So far here what I got: ...
2
votes
1answer
168 views

Skinny model, fat controller in Rails managing user IP addresses

As part of learning Rails framework, I have small app in progress. Basically idea is, user can create IP address, define is it in use, to which server is assigned, which user is it using and role of ...
2
votes
2answers
67 views

Locating existing records

In order to reduce redundancy in my app, I have added the method self.find_or_keep(object) to many of my models in order to find existing records with the same ...
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. <...
3
votes
1answer
75 views

Getting the HTTP client's IP

Can you please tell me whether this is a good way to get the user's IP (IPv4 or IPv6)? Does someone have a better way to do this? Please take a look at the entire code, the ...