Similar to a http://whatismyip.com lookup. It would obviously need to query a computer out there. Just wondering if anyone had a clever way to do it?
|
|||||
|
|
dig +short myip.opendns.com This only works if you are using OpenDNS as your dns server. If you aren't, one of these should work: dig +short myip.opendns.com @208.67.222.222 dig +short myip.opendns.com @208.67.220.220 dig +short myip.opendns.com @208.67.222.222 @208.67.220.220 |
|||||||||
|
|
You can use curl to get the page from something like whatismyip and then get the pieces out. I used whatismyipaddress.com in this example...obviously the fields will differ with different services.
|
|||
|
|
|
One must use OpenDNS' servers to use this... You can query a certain DNS server with dig like that: dig +short myip.opendns.com @208.67.222.222 |
|||
|
|
|
STUN is the proper solution. % stun -v stun.ekiga.net ... MappedAddress = 88.189.152.187:18009
|
|||
|
|
|
i just run a traceroute to somewhere on the internet and look for the hop out of our local network. perhaps there's a better way? |
|||
|
|
|
"lynx http://whatismyip.com" |
|||
|
|
|
you can use the ifconfig command to list all interfaces and their associated IP address(es). so, if you know your internet interface is ppp0, you can run
$ ifconfig ppp0
ppp0 Link encap:Point-to-Point Protocol
inet addr:X.X.XX.X P-t-P:Y.Y.Y.Y Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1444 Metric:1
RX packets:198986 errors:0 dropped:0 overruns:0 frame:0
TX packets:122929 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:134195571 (127.9 MiB) TX bytes:17101701 (16.3 MiB)
X.X.X.X will be your IP address. Y.Y.Y.Y is the IP address of the next hop. you can then postprocess the output of ifconfig with grep/awk/sed/cut/perl/whatever to extract just the IP. another alternative, if you have the iproute tools installed, is to use the ip command. e.g.
$ ip addr list ppp0
21842: ppp0: mtu 1444 qdisc htb state UNKNOWN qlen 3
link/ppp
inet X.X.X.X peer Y.Y.Y.Y/32 scope global ppp0
that's probably easier to read and certainly easier to parse:
$ ip addr list ppp0 | awk '/inet/ {print $2}'
X.X.X.X
|
|||||||||
|