I don't know if it will be useful, but have you considered using
STUN software to get the IP address?
There is a package, libnice, which contains a program,
/usr/bin/stunbdc
You need to select a public stun server, perhaps from the list at URL
http://www.voip-info.org/wiki/view/STUN
Please search this webpage for "Public STUN servers"
You might try something like the command:
stunbdc -4
stun.ekiga.net
Please note: I cannot test this suggestion.
I am no longer behind NAT.
I looked at other stun clients but couldn't figure out how to get
the information easily without examining source code.
I installed more than one package, had to guess the name of the STUN
client, run it, as a non-privileged user--forgive my paranoia--hoping
the program would give me some information on what it was and how
to use it.
I wish there was more, and better documentation, on these STUN packages.