Re: Finding the external IP on a DSL router?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On November 23, 2004 06:59 pm, Allen Wayne Best wrote:
> Hello:
>
> Does anyone know of a way to find the ip address on the external side of a
> router?
>
> I am have set up a Linux server for a client, where the server is
> 192.168.0.2 and the dsl router is 192.168.0.1. I have set up everything to
> do a ssh in and out of the server via the router. The difficulty is the
> router will change ip address on the external side (or internet seen side!)
> any time it is power cycled. I would like to email myself the new ip when
> it changes.
>
> --
> regards,
> allen wayne best, esq
> "your friendly neighborhood rambler owner"
> "my rambler will go from 0 to 105"
> Current date: 23:55:18::327:2004
>
> Don't try to have the last word -- you might get it.
> 		-- Lazarus Long


Hi Allen,
First, you could set up a (free) acct with a dynamic DNS service (google for 
ddns services). That way you can ping the hostname and get your current IP.

I have a script I run on my firewall to check if my ip changes and email me at 
home and at work. It runs from cron every 20 minutes.

I turned off word wrap but watch if your email client wraps some lines..

#!/bin/bash
#
# 11-01 Pete Nesbitt
# script to check if eth0's IP has changed.
#

DATE=`/bin/date`

# set variables for email
EMAIL="user@xxxxxxxxxx user@xxxxxxxxxxxxxxx"

# a file to hold the previous IP
OLDIP="/usr/local/scripts/check_ip/oldip.txt"

# check for the current IP
CURRENT_IP="`/sbin/ifconfig -a|/bin/grep -A 2 eth0|/bin/awk '/inet/ { print $2 
}'|/bin/sed -e s/addr://`"

# compare to new IP to last IP
if [ "`/bin/cat $OLDIP`" != "$CURRENT_IP" ]; then

# next part is all one line
  /bin/echo "The IP was reset at $DATE (ea 20 min.). The OLD IP was `cat  
$OLDIP`. The New IP is $CURRENT_IP. You must update
yi.org and hostname."|/bin/mail -s "New IP Address" $EMAIL
# end if the long line

# copy the new IP to the old IP
  /bin/echo "$CURRENT_IP" > $OLDIP
fi

exit

-- 
Pete Nesbitt, rhce

-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux