Mailinglist Archive: opensuse (1503 mails)

< Previous Next >
Re: [opensuse] Boot Script
  • From: Manfred Hollstein <manfred@xxxxxxxxxxxxxxxxx>
  • Date: Thu, 1 Oct 2009 12:11:52 +0200
  • Message-id: <20091001101152.GH16463@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Hi Wong,

On Thu, 01 Oct 2009, 11:55:41 +0200, Wong wrote:
Hi Manfred,

I have script was run on Redhat 9 (I put in /etc/rc.d/rc.local)

----snip---

EXT_IP="/sbin/ifconfig eth0 | grep inet | cut -d : -f 2 | cut -d \ -f 1"
INT_IP="/sbin/ifconfig eth1 | grep inet | cut -d : -f 2 | cut -d \ -f 1"
INTRANET="192.168.1.0/24"
iptables -A FORWARD -s $INTRANET -d ! $INT_IP -p tcp --dport 25 -j DROP

---snip---

But it is unable to run on SuSE 11.1 (I put in /etc/rc.d/boot.local)

Seems SuSE did not recognize the command EXT_IP="/sbin/ifconfig eth0 |
grep
inet | cut -d : -f 2 | cut -d \ -f 1"

Thanks a lot for your helps and advises.

I'm sure your script didn't do what you expected it to do on Red Hat
either. The line

EXT_IP="/sbin/ifconfig eth0 | grep inet | cut -d : -f 2 | cut -d \ -f 1"

Before those lines, I had EXT_IP=`/sbin/ifconfig eth0 | grep inet | cut -d
: -f 2 | cut -d \ -f 1` , but not work

it's perhaps that current versions of ifconfig now also print out the
IPv6 address, which results in a trailing newline in your command. If
your actually only interested in the IPv4 address, you should use the
following command:

EXT_IP="`/sbin/ifconfig eth0 | sed -n -e 's,.*inet addr:[ ]*\([^ ]*\)
.*$,\1,p'`"

If you want the IPv6 address, use this:

EXT_IP="`/sbin/ifconfig eth0 | sed -n -e 's,.*inet6 addr:[ ]*\([^ ]*\)
.*$,\1,p'`"

just assigns the text literally to the variable $EXT_IP. If you actually
want to get the output of the command, you'd have to put `...` around
the command as in:

EXT_IP="`/sbin/ifconfig eth0 | grep inet | cut -d : -f 2 | cut -d \ -f
1`"

The same is true for the INT_IP line.

I just tried the line above but also could not work as expected.

If the above still doesn't work for you, you should describe what you
expect.

Please advise. TIA

Wong

Cheers.

l8er
manfred
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups