ip-up und firewall Aufruf

Post Reply
Message
Author
yepi+amidiot

ip-up und firewall Aufruf

#1 Post by yepi+amidiot »

Hallo,

Irgendwo laeuft her etwas schief:

Konfiguration: DSL Linux Router (SuSE 7.1) mit Seawall Firewall inkl. Masquerading.
Dial on Demand ist eingerichtet und funktioniert ebenso die Firewall und das Masquerading.

Problem: Die Firewall muss ich manuell nach dem Einwaehlen von pppoed starten. Ich bekomme es einfach nicht hin den Aufruf (/etc/init.d/firewall start) in /etc/ppp/ip-up so zu plazieren, dass die Firewall korrekt nach dem Zuweisen gestartet wird.

Frage: Was ist in dem ip-up File falsch? Was muss ich in das Skript reinschreiben, damit die Firewall beim Auswaehlen wieder runterfaehrt. Sonst gibt es bei einer erneuten Einwahl ja wohl Probleme mit einem erneuten Start.

Vielen Dank im voraus.

yep

BTW: SuSE Firewall ist nicht installiert.
****************************************snip***************************************
#!/bin/sh

# (C) 1997-2001 SuSE GmbH, Germany
# Klaus Franken <feedback@suse.de> 25.02.1998
# Remo Behn <feedback@suse.de> 18.07.1998
# Send suggestions and comments to feedback@suse.de

BASENAME=${0##*/}
INTERFACE=$1
DEVICE=$2
SPEED=$3
LOCALIP=$4
REMOTEIP=$5

if [ -z "$REMOTEIP" ]; then
echo "Usage: $0 <INTERFACE> <DEVICE> <SPEED> <LOCALIP> <REMOTEIP>"
exit 1
fi

TERM=raw
export TERM

. /etc/rc.config

case "$INTERFACE" in
ippp*)

# find the device
found=0
for I in $NETCONFIG $NETCONFIG_PCMCIA; do
eval NETDEV=\$NETDEV$I
if [ $NETDEV = $INTERFACE ]; then
found=1
break;
fi
done

if [ $found -eq 0 ]; then
echo "Device '$INTERFACE' not configured in '/etc/rc.config'"
exit 1
fi

eval IFCONFIG=\$IFCONFIG$I

case "$BASENAME" in
ip-up)
# Get the nameservers (works with ipppd option ms-get-dns):

if [ -n "$MS_DNS1" -a "$START_NAMED" != "yes" ]; then
rm -f /etc/ppp/resolv.prev
if [ -f /etc/resolv.conf ]; then
cp -p /etc/resolv.conf /etc/ppp/resolv.prev
grep domain /etc/ppp/resolv.prev > /etc/resolv.conf
grep search /etc/ppp/resolv.prev >> /etc/resolv.conf
echo "nameserver $MS_DNS1" >> /etc/resolv.conf
echo "nameserver $MS_DNS2" >> /etc/resolv.conf
echo "Modified /etc/resolv.conf for DNS at $INTERFACE"
else
echo "nameserver $MS_DNS1" >> /etc/resolv.conf
echo "nameserver $MS_DNS2" >> /etc/resolv.conf
chmod 644 /etc/resolv.conf
echo "Installed /etc/resolv.conf for DNS at $INTERFACE"
fi
fi

#
# SuSE Firewall script: If you installed the package firewals
# and configured your firewall in /etc/rc.config.d/firewall.rc.config
# then set START_FW in /etc/rc.config to yes and it will be
# started here:
#
# test "$START_FW" = yes && /sbin/SuSEfirewall
# test -x /sbin/SuSEpersonal-firewall && . /sbin/SuSEpersonal-firewall

#
# You may choose to use a default firewall script, configured for
# the standard dialup user(install package ipchains):
#
#test -x /etc/ppp/inet_chains.local && /etc/ppp/inet_chains.local "$@"

/etc/init.d/firewall start

# maybe you want to start mail services:
# set follow variables in /etc/rc.config
# SENDMAIL_TYPE="yes"
# SENDMAIL_SMARTHOST="<ISP-mailserver>"
# SENDMAIL_ARGS="-bd -om"
# SENDMAIL_EXPENSIVE="yes"
# SENDMAIL_NOCANONIFY="yes"
#/usr/bin/fetchmail -a -v >>/var/log/fetchmail 2>&1 &
#/usr/sbin/sendmail -q &

# As an alternative to the commands above, you can use a seperate script,
# /etc/ppp/poll.tcpip. The default scripts as shipped is able to set the
# system clock using ntpdate (see the XNTPD_INITIAL_NTPDATE setting in
# /etc/rc.config). It supports fetchmail with a system-wide
# /etc/fetchmailrc and can use UUCP to fetch mail over TCP/IP, provided
# that UUCP is configured properly. Last not least it also calls sendmail
# to send any queued mail. Uncomment the line below.
# /etc/ppp/poll.tcpip

# call ip-up.local if it exists and is executable:
test -x /etc/ppp/ip-up.local && /etc/ppp/ip-up.local "$@"
;;
ip-down)

# Restore the nameservers (got with ipppd option ms-get-dns):

if [ -n "$MS_DNS1" -a "$START_NAMED" != "yes" ]; then
if [ -f /etc/ppp/resolv.prev ]; then
cp -fp /etc/ppp/resolv.prev /etc/resolv.conf
echo "Restored original /etc/resolv.conf"
#else
# rm -f /etc/resolv.conf
# echo "Deinstalled /etc/resolv.conf"
fi
fi

# restart interface
/sbin/ifconfig $INTERFACE $IFCONFIG
# set routes from /etc/route.conf
/etc/init.d/route start $INTERFACE
#
# SuSE Firewall script: If you installed the package firewals
# and configured your firewall in /etc/rc.config.d/firewall.rc.config
# then set START_FW in /etc/rc.config to yes and it will be
# started here:
#
test "$START_FW" = yes && /sbin/SuSEfirewall
test -x /sbin/SuSEpersonal-firewall && . /sbin/SuSEpersonal-firewall

# call ip-down.local if it exists and is executable:
test -x /etc/ppp/ip-down.local && /etc/ppp/ip-down.local "$@"
;;
*)
;;
esac
;;

ppp*)
# Analog-PPP, add commands as you need...
case "$BASENAME" in
ip-up)
#
# This code allows automatic configuration of your resolv.conf
# for peer supplied DNS addresses when using the `usepeerdns'
# option. Original resolv.conf is restored when ip-down is called
# by pppd when the link goes down.
#
if [ -n "$USEPEERDNS" -a -f /etc/ppp/resolv.conf -a "$START_NAMED" != "yes" ]; then
rm -f /etc/ppp/resolv.prev
if [ -f /etc/resolv.conf ]; then
cp -p /etc/resolv.conf /etc/ppp/resolv.prev
grep domain /etc/ppp/resolv.prev > /etc/resolv.conf
grep search /etc/ppp/resolv.prev >> /etc/resolv.conf
cat /etc/ppp/resolv.conf >> /etc/resolv.conf
echo "Modified /etc/resolv.conf for DNS at $INTERFACE"
else
cp /etc/ppp/resolv.conf /etc
chmod 644 /etc/resolv.conf
echo "Installed /etc/resolv.conf for DNS at $INTERFACE"
fi
fi
#
# SuSE Firewall script: If you installed the package firewals
# and configured your firewall in /etc/rc.config.d/firewall.rc.config
# then set START_FW in /etc/rc.config to yes and it will be
# started here:
#
test "$START_FW" = yes && /sbin/SuSEfirewall
test -x /sbin/SuSEpersonal-firewall && . /sbin/SuSEpersonal-firewall

#
# You may choose to use a default firewall script, configured for
# the standard dialup user(install package ipchains):
#
#test -x /etc/ppp/inet_chains.local && /etc/ppp/inet_chains.local "$@"

# call ip-up.local if it exists and is executable:
test -x /etc/ppp/ip-up.local && /etc/ppp/ip-up.local "$@"
;;
ip-down)
#
# This code restores the original resolv.conf saved when ip-up
# was called by the pppd which uses the `usepeerdns' option and
# resolv.conf was modified for the supplied dns server adresses.
#
if [ -n "$USEPEERDNS" -a -f /etc/ppp/resolv.conf -a "$START_NAMED" != "yes" ]; then
if [ -f /etc/ppp/resolv.prev ]; then
cp -fp /etc/ppp/resolv.prev /etc/resolv.conf
echo "Restored original /etc/resolv.conf"
else
rm -f /etc/resolv.conf
echo "Deinstalled /etc/resolv.conf"
fi
fi
#
# SuSE Firewall script: If you installed the package firewals
# and configured your firewall in /etc/rc.config.d/firewall.rc.config
# then set START_FW in /etc/rc.config to yes and it will be
# started here:
#
test "$START_FW" = yes && /sbin/SuSEfirewall
test -x /sbin/SuSEpersonal-firewall && . /sbin/SuSEpersonal-firewall

# call ip-down.local if it exists and is executable:
test -x /etc/ppp/ip-down.local && /etc/ppp/ip-down.local "$@"
;;
*)
;;
esac
;;
*)
# dont know...
;;
esac | logger -p security.notice -t $BASENAME

**************************************snap************************************************

Matze

Re: ip-up und firewall Aufruf

#2 Post by Matze »

hi,

ich persönlich bevorzuge es, solcherlei sachen in die ip-up.local bzw. ip-down.local einzutragen. wie in dem script ip-up zu sehen ist, werden diese, wenn vorhanden, gestartet.

# call ip-up.local if it exists and is executable:
test -x /etc/ppp/ip-up.local && /etc/ppp/ip-up.local "$@"
;;
ip-down)


also leg dir diese dateien an und schreib rein, was bei an- bzw. abwahl passieren soll.

matze

yepi amanidiot

Re: ip-up und firewall Aufruf

#3 Post by yepi amanidiot »

Hi Matze,

Habe ich jetzt gemacht. Zwei Dateien erstellt mit ip-up.down und ip-down.local und in /etc/ppp gestellt. Ich habe jeweils nur den Befehl /etc/init.d/firewall start und stop in die Datein entsprechend eingetragen und ausfuehrbar gemacht (dachte vielleicht hilfts <img src="http://www.pl-forum.de/UltraBoard/Images/Wilk.gif" border="0" align="middle">. Trotzdem laeuft die Seawall beim start vom pppoed nicht hoch.

Noch Tips?

Danke

Yepi

Christian

Re: ip-up und firewall Aufruf

#4 Post by Christian »

Das kann daran liegen dass Du versuchst ein Script außerhalb des Pfades aufzurufen.
Versuch doch mal das ganze mit einem ./ zu erweitern dann sollte das laufen.
Der Eintrag sollte dann so aussehen

/etc/init.d/./firewall start

Für stop natürlich genauso ..

hugenay

Re: ip-up und firewall Aufruf

#5 Post by hugenay »

hm, das macht keinen unterschied afaik.

mach doch mal basic debugging:
- wird ip-up.local wirklich ausgefuehrt? mal ein 'echo "ip-up wurde ausgefuehrt' >> /root/ipup.test.log' in die datei einfuegen und kucken ob wenigstens das geht. BTW: Du hast doch in ip-up.local auch einen interpreter eingegeben: #!/bin/sh zum beispiel?!
- dann kann man schon weiter sehen, ob es an ip-up oder ip-up.local liegt. Diese dateien mal mit echo's spicken und bis wohin das skript laeuft und bis wohin nicht.

gruss hug.

hugenay

Re: ip-up und firewall Aufruf

#6 Post by hugenay »

letzte satz muss so heissen, sorry: Diese dateien mal mit echo's spicken und kucken bis wohin das skript laeuft und bis wohin nicht.

Matze

Re: ip-up und firewall Aufruf

#7 Post by Matze »

@Christian
wieso "/etc/init.d/./firewall start" ??? das "./" kannst du weglassen, wenn der komplette pfad angegeben ist.

@yepi+amidiot
i.e. (ip-up.local):
#!/bin/bash
echo "Firewall wird gestartet" >/dev/tty1
/etc/init.d/firewall start

i.e. (ip-down.local):
#!/bin/bash
echo "Firewall wird gestopt" >/dev/tty1
/etc/init.d/firewall stop


ABER:
sagtest du nicht was von Seawall firewall ? muss die nicht anders gestartet werden ? ich kenn das ding nicht - is nur so ne idee.... denn dies hier startet das standard-suse-firewall-script, soweit ich weiss.

matze

Yepi amanidiot

Re: ip-up und firewall Aufruf

#8 Post by Yepi amanidiot »

Erstmal herzlichen Dank fuer alle Tips. Mittlerweile bin ich einen Schritt weiter.

Script ip-up.local sieht folgendermassen aus:

#!/bin/sh
echo "Firewall Start" > /dev/tty1
/etc/init.d/firewall start

#


Das Skript wird auch mit ip-up ausgefuehrt nur kommt folgende Ausgabe:

Usage: /etc/init.d/firewall {start|stop|reset|restart|status]}


Wie kriege ich den Start Parameter uebergeben?

@Matze
Ich verwende die Seawall. Hatte einige Probleme mit DSL und der SuSE. Mag an mir gelegen haben. Aber wenn die Seawall laeuft, gefaellt sie mir besser.

Y

yepi amanidiot

Re: ip-up und firewall Aufruf

#9 Post by yepi amanidiot »

Noch ne Frage! Ist aus grauer Vorzeit! Hab's mal gewusst.

Wie kann ich eine Zeile in einem Skript mit einem Carriage Return abschliessen? Welches Zeichen wird dafuer verwendet?

Nachedem ich in den Tiefen der Seawall Doku rumgesucht habe, stellt sich raus, dass der Shellaufruf mit einem Carriage Return abgeschlossen werden soll.

Danke

yepi amanidiot

Re: ip-up und firewall Aufruf

#10 Post by yepi amanidiot »

Das Problem ist geloest:

Im Skript muss vor dem Aufruf der Befehl sh stehen.

Begruendung aus SuSE SDB:
In der Umgebung von Root befindet sich "." nicht im Suchpfad (Variable PATH). Wenn der Benutzer root im aktuellen Verzeichnis ein Programm xxx starten will, muß er entweder
./xxx

oder
sh xxx

tippen.

Warum ist dem so?

Das Ganze hat in erster Linie mit Sicherheitsaspekten zu tun.

Ein Beispiel: Root befindet sich im Verzeichnis /tmp und dort ist ein ausführbares Shellscript mit dem Namen "sl", welches folgenden Code enthält:

#!/bin/bash
cd /
rm -rf *

Tippt Root nun aus Versehen
sl

ein (anstelle von "ls"), so wird umgehend irgendwo eine starke Festplattenaktivität zu vermerken sein ;-(

Post Reply