How do I get my public IP address on the UNIX CLI ?

I’ve deployed a Centos server and wanted to make sure I was going out through the correct IP address. With a windows machine I would just use something like However, with only the CLI  this isnt possible. Having a POP3 server external to this device I just popped the  mail server to get the IP address from the logs.


An alternative is to use wget:

wget -q -O –

The output will show something like this:

<html><head><title>Current IP Check</title></head><body>Current IP Address: XXX.XXX.XXX.XXX</body></html>

You can use (eg) sed to trim the output but this was good enough for my purposes