Nochmals: Zwei Netzwerkkarten unter Linux aktivieren

Post Reply
Message
Author
Urs

Nochmals: Zwei Netzwerkkarten unter Linux aktivieren

#1 Post by Urs »

Hallo Zusammen

Mein Problem mit den beiden Netzwerkkarten besteht immernoch (siehe Beitrag: "Zwei Netzwerkkarten unter Linux aktivieren (unten angehängt!)"

Ich habe die Anweisungen von Markus genau befolgt, habe im YAST die Einträge überprüft und auch die beiden Files etc/rc.conf und etc/modules.conf scheinen ok zu sein!
Unter yast werden die beiden Netzwerkkarten als aktiv angezeigt unter yast2 aber steht der Status(Aktiv) auf "--"

Wenn ich /etc/init.d/network restart eingebe in der Konsole, gibt mir diese das hier zurück:
shutting down network device eth1
setting up network device eth1

wo ist hier eth0???

Leider aber nützt das nichts, keine der beiden Karten ist aktiv. Wenn ich aber nur eine der beiden Karten im Rechner habe, funktioniert das alles Problemlos (ich bekomme eine IP vom Cablemodem und wenn ich die Karte mit einer fixen IP versehe, sehe ich sie im netz). Das Ziel ist es aber eben eine Karte mit einer Dynamischen IP über DHCP zu steuern (wird vom cable-Anbieter geschickt) und die andere Karte mit einer fixen IP zu versehen für das interne Netzwerk

Kann mir irgendjemand weiterhelfen???
Ich bin am Verzweifeln!

Gruss Urs



Alte Nachricht:
Hallo zusammen
Ich möchte gerne einen Linux-Firewall erstellen!
Zu diesem Zweck habe ich zwei Netzwerkkarten in meinem Rechner!
Ich habe Suse Linux 7.1 installiert.
YAST2 erkennt die beiden Karten korrekt als eth0 und eth1 nur ist der Status(Aktiv) auf "--" gesetzt!
Wenn ich nur eine von beiden Netzwerkkarten im Rechner habe, dann funktioniert es optimal!
Wie kann ich den Status der beiden Karten ändern, so das beide laufen?

Vielen Dank für eure Hilfe!

Markus

Re: Nochmals: Zwei Netzwerkkarten unter Linux aktivieren

#2 Post by Markus »

Hi Urs,
was steht denn in deiner /etc/network/interfaces (vielleicht heißt der Pfad bei Suse etwas anders)

Sind da beide Schnittstellen eingetragen?
Wenn ja, hast du mal versucht, eth0 von Hand zu starten (mit ifup)?
Siehe auch 'man interfaces', 'man ifup'

Viel Erfolg,
Gruß
Markus


@Thomas Mitzkat
Entschuldige bitte vielmals daß ich keine Ahnung habe. Und viele Grüße.

gewitter
Posts: 1354
Joined: 09. Apr 2001 9:03

Re: Nochmals: Zwei Netzwerkkarten unter Linux aktivieren

#3 Post by gewitter »

@Markus <img src="http://www.pl-forum.de/UltraBoard/Images/Wilk.gif" border="0" align="middle"> kommst ja langsam in die Puschen

@Urs:

wenn das mit den suse-scripts nicht klappt, dass z.B. das zweite netzwerk nicht gestartet und somit auch das modul nicht nachgezogen wird, empfehle ich die konfiguration grundsätzlich umzustellen:

benenne das script /etc/init.d/network um in /etc/init.d/network.save. erstelle ein neues script network:

#!/bin/sh
# Begin /etc/init.d/network
#
# Main script by Gerard Beekmans - gerard@linuxfromscratch.org
# GATEWAY check by Jean-François Le Ray - jfleray@club-internet.fr
# "Specify which IF to use to reach default GATEWAY" by
# Graham Cantin - gcantin@pacbell.net
#

#
# Include the functions declared in the /etc/init.d/functions file
# and the variables from the /etc/sysconfig/network file.
#

source /etc/init.d/functions
source /etc/sysconfig/network

case "$1" in
start)

#
# Obtain all the network card configuration files
#

for interface in $(/bin/ls /etc/sysconfig/nic-config/ifcfg* | \
grep -v ifcfg-lo)
do
#
# Load the variables from that file
#

source $interface
#
# If the ONBOOT variable is set to yes, process this file and bring the
# interface up.
#

if [ "$ONBOOT" == yes ]
then
echo -n "Bringing up the $DEVICE interface..."
/sbin/ifconfig $DEVICE $IP broadcast $BROADCAST \
netmask $NETMASK
evaluate_retval
fi
done

#
# If the /etc/sysconfig/network file contains a GATEWAY variable, set
# the default gateway and the interface through which the default
# gateway can be reached.
#

if [ "$GATEWAY" != "" ]; then
echo -n "Setting up routing for $GATEWAY_IF interface..."
/sbin/route add default gateway $GATEWAY \
metric 1 dev $GATEWAY_IF
evaluate_retval
fi
;;

stop)

#
# Obtain all the network card configuration files
#

for interface in $(/bin/ls /etc/sysconfig/nic-config/ifcfg* | \
grep -v ifcfg-lo)
do
#
# Load the variables from that file
#

source $interface
#
# If the ONBOOT variable is set, process the file and bring the
# interface down
#

if [ $ONBOOT == yes ]
then
echo -n "Bringing down the $DEVICE interface..."
/sbin/ifconfig $DEVICE down
evaluate_retval
fi
done
;;

restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac

# End /etc/init.d/network

erstelle ein file /etc/init.d/functions:

#!/bin/sh
# Begin /etc/init.d/functions

#
# Set a few variables that influence the text that's printed on the
# screen. The SET_COL variable starts the text in column number 70 (as
# defined by the COL variable). NORMAL prints text in normal mode.
# SUCCESS prints text in a green colour and FAILURE prints text in a red
# colour
#
switch="/etc/init.d"

if test -z "$LINES" -o -z "$COLUMNS" ; then
eval `stty size 2>/dev/null | \
(read L C; echo LINES=${L:-24} COLUMNS=${C:-80})`
fi
export LINES COLUMNS
if test $LINES -eq 0 -o $COLUMNS -eq 0 ; then
LINES=24
COLUMNS=80
fi

LEFT="["
RIGHT="]"
esc=`echo -en "\033"`
extd="${esc}[1m"
warn="${esc}[31m"
done="${esc}[32m"
attn="${esc}[33m"
info="${esc}[34m"
down="${esc}[35m"
norm=`echo -en "${esc}[m\017"`
stat=`echo -en "\015${esc}[${COLUMNS}C${esc}[10D"`

COL=70
WCOL=50
SET_COL="echo -en \<!--no-->033[${COL}G"
SET_WCOL="echo -en \<!--no-->033[${WCOL}G"
EXTEND="echo -en \<!--no-->033[1m"
NORMAL="echo -en \<!--no-->033[0;39m"
SUCCESS="echo -en \<!--no-->033[1;32m"
WARNING="echo -en \<!--no-->033[1;33m"
FAILURE="echo -en \<!--no-->033[1;31m"

#
# The evaluate_retval function evaluates the return value of the process
# that was run just before this function was called. If the return value
# was 0, indicating success, the print_status function is called with
# the 'success' parameter. Otherwise the print_status function is called
# with the failure parameter.
#

action()
{
echo
return 0
}

evaluate_retval()
{
if [ $? = 0 ]
then
print_status success
else
print_status failure
fi
}

#
# The print_status prints [ OK ] or [FAILED] to the screen. OK appears
# in the colour defined by the SUCCESS variable and FAILED appears in
# the colour defined by the FAILURE variable. Both are printed starting
# in the column defined by the COL variable.
#

print_status()
{

#
# If no parameters are given to the print_status function, print usage
# information.
#

if [ $# = 0 ]
then
echo "Usage: print_status {success|failure}"
return 1
fi

case "$1" in
success)
$SET_COL
echo -n "[ "
$SUCCESS
echo -n "OK"
$NORMAL
echo " ]"
;;
warning)
$SET_COL
echo -n "[ "
$WARNING
echo -n "ATTN"
$NORMAL
echo " ]"
;;
failure)
$SET_COL
echo -n "["
$FAILURE
echo -n "FAILED"
$NORMAL
echo "]"
;;
esac

}

#
# The loadproc function starts a process (often a daemon) with
# proper error checking
#

loadproc()
{

#
# If no parameters are given to the print_status function, print usage
# information.
#

if [ $# = 0 ]
then
echo "Usage: loadproc {program}"
exit 1
fi
#
# Find the basename of the first parameter (the daemon's name without
# the path
# that was provided so /usr/sbin/syslogd becomes plain 'syslogd' after
# basename ran)
#

base=$(/usr/bin/basename $1)
#
# the pidlist variable will contains the output of the pidof command.
# pidof will try to find the PID's that belong to a certain string;
# $base in this case
#

pidlist=$(/bin/pidof -o $$ -o $PPID -o %PPID -x $base)

pid=""

for apid in $pidlist
do
if [ -d /proc/$apid ]
then
pid="$pid $apid"
fi
done
#
# If the $pid variable contains anything (from the previous for loop) it
# means the daemon is already running
#

if [ ! -n "$pid" ]
then
#
# Empty $pid variable means it's not running, so we run $* (all
# parameters giving to this function from the script) and then check the
# return value
#

$*
evaluate_retval
else
#
# The variable $pid was not empty, meaning it was already running. We'll
# print [ ATTN ] now
#

$SET_WCOL
echo -n "Already running"
print_status warning
fi

}

#
# The killproc function kills a process with proper error checking
#

killproc()
{

#
# If no parameters are given to the print_status function, print usage
# information.
#

if [ $# = 0 ]
then
echo "Usage: killproc {program} [signal]"
exit 1
fi

#
# Find the basename of the first parameter (the daemon's name without
# the path
# that was provided so /usr/sbin/syslogd becomes plain 'syslogd' after
# basename ran)
#

base=$(/usr/bin/basename $1)

#
# Check if we gave a signal to kill the process with (like -HUP, -TERM,
# -KILL, etc) to this function (the second parameter). If no second
# parameter was provided set the nolevel variable. Else set the
# killlevel variable to the value of $2 (the second parameter)
#

if [ "$2" != "" ]
then
killlevel=-$2
else
nolevel=1
fi

#
# the pidlist variable will contains the output of the pidof command.
# pidof will try to find the PID's that belong to a certain string;
# $base in this case
#

pidlist=$(/bin/pidof -o $$ -o $PPID -o %PPID -x $base)

pid=""

for apid in $pidlist
do
if [ -d /proc/$apid ]
then
pid="$pid $apid"
fi
done

#
# If $pid contains something from the previous for loop it means one or
# more PID's were found that belongs to the processes to be killed
#

if [ -n "$pid" ]
then

#
# If no kill level was specified we'll try -TERM first and then sleep
# for 2 seconds to allow the kill to be completed
#

if [ "$nolevel" = 1 ]
then
/bin/kill -TERM $pid

#
# If after -TERM the PID still exists we'll wait 2 seconds before
# trying to kill it with -KILL. If the PID still exist after that, wait
# two more seconds. If the PIDs still exist by then it's safe to assume
# that we cannot kill these PIDs.
#

if /bin/ps h $pid >/dev/null 2>&1
then
/usr/bin/sleep 2
if /bin/ps h $pid > /dev/null 2>&1
then
/bin/kill -KILL $pid
if /bin/ps h $pid > /dev/null 2>&1
then
/usr/bin/sleep 2
fi
fi
fi
/bin/ps h $pid >/dev/null 2>&1
if [ $? = 0 ]
then
#
# If after the -KILL it still exists it can't be killed for some reason
# and we'll print [FAILED]
#

print_status failure
else

#
# It was killed, remove possible stale PID file in /var/run and
# print [ OK ]
#

/bin/rm -f /var/run/$base.pid
print_status success
fi
else

#
# A kill level was provided. Kill with the provided kill level and wait
# for 2 seconds to allow the kill to be completed
#

/bin/kill $killlevel $pid
if /bin/ps h $pid > /dev/null 2>&1
then
/usr/bin/sleep 2
fi
/bin/ps h $pid >/dev/null 2>&1
if [ $? = 0 ]
then

#
# If ps' return value is 0 it means it ran ok which indicates that the
# PID still exists. This means the process wasn't killed properly with
# the signal provided. Print [FAILED]
#

print_status failure
else

#
# If the return value was 1 or higher it means the PID didn't exist
# anymore which means it was killed successfully. Remove possible stale
# PID file and print [ OK ]
#

/bin/rm -f /var/run/$base.pid
print_status success
fi
fi
else

#
# The PID didn't exist so we can't attempt to kill it. Print [ ATTN ]
#

$SET_WCOL
echo -n "Not running"
print_status warning
fi
}

#
# The reloadproc functions sends a signal to a daemon telling it to
# reload it's configuration file. This is almost identical to the
# killproc function with the exception that it won't try to kill it with
# a -KILL signal (aka -9)
#

reloadproc()
{

#
# If no parameters are given to the print_status function, print usage
# information.
#

if [ $# = 0 ]
then
echo "Usage: reloadproc {program} [signal]"
exit 1
fi

#
# Find the basename of the first parameter (the daemon's name without
# the path that was provided so /usr/sbin/syslogd becomes plain 'syslogd'
# after basename ran)
#

base=$(/usr/bin/basename $1)

#
# Check if we gave a signal to send to the process (like -HUP)
# to this function (the second parameter). If no second
# parameter was provided set the nolevel variable. Else set the
# killlevel variable to the value of $2 (the second parameter)
#

if [ -n "$2" ]
then
killlevel=-$2
else
nolevel=1
fi

#
# the pidlist variable will contains the output of the pidof command.
# pidof will try to find the PID's that belong to a certain string;
# $base in this case
#

pidlist=$(/bin/pidof -o $$ -o $PPID -o %PPID -x $base)

pid=""

for apid in $pidlist
do
if [ -d /proc/$apid ]
then
pid="$pid $apid"
fi
done

#
# If $pid contains something from the previous for loop it means one or
# more PID's were found that belongs to the processes to be reloaded
#

if [ -n "$pid" ]
then

#
# If nolevel was set we will use the default reload signal SIGHUP.
#

if [ "$nolevel" = 1 ]
then
/bin/kill -SIGHUP $pid
evaluate_retval
else

#
# Else we will use the provided signal
#

/bin/kill $killlevel $pid
evaluate_retval
fi
else

#
# If $pid is empty no PID's have been found that belong to the process.
# Print [ ATTN ]
#

$SET_WCOL
echo -n "Not running"
print_status warning
fi
}

#
# The statusproc function will try to find out if a process is running
# or not
#

statusproc()
{

#
# If no parameters are given to the print_status function, print usage
# information.
#

if [ $# = 0 ]
then
echo "Usage: status {program}"
return 1
fi

#
# $pid will contain a list of PID's that belong to a process
#

pid=$(/bin/pidof -o $$ -o $PPID -o %PPID -x $1)
if [ -n "$pid" ]
then

#
# If $pid contains something, the process is running, print the contents
# of the $pid variable
#

echo "$1 running with Process ID $pid"
return 0
fi

#
# If $pid doesn't contain it check if a PID file exists and inform the
# user about this stale file.
#

if [ -f /var/run/$1.pid ]
then
pid=$(/usr/bin/head -1 /var/run/$1.pid)
if [ -n "$pid" ]
then
echo "$1 not running but /var/run/$1.pid exists"
return 1
fi
else
echo "$1 is not running"
fi

}

# End /etc/init.d/functions

lege ein verzeichnis /etc/sysconfig an und darin die datei network:

HOSTNAME=dein_computername
GATEWAY=192.168.0.99
GATEWAY_IF=eth0

im verzeichnis /etc/sysconfig ein verzeichnis nic-config und darin für jedes netzwerk eine datei anlegen:

datei "ifcfg-eth0":
ONBOOT=yes
DEVICE=eth0
IP=192.168.0.3
NETMASK=255.255.255.0
BROADCAST=192.168.0.255

datei "ifcfg-eth1":
ONBOOT=yes
DEVICE=eth1
IP=192.168.10.3
NETMASK=255.255.255.0
BROADCAST=192.168.10.255

datei "ifcfg-lo":
ONBOOT=yes
DEVICE=lo
IP=127.0.0.1
NETMASK=255.0.0.0
BROADCAST=
MTU=


die ip's für eth? müsstest du entsprechend ändern. in den scripten könnten die pfadangaben für aufgerufene programme nicht stimmen, bitte prüfen. die rechte für ausführbare dateien sollten richtig gesetzt sein (executable). die aliase sind ja wohl in /etc/modules.conf richtig gesetzt. die scripte sollten so lauffähig sein, notfalls lässt sich leicht der ursprüngliche zustand wieder herstellen und an dieser lösung dennoch weiterarbeiten. weitere informationen unter www.linuxfromscratch.com, wo man sich anleitungen um ein netzwerk hochfahren zu können, runterladen kann.
Last edited by gewitter on 10. Nov 2001 18:53, edited 1 time in total.

Post Reply