Re: Finding the external IP on a DSL router?

From: Pete Nesbitt (pete_at_linux1.ca)
Date: 11/24/04

  • Next message: Mike Klinke: "Re: Cannot reach certain mail servers"
    To: edward@tripled.iinet.net.au, General Red Hat Linux discussion list <redhat-list@redhat.com>
    Date: Tue, 23 Nov 2004 20:19:53 -0800
    
    

    On November 23, 2004 07:58 pm, Edward wrote:
    > > #!/bin/bash
    > > #
    > > # 11-01 Pete Nesbitt
    > > # script to check if eth0's IP has changed.
    > > #
    > >
    > > DATE=`/bin/date`
    > >
    > > # set variables for email
    > > EMAIL="user@domain.com user@otherdomain.com"
    > >
    > > # 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
    >
    > Just a side note Pete - I'm by no means a scripter, but where does the
    > above script find the router's external IP address?
    >
    > What you said before holds true - if you set up dyndns or equivalent,
    > you can ping the address to get the outside ip, but your script (to my
    > untrained eyes), seem to grab the IP information from ifconfig.
    >
    > If I run ifconfig -a, it shows a local address of my gateway as the inet
    > address on eth0, and my outside address on ppp0.
    >
    > But if he's using a router, would his gateway not be a local address?
    >
    > You're probably right though, as I don't know much about these things,
    > but I just want to make sure.
    >
    > Regards,
    > Ed.

    Hi Ed,
    You raise some interesting questions. This may come down to which DSL
    technology is in place.

    My DSL connection (always-on) comes in to a DSL modem (telco provided) that
    has a 10 Mb Ethernet port on the inside. That feeds into a Linux box which
    has 3 nics (InterNet, LAN, DMZ) and acts as a fireqwall/gateway. If it is a
    hardware router, well then that is a different story, I guess I always
    presume Linux:-)

    My outside is eth0, so ifconfig can pull the IP from it. I have almost no
    experience with ppp, but if your using it on DSL then it must be a
    connect-on-demand, not an always-on setup, which would make pulling the IP
    from inside difficult, unless you initiated a external link first.

    This may come down to another "need more info".

    -- 
    Pete Nesbitt, rhce
    -- 
    redhat-list mailing list
    unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
    https://www.redhat.com/mailman/listinfo/redhat-list
    

  • Next message: Mike Klinke: "Re: Cannot reach certain mail servers"

    Relevant Pages

    • Re: CFT: major wireless changes
      ... known configurations ... It doesn't use the "scan" caapabilities of ifconfig, ... I started checking what the script ... ifconfig dumped core; not sure why, ...
      (freebsd-current)
    • Re: Need to monitor when IP Address changes
      ... ifconfig to a text file and uploads it to a password-protected web ... I have a cron job scheduled every hour to run the script, ... after which you'll see the output of ifconfig. ...
      (freebsd-newbies)
    • Re: how do I configure a USB device?
      ... The more complicated one is to do it manually by creating a configuration ... configure your network card as eth0 before being able to assign your DSL ... I would like YaST to do the job but if I ask YaST to add a network card ... This is only the low level start script being called by the runlevel ...
      (alt.os.linux.suse)
    • Re: ifconfig doesnt detect change under crontab
      ... > Whenever my IP address changes, the cron'd ifconfig doesn't seem to ... If using dhcp instead, then something related to whatever does your ... dhcp should have related scripts that can also monitor ... So it appears that something in your undisclosed crontab entry or script ...
      (comp.os.linux.networking)
    • Re: CFT: major wireless changes
      ... ifconfig dumped core; not sure why, ... need to tweak in my script. ... bmiss 7 scanvalid 60 bintval 100 ... DHCPREQUEST on ed1 to 255.255.255.255 port 67 ...
      (freebsd-current)