LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 10-22-2002, 11:16 AM   #1
lintadsl
LQ Newbie
 
Registered: Oct 2002
Posts: 25

Rep: Reputation: 15
DHCPCD - can we get IP address of it?


Hi there,
First of all, I have no problem with DHCPCD on my box.
Any one knows that from Client, how to get a new IP whenever DHCP server release new IP and send ifconfig to yahoo email account?
I used pppoe for ADSL and any time re-connected, it send email to my yahoo account with new IP address. Now I moved to Cable modem which requires DHCPCD. I looked some conf files related DHCP but could not fine a right spot to put my email address to get new IP.

Thanks in advance
Regards,
Lint
 
Old 11-02-2002, 02:14 PM   #2
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 13,602

Rep: Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084
I didn't test this and it's a little ugly but it *should* work:

Code:
#!/usr/bin/perl 

# This script will get the current IP and mail it to me if it has changed.


my $ip = `/sbin/ifconfig | grep -A1 eth1 | tail -1 | cut -d : -f 2 | cut -d ' ' -f 1`;
open(FILE,"/var/ip/ip") || die "couldn't open file $!";
my $oldip = <FILE>;
chomp $oldip;
chomp $ip;

if ($ip ne $oldip) {
        $message = "Your new IP is $ip.  It's " . scalar(localtime) . ".";
        `echo "$message" | mail -s IP email\@domain.com`;
        `echo "$ip" > /var/ip/ip`; 
}
Note that eth1 needs to be changed to the interface connected to the cable modem.

--jeremy
 
Old 11-04-2002, 08:30 AM   #3
lintadsl
LQ Newbie
 
Registered: Oct 2002
Posts: 25

Original Poster
Rep: Reputation: 15
So, only thing I need to change is my email address in your script? I am using eth1 to Cable modem. Please correct me if i am wrong. I am thinking I need to defind FILE from "my $oldip = <FILE>;" line. Don't I?
Better let you know I am network guy not programmer. ^_^.

Thanks again. It is exciting to hear since I have not get any respond from others.

Lint.
 
Old 11-04-2002, 08:51 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
The FILE thing is fine, but you'll need to create the ip file yourself before you run jeremy's script, as it will always fail otherwise, so "mkdir /var/ip; touch /var/ip/ip"
 
Old 11-04-2002, 10:16 AM   #5
lintadsl
LQ Newbie
 
Registered: Oct 2002
Posts: 25

Original Poster
Rep: Reputation: 15
Thanks, Chris. I will try that and let you gus know how it goes.
So, this script should be running all the time in background?
If this works, then it would be pretty handy to know everyone who uses cable modem with dinamic IP.

Lintadsl

Last edited by lintadsl; 11-04-2002 at 10:19 AM.
 
Old 11-04-2002, 11:54 AM   #6
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 13,602

Rep: Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084
You would have to run it via cron.

--jeremy
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get ip address, broadcast address, mac address of a machine sumeshstar Programming 2 03-12-2005 04:33 AM
DHCP Server MAC Address found, IP address not assigned wmburke Linux - Wireless Networking 17 11-17-2004 10:33 AM
Slackware 10 dhcpcd MAC address on a laptop questions jtp51 Slackware 12 10-14-2004 12:38 PM
dhcpcd not accepting offered ip address on 3c509b-tpo card Yukoner Slackware - Installation 4 06-14-2004 05:56 PM
RH7.2 dhcpcd & MAC address Nairobi Linux - Networking 4 06-24-2002 03:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration