Mailinglist Archive: opensuse (1503 mails)

< Previous Next >
Re: [opensuse] Boot Script

On Thu, 01 Oct 2009, 12:50:11 +0200, Wong wrote:
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:[ ]*\([^ ]*\)

If you want the IPv6 address, use this:

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

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

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

I have want the script will automatically read the IP of each NIC. Then the
value (IP addr) will be given to other lines of scripts.

Here the result of my simulation:

Server:~ # /sbin/ifconfig eth1 | grep inet | cut -d : -f 2 | cut -d \ -f 1

(By using sample you gave, there was no IP addr output.)

hmm, works perfectly well here. Do you have any LANG or LC_* variables
set to some other value than C, POSIX, or en_US? If yes, you should
prefix the /sbin/ifconfig with "env LANG=POSIX LC_ALL=POSIX".

My apologize to misinform, your sample of script is able to run. I missed the ' sign after .*$,\1,p. Below the result:

Server:~ # /sbin/ifconfig eth1 | sed -n -e 's,.*inet addr:[ ]*\([^ ]*\) .*$,\1,p'

But it result same issue if run in boot.local

But I don't know why the line EXT_IP=`/sbin/ifconfig eth0 | grep inet | cut
-d : -f 2 | cut -d \ -f 1` was not functioning in SuSE.

can you add "set -x" to your script and post the output from running the

Where can I put the command?

Does the line #! /bin/sh cause the issue? In RH9 it was #! /bin/bash.

no, that would be highly unlikely, at least in a "normal" setup ;-)
Please show the output from the following commands:

# ls -als /bin/sh
# rpm -qf /bin/sh

Here it is:

Server:~ # ls -als /bin/sh
0 lrwxrwxrwx 1 root root 4 Sep 4 14:11 /bin/sh -> bash

Server:~ # rpm -qf /bin/sh

Here is my boot.local scripts

#! /bin/sh

iptables -F
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain

#EXT_IP=`/sbin/ifconfig eth0 | grep inet | cut -d : -f 2 | cut -d \ -f 1`
EXT_IP=`/sbin/ifconfig eth0 | sed -n -e 's,.*inet addr:[ ]*\([^ ]*\) .*$,\1,p'`
#INT_IP=`/sbin/ifconfig eth1 | grep inet | cut -d : -f 2 | cut -d \ -f 1`
INT_IP=`/sbin/ifconfig eth1 | sed -n -e 's,.*inet addr:[ ]*\([^ ]*\) .*$,\1,p'`

iptables -A INPUT -s 0/0 -d $EXT_IP -p tcp --dport 25 -j ACCEPT
iptables -A FORWARD -s $INTRANET -d ! $INT_IP -p tcp --dport 25 -j LOG
iptables -A FORWARD -s $INTRANET -d ! $INT_IP -p tcp --dport 25 -j DROP

All scripts that use $EXT_IP and $INT_IP are unable run.

Thanks a lot, Manfred.


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

< Previous Next >
Follow Ups