Oneliner for Finding Out Your Public IP Address Via Command Line on FreeBSD

Hello FreeBSD Geeks.

In this article I will show you how to find out your public IP address in FreeBSD Systems, with fetch:

$ fetch -q -o - http://www.ipchicken.com | grep -o -E '(^|[[:space:]])[0-9]*.[0-9]*.[0-9]*.[0-9]*([[:space:]]|$)'

I have used fetch, because wget is not installed by default on FreeBSD systems.

You can alias this oneliner:

$ alias get_ip='fetch -q -o - http://www.ipchicken.com | grep -o -E \'(^|[[:space:]])[0-9]*.[0-9]*.[0-9]*.[0-9]*([[:space:]]|$)\''

To make these alias persistent, do this:

$ echo 'alias get_ip=\'fetch -q -o - http://www.ipchicken.com | grep -o -E \'(^|[[:space:]])[0-9]*.[0-9]*.[0-9]*.[0-9]*([[:space:]]|$)\'\'' >> ~/.{bash,zsh,ksh,csh}rc

 

Tagged with: , , , , ,
Posted in The Linux and Unix Articles!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Subscribe

  

Subscribe to get the latest Linux news and how to guides directly on your e-mail!