Getting an External IP Address - Programming On Unix

Users browsing this thread: 2 Guest(s)
evbo
Members
So I have a FreeBSD server that needs to know its external IP address and set it as an environment variable. So far, my method for doing this has been

Code:
EXTERNAL_IP="$(dig +short myip.opendns.com @resolver1.opendns.com)"

Of course, this relies on (1) the IP not changing after boot and (2) opendns not going away. Does anyone have ideas on a more robust way of handling this problem? There's probably a very simple solution that I've completely overlooked :)


Messages In This Thread
Getting an External IP Address - by evbo - 31-07-2017, 06:10 PM
RE: Getting an External IP Address - by xero - 31-07-2017, 06:42 PM
RE: Getting an External IP Address - by hades - 01-08-2017, 12:23 AM