Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 13,602
Rep:
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.
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.
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"
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.