[Gllug] hex IP addresses in /proc

Julian Somers lists at bigpip.com
Wed Feb 15 11:53:13 UTC 2006


On 14 Feb 2006, at 17:17, Tethys wrote:

>
> Julian Somers writes:
>
>> Does anyone know the method to convert the strange hexadecimal IP
>> addresses in /proc (I'm concerned with /proc/net/ip_mr_cache, but
>> they are there in /proc/net/tcp as well) into good old IP addresses?
>
> Just convert them to decimal and swap endianness:
>
> 	hexip=0201A8C0
> 	decip=
> 	sep=
> 	for i in 6 4 2 0
> 	do
> 		[ $i -eq 6 ] || sep=.
> 		decip="$decip$sep$((16#${hexip:$i:2}))"
> 	done
>
> 	echo $decip
>
Fantastic. Thanks!

Julian

> Tet
> -- 
> Gllug mailing list  -  Gllug at gllug.org.uk
> http://lists.gllug.org.uk/mailman/listinfo/gllug

-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list