Thank you for the additional functionality. It is actually where I was
heading before I asked the mailing list. But based upon Erich's answer,
I was able to provide a real simple solution. However I'll keep these
scripts for they may come in handy somewhere down the road.

Just in case inquiring minds want to know, they way I solved the issue
was to use the /etc/dhcpc/dhcpcd-eth0.info within the
/etc/shorewall/params file. The first file (dhcpcd-eth0.info file is
created from the DHCPCD daemon when the IP address is assigned. The file
is also updated when the IP address changes. I don't think I'm using the
files quite the way Erich intended by his response, but when I looked
into the /etc/dhcpc/dhcpcd.exe file I saw that it was a simple script
and at the beginning of the script, it was reading in the first file
(dhcpcd-eth0.info). Because the file was properly structured, when the
file is read into the script, the lines are read in as variable/value
pairs.

Since what I wanted was the IP address (which is the first line of the
file), all I needed to do was to read the file into the
/etc/shorewall/params file (just like it is done in the dhcpcd.exe file)
and then I am able to reference each value by the variable assigned to
it, in the case of the IP address, the variable is IPADDR. So the
beginning of my /etc/shorewall/params file looks like this:

HOSTINFO="/etc/hdcpc/dhcpcd-eth0.info"

# Read in the variables and values from the file created from the DHCPCD
daemon process
. ${HOSTINFO}

# Use the DHCP variables to assign values to my local variables
NetFw=${IPADDR}                 # ${IPADDR} is from the dhcpcd-eth0.info
file
NetNet=${NETWORK}            # ${NETWORK} is from the dhcpcd-eth0.info
file
NetGate=${GATEWAY}         # ${GATEWAY} is from the dhcpcd-eth0.info
file

There are some more variables in the file, and some of them would
require parsing to be able to stuff them into shorewall variables, but
it would be simpler to do then parsing the 'ip addr eth0' command. I've
already put these changes into effect and restarted my firewall and
everything is working fine - the values have been properly assigned
within Shorewall.

Thank you so much for the help.
bpk

On Sun, 2004-05-23 at 08:13, chuck_vette66_com wrote: 
> I wanted to do something similar so I wrote these 2 little scripts to solve
> my problem of occasional IP address changes.
> 
> I have 2 parts.
> The first script gets the current address and stuffs it into a temp file.
> The second gets the current address and then compairs it to the stored
> address, if different I get an email.
> both these scritps run on a Cron.
> 
> 
> Part one (stuffs the current address into temp file)
> 
> # Get IP address from interface
> IPADDR=`ip addr show eth0 | grep "inet " | sed s/"    "// | cut -d' ' -f 2 |
> cut -d'/' -f1`
> #write address to tmp for later comparison
> echo $IPADDR > /tmp/ip.txt
> 
> Part 2 mails the new address to me if it has changed.
> 
> #Mail ip address
> #!/bin/sh
> # file = mailip 12/11/02
> su_user=root
> prefix=/tmp/$su_usr.$$
> # Get current IP address from interface
> IPADDR=`ip addr show eth0 | grep "inet " | sed s/"    "// | cut -d' ' -f 2 |
> cut -d'/' -f1`
> #
> { su $su_usr -c "$cmd"
> } 2>$prefix.err 1>$prefix.out
> 
> {
>         echo "    ">>$prefix.msg
>         echo "My IP address is : "$IPADDR >> $prefix.msg
>         echo "    ">>$prefix.msg
> } > $prefix.msg
> 
> # send the mail
> # compaire old and new addresses
> OLD_IPADDR=`cat /tmp/ip.txt`
> 
> if [ $OLD_IPADDR = $IPADDR ]
>  then
>  echo "whoo hoo" # skip (or do something) if same
> else
>  mail -s "Internet IP address Changed!" [EMAIL PROTECTED] < $prefix.msg
> fi
> #
> # clean up
> rm $prefix*
> #
> # written by
> # vette66 (chuck)
> # http://www.vette66.com
> 
> ----- Original Message -----
> From: "Erich Titl" <[EMAIL PROTECTED]>
> To: "Brad Klinghagen" <[EMAIL PROTECTED]>; "LEAF User"
> <[EMAIL PROTECTED]>
> Sent: Sunday, May 23, 2004 6:03 AM
> Subject: Re: [leaf-user] Simple IP address retrieval question
> 
> 
> Brad
> 
> At 06:12 23.05.2004, Brad Klinghagen wrote:
> >Currently I have an ISP that provides an IP address via DHCP, and the
> >address occasionally changes. What I want to do is to retrieve the IP
> >address of the Internet side interface (eth0) of my firewall without
> >manual intervention, and stuff that value into a variable. I need the
> >value for additional DNAT rules because I have a web server and email
> >server on my LAN.
> >
> >This sounds like it should have a really simple solution (like some Bash
> >command or something), and I've looked all over to find how to do this,
> >but haven't seen it anywhere, so forgive me for my ignorance if I've
> >overlooked something outrageously simple.
> 
> Most DHCP clients provide some sort of exit hooks, where the user can, at
> his discretion, do whatever he wants with the newly provided values. For
> dhclient this is /etc/dhclient-exit-hooks, dhcpcd uses dhcpcd.exe by
> default in /etc/dhcpd, for pump I have no info.
> 
> HTH
> 
> Erich
> 
> 
> THINK
> PÃntenstrasse 39
> 8143 Stallikon
> mailto:[EMAIL PROTECTED]
> PGP Fingerprint: BC9A 25BC 3954 3BC8 C024 8D8A B7D4 FF9D 05B8 0A16
> 
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: Oracle 10g
> Get certified on the hottest thing ever to hit the market... Oracle 10g.
> Take an Oracle 10g class now, and we'll give you the exam FREE.
> http://ads.osdn.com/?ad_id149&alloc_idÂ66&op=ick
> ------------------------------------------------------------------------
> leaf-user mailing list: [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/leaf-user
> SR FAQ: http://leaf-project.org/pub/doc/docmanager/docid_1891.html
> 



-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
------------------------------------------------------------------------
leaf-user mailing list: [EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/leaf-user
SR FAQ: http://leaf-project.org/pub/doc/docmanager/docid_1891.html

Reply via email to