Tag: ip address

Linux : Sort a list of IP address

like we saw previously in that article , it’s possible to ping an entire /24 subnet with a little convenient bash one liner.
You will get a result like this.

The Problem is , the IP adresses are going to be displayed in the order they answer the ping , and some devices are going to answer faster than other , making a list that is not in order

the sort command in her default setting will sort using the first changing character , which is going to give me a list like that : 21, 254, 31, 32, 41, 42, 46, 8

If you have installed on you host a recent version of the sort command , you will be able to use sort -V
but on older and some embedded devices the -V option is not available ,

You can then launch the sort command with these options :

the result will be :

if you need to sort a /16 list of ip address :

you can just add -k 3,3 to the command : 

Display your current external IP address with WGET

To know your ip address , you can use the command ifconfig
You will know the ip address for each of your network interfaces.

But if you are not directly connected to the internet and use a Gateway that’s nating the internet traffic for you , ifconfig is not going to be helpful to know the ip that connect you to the internet.

with this command the current external ip address associated with you default gateway will display