Finding your dynamic external IP

Daniel Rudy dcrudy at pacbell.net
Sun Aug 3 16:16:26 PDT 2003


Somewhere around the time of 08/03/2003 15:13, the world stopped and
listened as David S. Jackson spoke these words of wisdom...:

> If your external IP number changes, as with DHCP, is there a way
> to find out what it currently is?  I was thinking you could keep
> BitchX logged into a chat channel and script a /dns yournick and
> email yourself the results from time to time.   
> 
> How would you do it?
> 

If you know what interface you are running on, then you can do this to 
get the IP address:

ifconfig <interface> | head -2 | tail -1 | awk '{print $2}'

to get the IP address.  Then if you want to mail it to yourself, then 
you can do the following:

/usr/bin/printf "Current IP address: `ifconfig <interface> | head -2 | 
tail -1 | awk '{print $2}'`\n" | /usr/bin/mail -s "IP Address 
Assignment" root &

To update your Dynamic DNS, use the following:

ddclient -use=if -if=<interface>

This will run ddclient in daemon mode so that anytime the IP address 
changes on <interface> it will update the DDNS provider's servers.
-- 
Daniel Rudy



More information about the freebsd-questions mailing list