Re: IP -> e-mail

2012-06-06 Thread Matthias Apitz
El día Wednesday, June 06, 2012 a las 02:06:48AM -0700, Dánielisz László 
escribió:

> Hi everybody,
> 
> Let say my computer is connected to the internet with a cable modem and has a 
> dynamic IP address via DHCP. This address is refreshed after every random 
> days.
> I want to know the new address even when I'm not home. Like send an e-mail 
> with the new IP, I already know how to do this, but how can I track the event 
> when my computer receives the new IP?
> Any ideas or same issues?

Hi,

Run this in a cronjob:

lynx -dump myip.nl | fgrep 'WAN IP'

strore the result in a file and when it changes, trigger a mail;

HIH

matthias
-- 
Matthias Apitz
e  - w http://www.unixarea.de/
UNIX since V7 on PDP-11, UNIX on mainframe since ESER 1055 (IBM /370)
UNIX on x86 since SVR4.2 UnixWare 2.1.2, FreeBSD since 2.2.5
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: IP -> e-mail

2012-06-06 Thread Robert Huff

Matthias Apitz writes:

>  > Let say my computer is connected to the internet with a cable
>  modem and has a dynamic IP address via DHCP. This address is
>  refreshed after every random days.
>
>  > I want to know the new address even when I'm not home. Like
>  send an e-mail with the new IP, I already know how to do this,
>  but how can I track the event when my computer receives the new
>  IP?
>
>  Run this in a cronjob:
>  
>  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}'


Robert Huff

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: IP -> e-mail

2012-06-06 Thread Matthias Apitz
El día Wednesday, June 06, 2012 a las 09:17:47AM -0400, Robert Huff escribió:

> >  Run this in a cronjob:
> >  
> >  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; 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 :-))

Trust me, the above lynx is the nearly only robust version.

matthias
-- 
Matthias Apitz
e  - w http://www.unixarea.de/
UNIX since V7 on PDP-11, UNIX on mainframe since ESER 1055 (IBM /370)
UNIX on x86 since SVR4.2 UnixWare 2.1.2, FreeBSD since 2.2.5
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: IP -> e-mail

2012-06-06 Thread Robert Bonomi
m
> From owner-freebsd-questi...@freebsd.org  Wed Jun  6 07:37:57 2012
> Date: Wed, 6 Jun 2012 02:06:48 -0700 (PDT)
> From: =?iso-8859-1?Q?D=E1nielisz_L=E1szl=F3?= 
> To: "freebsd-questions@freebsd.org" 
> Subject: IP -> e-mail
>
> Hi everybody,
>
> Let say my computer is connected to the internet with a cable modem and h
> as a dynamic IP address via DHCP. This address is refreshed after every r
> andom days.
> I want to know the new address even when I'm not home. Like send an e-mai
> l with the new IP, I already know how to do this, but how can I track the
> event when my computer receives the new IP?
> Any ideas or same issues?

Schedule a 'cron' job to run as frequently as you like.
Have it:
  a) do an 'ifconfig -a', or maybe just check the 'interface of interest'.
  b) 'diff' that output against a 'reference' copy from the previous run
  c) send an email if diff reports differences
  d) save the ifconfig output for referene in the next run 


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


RE: IP -> e-mail

2012-06-06 Thread Sean Cavanaugh
> -Original Message-
> From: owner-freebsd-questi...@freebsd.org [mailto:owner-freebsd-
> questi...@freebsd.org] On Behalf Of Robert Huff
> Sent: Wednesday, June 06, 2012 9:18 AM
> To: Matthias Apitz
> Cc: freebsd-questions@freebsd.org
> Subject: Re: IP -> e-mail
> 
> 
> Matthias Apitz writes:
> 
> >  > Let say my computer is connected to the internet with a cable
> > modem and has a dynamic IP address via DHCP. This address is
> > refreshed after every random days.
> >
> >  > I want to know the new address even when I'm not home. Like  send
> > an e-mail with the new IP, I already know how to do this,  but how can
> > I track the event when my computer receives the new  IP?
> >

If you are using it so you know what IP to hit from outside your network, I
would also recommend taking a look at a service like DynDNS as you would
have a DNS name that would auto correct for new IP.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: IP -> e-mail

2012-06-06 Thread Robert Bonomi

Matthias Apitz  opined:
> El dia Wednesday, June 06, 2012 a las 09:17:47AM -0400, Robert Huff escribio:
> > Matthias Apitz  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
approach.

_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.



___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: IP -> e-mail

