LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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 02-11-2012, 08:10 PM   #1
loopilla
LQ Newbie
 
Registered: Feb 2005
Location: Budapest
Distribution: Fedora Core 3
Posts: 3

Rep: Reputation: 0
How to send an http request after router reconnect to internet on openwrt?


I'd like to be notified about the newly assigned IP when the ISP close the connection in every 24h.
I want to send an http request to an other server to store the IP from the http header.
Is there a way to simply run a command to send the http request after success reconnection(DHCP server).

I want it to add in the router using openwrt.

Thx
 
Old 02-12-2012, 03:47 AM   #2
protube
LQ Newbie
 
Registered: Feb 2012
Distribution: Arch Linux
Posts: 2

Rep: Reputation: Disabled
Hi

Replace the echo functions with ways you'd like to be informed about an IP change (e-mail, etc.) and hit that script in a cron job.
I don't know if there is a specific function in openwrt to do this, but the script does basically the same - it's the not the most beautiful syntax, but it works.

Code:
#!/bin/bash
#set -x

# Create the log file
touch /path/to/log/file
LOG=/path/to/log/file

OLD_IP=`cat $LOG`

# grep current IP address
GETIP=$(curl -s ifconfig.me)

# log current IP address
echo $GETIP > $LOG

# check if ip changed
    if [ "$OLD_IP" == "$GETIP" ]; then
        echo 'NO change of IP address for' `hostname` $y 'on ' `date`

    elif [ "$OLD_IP" != "$GETIP" ]; then  
        echo 'NEW IP address for' `hostname` 'is:' $y 'on ' `date`
    fi

exit 0
UPDATE: I'm sorry for the inconvenience. The code above now works (inspired from here, there is also the option to let the results be mailed to you)

Last edited by protube; 02-24-2012 at 08:26 AM.
 
  


Reply

Tags
network, openwrt, reconnect


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] Send HTTP request signed using private key steven.c.banks Linux - General 1 09-22-2011 09:18 AM
[SOLVED] Send a request to a http server without using sockets. jaepi Programming 7 07-11-2011 10:34 PM
Unable to send HTTP POST request using PPP over GPRS harsh_electro Linux - Networking 7 07-25-2008 09:01 PM
Getting Debian router to notify via HTTP if internet is down ultrasawblade Linux - Software 2 05-14-2007 01:10 PM


All times are GMT -5. The time now is 11:33 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration