IP -> e-mail

Robert Bonomi bonomi at mail.r-bonomi.com
Wed Jun 6 14:10:36 UTC 2012

Matthias Apitz <guru at unixarea.de> opined:
> El dia Wednesday, June 06, 2012 a las 09:17:47AM -0400, Robert Huff escribio:
> > Matthias Apitz <guru at unixarea.de> opined:
> > >  
> > >  lynx -dump myip.nl | fgrep 'WAN IP'
> > >  
> > >  strore the result in a file and when it changes, trigger a mail;
> > 
> >   Or, using only tools in the base system:
> > 
> > ifconfig | head | grep "inet " | awk '{print $2}'
> This will not work if your host has some private addr which is NAT'ed by a
> router; 

FALSE TO FACT.  Given the OP's actual request.

>         the real test is ask some remote side "how I do apear to you?"
> ofc you could do this as well by SSH'ing to some side and asking with
> netstat(1) there (which may be shows another NAT'ed addr too :-))

Matthias, your lynx-based 'solution' does *NOT* solve the OP's question.

He wants to know -when- his DHCP assigned address changes.  Consider
what happens if both the expired address and the new address are behind
the _same_ NAT translation.  The internal addrress changes, but the 
external one does not.

To do what the OP _asked_, parsing the 'ifconfig' output *is* the correct

_IF_, on the other hand, he wants to know when the 'externally visible'
address (a _very_ different question) for that host changes, then your 
approach is the correct one.

More information about the freebsd-questions mailing list