2012-06-06 Thread Matthias Apitz
El día Wednesday, June 06, 2012 a las 10:03:26AM -0400, Sean Cavanaugh escribió:

> > Matthias Apitz writes:
> > 
> > >  > Let say my computer is connected to the internet with a cable
> > > modem and has a dynamic IP address via DHCP. This address is
> > > refreshed after every random days.
> > >
> > >  > I want to know the new address even when I'm not home. Like  send
> > > an e-mail with the new IP, I already know how to do this,  but how can
> > > I track the event when my computer receives the new  IP?
> > >
> 
> If you are using it so you know what IP to hit from outside your network,

I understand that the OP is not at home when the change occurs, but
wants to connect to home;

> I would also recommend taking a look at a service like DynDNS as you would
> have a DNS name that would auto correct for new IP.

the IP provider in Germany do not assign a static DNS name to you if yo do
not have a static IP. 

matthias
-- 
Matthias Apitz
e  - w http://www.unixarea.de/
UNIX since V7 on PDP-11, UNIX on mainframe since ESER 1055 (IBM /370)
UNIX on x86 since SVR4.2 UnixWare 2.1.2, FreeBSD since 2.2.5
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: IP -> e-mail

2012-06-06 Thread RW
On Wed, 6 Jun 2012 02:06:48 -0700 (PDT)
Dánielisz László wrote:

> Hi everybody,
> 
> Let say my computer is connected to the internet with a cable modem
> and has a dynamic IP address via DHCP. This address is refreshed
> after every random days. I want to know the new address even when I'm
> not home. Like send an e-mail with the new IP, I already know how to
> do this, but how can I track the event when my computer receives the
> new IP? Any ideas or same issues?

Have you considered dynamic dns? If you don't actually need the address
it would allow you to access the machine by hostname. Even if you do,
polling the dns is as good a way as any of detecting the change. 
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: IP -> e-mail

2012-06-06 Thread Lowell Gilbert
Dánielisz László  writes:

> Let say my computer is connected to the internet with a cable modem and has a 
> dynamic IP address via DHCP. This address is refreshed after every random 
> days.
> I want to know the new address even when I'm not home. Like send an e-mail 
> with the new IP, I already know how to do this, but how can I track the event 
> when my computer receives the new IP?
> Any ideas or same issues?

dhclient-script(8) has provision for running scripts on any DHCP event,
and provides both new and old IP addresses in environment variables. If
they're different, fire off an e-mail.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: IP -> e-mail

2012-06-06 Thread Matthias Apitz
El día Wednesday, June 06, 2012 a las 09:11:02AM -0500, Robert Bonomi escribió:

> 
> Matthias Apitz  opined:
> > El dia Wednesday, June 06, 2012 a las 09:17:47AM -0400, Robert Huff 
> > escribio:
> > > Matthias Apitz  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 OP request is a bit uncertain and I interpreted it as he wants to
know how to 'phone' home. The OP talks about a cable modem and DHCP and
about the addr for the computer. If your computer is connected to the
'modem' by ethernet or Wifi and the IP is assigned by DHCP to the modem,
you will never see any change in your computer. It just stays for ever,
for example, 192.168.2.1 while the router has 192.168.2.2 and all this
network is NAT behind the router WAN IP. In this szenario your ifconfig
solution will not help.

May be the OP should clarify his situation and what he really wants.

matthias
-- 
Matthias Apitz
e  - w http://www.unixarea.de/
UNIX since V7 on PDP-11, UNIX on mainframe since ESER 1055 (IBM /370)
UNIX on x86 since SVR4.2 UnixWare 2.1.2, FreeBSD since 2.2.5
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


RE: IP -> e-mail

2012-06-06 Thread Sean Cavanaugh
> 
> > I would also recommend taking a look at a service like DynDNS as you
> > would have a DNS name that would auto correct for new IP.
> 
> the IP provider in Germany do not assign a static DNS name to you if yo do
> not have a static IP.
> 

Hence the Dynamic DNS option. Granted OP would have to run a client on their
device to actively track the change but it would update the DNS record
within a small window of the IP change.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: IP -> e-mail

2012-06-06 Thread Mark Felder
On Wed, 06 Jun 2012 09:11:02 -0500, Robert Bonomi  
 wrote:



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


Incorrect; it does solve his problem.


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.


Please people, read carefully: His ISP is handing out his public IP via  
DHCP. This is normal for consumer internet connections. He doesn't care  
about his internal RFC 1918 IP which is handed out by his router's DHCP  
server; that's an easy problem to solve.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"