commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
Instead of hard-coding in a check to scrape info from ifconfig based on a specific interface, do it in a more portable way.
This works really well if you switch between wired, wireless, bluetooth or even VPN connections. You can get your current IP in a script (since it'll be something like tun0 instead of eth0 or wlan1).
This uses a well known public ip address 18.104.22.168, but it doesn't actually connect to it, it just shows you the route it would take.
There is 1 alternative - vote for the best!
If you can do better, submit your command here.
You must be signed in to comment.