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

Hello FreeBSD Geeks.

Watch Free Movies

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

$ fetch -q -o - | 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 - | 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 - | grep -o -E \'(^|[[:space:]])[0-9]*.[0-9]*.[0-9]*.[0-9]*([[:space:]]|$)\'\'' >> ~/.{bash,zsh,ksh,csh}rc


Scroll to Top