- There is chance that any IP in ifconfig will not match real Internet IP (in case of biNAT) - In FreeBSD there is no iproute2 package, so ip command is not applicable
–
SaveTheRbtzJul 18 '09 at 3:57

true, i don't use NAT so it never occurred to me to....it just seemed "wrong" to me to use an external service for information you can query your own system about. even with NAT, i'd still prefer to figure out how to query the router doing the NAT (perhaps via an SNMP query) than to rely on an external service which may or may not be available when i need it.
–
casJul 18 '09 at 4:44

@Craig, Your approach is fine. However, its not an external IP unless you can reach it on that value from outside. You do have to rely on an external point for this answer. The idea is to find a reliable (at least more than your perimeter point) external point for the query. OpenDNS is a good point.
–
nikJul 19 '09 at 17:17

@nik: the only likely case where your border router's IP isn't the external IP is when you're behind multiple layers of NAT...in which case, the correct solution is to switch to a non-brain-damaged service ASAP. also, the problem with fetching a URL to find out your IP is that it only tells you the IP of the host that actually fetches it - which may be a proxy that strips Via headers.
–
casJul 20 '09 at 9:51