Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

James Robertson http://www.r0bertson.co.uk

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

Finding your WAN IP address

My server sits behind a NAT router, so finding out my public IP address is a non-trivial task. I can use curl to poll checkip.dyndns.org for my current address:
curl -s checkip.dyndns.org

The current IP check returns the information in this format: <html><head><title>Current IP Check</title></head><body>Current IP Address: 216.239.39.99</body></html>

Using cut, I can extract just the information that I need:
curl -s checkip.dyndns.org|cut -d ":" -f2|cut -d "<" -f1

That produces something a bit more readable: 216.239.39.99

-------------------------
This article snippet was copied from My sysadmin toolbox [linux.com] while I was googling for 'apt-cache search dyndns'.

Ping a range of IP addresses

(1..254).each {|i| puts ": found 192.168.1.#{i}" if  `ping 192.168.1.#{i} -c 1 -w 1`.match(/ttl/) }
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS