PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Kapiere ich nicht: Warum symbolischer Link von IP-Down auf IP-Up ?



AndiX
20.11.03, 11:19
ich denke, die meisten von euch kennen diese beiden script dateien IP-UP und IP-DOWN: wenn ich jetzt einen eigenen befehl in IP-UP eintrage, dann befindet sich dieser ebenfalls in der IP-DOWN datei.logisch, die beiden sind ja auch symbolisch miteinander gelinkt.

kann mir aber bitte jemand mal den zweck erklären, was das soll ???

das IP-UP script soll nur bestimmte befehle abarbeiten, wenn dieser ne internetverbindung aufbaut und IP-DOWN wiederrum andere befehle, wenn dieser auflegt.

diese ganze aktion kann ich ja nun vergessen, wenn diese miteinander gelinkt sind. kann ich diese symbolische verlinkung gefahrlos löschen oder was soll dieser mist :confused:

achja: SuSE 8.2

pibi
20.11.03, 12:27
Original geschrieben von AndiX
kann ich diese symbolische verlinkung gefahrlos löschenDas wuerde ich an Deiner Stelle schoen sein lassen, denn bei Linux ist nichts sinnlos oder ueberflüssig;-)

Im Script selber wird naemlich schon unterschieden, ob nun ip-up oder ip-down aufgerufen wurde. Es ist sogar recht klar dokumentiert. Findest Du diese Stelle selber? Wenn nicht, dann frag nochmal.

Gruss Pit.

AndiX
20.11.03, 14:02
mir ist schon klar, dass beim verbindungsaufbau die IP-UP abgearbeitet wird und bei verbindungsabbau nur die IP-DOWN. wie bitte soll ich aber spezielle befehle für IP-UP einbinden, wenn diese dann zusätzlich in der IP-DOWN miteingetragen werden :confused:

dieser sinn ist mir nicht klar :ugly:

pibi
20.11.03, 14:36
Original geschrieben von AndiX
mir ist schon klar, dass beim verbindungsaufbau die IP-UP abgearbeitet wird und bei verbindungsabbau nur die IP-DOWN.Aber beide Aufrufe zeigen auf das gleiche File. In diesem Script selber wird nun unterschieden, ob ip-up aufgerufen wurde oder ip-down. Wie das geht? Kopiere das folgende Script nach /tmp/1-up:
#!/bin/sh

BASENAME=${0##*/}
echo aufgerufen wurde: $BASENAME

case "$BASENAME" in
1-up)
echo up-Bedingung
;;
1-down)
echo down-Bedingung
;;
*)
echo ungueltiger Aufruf
esacDann legen einen Link darauf und nenne diesen 1-down und 1-test.
ln -s /tmp/1-up /tmp/1-down
ln -s /tmp/1-up /tmp/1-testUnd nun rufe der Reihe nach 1-up, 1-down und 1-test auf. Ist es jetzt klaerer?

Gruss Pit.

AndiX
20.11.03, 15:47
grossartig, danke pit. ich habe es nun verstanden und bin nun ein schritt als guru weiter ;-)

möchte ich nun einen eigenen befehl in die up-down eintragen, wo kommt dieser in meinem script dann genau rein ??? das selbe mit ip-up: wo trage ich dann den speziellen befehl NUR für IP-UP ein in diesem script ? sorry für meine fragen, aber ich bin kein script experte und noch ein newbie in sachen linux....

mein IP-UP bzw IP-DOWN script:

#!/bin/sh

# (C) 1997-2002 SuSE Linux AG, Nuernberg, Germany
# Klaus Franken <feedback@suse.de> 25.02.1998
# Remo Behn <feedback@suse.de> 18.07.1998
# Arvin Schnell <feedback@suse.de> 28.02.2002
# Send suggestions and comments to feedback@suse.de

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

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

TERM=raw
export TERM

check_srv() {
RLVL=`/sbin/runlevel | sed 's/. //'`
test -L /etc/init.d/rc${RLVL}.d/S??$1 && return 0
return 1
}

start_firewall() {
case `uname -r` in
2.[345].*)
if check_srv SuSEfirewall2_setup; then
/sbin/SuSEfirewall2 start
else
if check_srv SuSEfirewall_setup; then
/sbin/SuSEfirewall start
fi
fi
;;
*)
if check_srv SuSEfirewall_setup; then
/sbin/SuSEfirewall start
fi
;;
esac
# KG: Probably not correct any more: Should check symlinks as well
test -x /sbin/SuSEpersonal-firewall && . /sbin/SuSEpersonal-firewall
}

# from here on output is logged by logger
case "$INTERFACE" in
ippp*)

if [ -f /etc/sysconfig/network/ifcfg-$INTERFACE ] ; then
. /etc/sysconfig/network/ifcfg-$INTERFACE
else
echo "warning Device '$INTERFACE' has no sysconfig file";
# we don't need to exit here
# exit 1
fi

case "$BASENAME" in
ip-up)
#
# Get the nameservers (works with ipppd option ms-get-dns):
#
if [ -n "$USEPEERDNS" -a -n "$MS_DNS1" ]; then
/sbin/modify_resolvconf modify -s ipppd -e "$INTERFACE" \
-p ipppd -f /etc/ppp/ip-up -n "$MS_DNS1 $MS_DNS2" -t - << EOT
If you do not like the ipppd to change your nameserver
settings remove the option MODIFYDNS for this provider
EOT
fi

# ip_resend hook
test "$IP_RESEND" = "yes" -a -x /usr/sbin/ip_resend_wakeup && \
/usr/sbin/ip_resend_wakeup -m $LOCALIP -o $INTERFACE

#
# SuSE Firewall script: If you installed and configured your firewall
# in /etc/sysconfig/SuSEfirewall2 it will be started here:
#
test "$FIREWALL" = "yes" && start_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 "$@"

# maybe you want to start mail services:
# set follow variables in /etc/sysconfig/sendmail
# 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/sysconfig/xntp). 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.
if test "$RUN_POLL_TCPIP" != "no" ; then
/etc/ppp/poll.tcpip | logger -p security.notice -t poll.tcpip > /dev/null &
fi

# call ip-up.local if it exists and is executable:
if test -x /etc/ppp/ip-up.local ; then
/etc/ppp/ip-up.local "$@" | logger -p security.notice -t ip-up.local > /dev/null &
fi

# run additional scripts if they exist
if [ -d /etc/ppp/ip-up.d ]; then
for SCRIPT in /etc/ppp/ip-up.d/*; do
[ -d $SCRIPT -o ! -x $SCRIPT ] && continue;
# ignore backup files and leftovers from rpm
case $SCRIPT in
*.rpmsave|*.rpmnew|*rpmorig|*~) continue ;;
esac
$SCRIPT "$@" | logger -p security.notice -t $SCRIPT > /dev/null &
done
fi
;;
ip-down)
#
# Restore the nameservers (got with ipppd option ms-get-dns):
#
if [ -n "$USEPEERDNS" -a -n "$MS_DNS1" ]; then
/sbin/modify_resolvconf restore -s ipppd -e "$INTERFACE"
fi

# restart interface
LINK_OPT=""
test "$DYNAMICIP" = "yes" && LINK_OPT="$LINK_OPT dynamic on"
/sbin/ip address flush dev $INTERFACE
/sbin/ip link set $INTERFACE down
/sbin/ip link set $INTERFACE up $LINK_OPT
/sbin/ip address add dev $INTERFACE local $IPADDR peer $PTPADDR

# set routes from /etc/sysconfig/network/routes (only for dod)
if [ "$DIALMODE" = "auto" ] ; then
/etc/sysconfig/network/scripts/ifup-route $INTERFACE
fi

#
# SuSE Firewall script: If you installed and configured your firewall
# in /etc/sysconfig/SuSEfirewall2 it will be started here:
#
test "$FIREWALL" = "yes" && start_firewall

# call ip-down.local if it exists and is executable:
if test -x /etc/ppp/ip-down.local ; then
/etc/ppp/ip-down.local "$@" | logger -p security.notice -t ip-down.local > /dev/null &
fi

# ip_resend hook
test "$IP_RESEND" = "yes" -a -x /usr/sbin/ip_resend && \
/usr/sbin/ip_resend -o $INTERFACE $IP_RESEND_PARAMETER

# run additional scripts if they exist
if [ -d /etc/ppp/ip-down.d ]; then
for SCRIPT in /etc/ppp/ip-down.d/*; do
[ -d $SCRIPT -o ! -x $SCRIPT ] && continue;
# ignore backup files and leftovers from rpm
case $SCRIPT in
*.rpmsave|*.rpmnew|*rpmorig|*~) continue ;;
esac
$SCRIPT "$@" | logger -p security.notice -t $SCRIPT > /dev/null &
done
fi
;;
*)
;;
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 ]; then
/sbin/modify_resolvconf modify -s pppd -p pppd -e "$INTERFACE" \
-f /etc/ppp/ip-up -n "$DNS1 $DNS2" -t - << EOT
If you do not want the pppd to change your nameserver settings
set MODIFYDNS=no in the config file for this provider in
/etc/sysconfig/network/providers/ and ensure that the option
usepeerdns is not set in /etc/ppp/options.
EOT
fi

#
# SuSE Firewall script: If you installed and configured your firewall
# in /etc/sysconfig/SuSEfirewall2 it will be started here:
#
start_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 "$@"

# maybe you want to start mail services:
# set follow variables in /etc/sysconfig/sendmail
# 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/sysconfig/xntp). 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.
if test -z "$IPPARAM" -o -n "${IPPARAM##*no_poll_tcpip*}" ; then
/etc/ppp/poll.tcpip | logger -p security.notice -t poll.tcpip > /dev/null &
fi

# call ip-up.local if it exists and is executable:
if test -x /etc/ppp/ip-up.local ; then
/etc/ppp/ip-up.local "$@" | logger -p security.notice -t ip-up.local > /dev/null &
fi

# run additional scripts if they exist
if [ -d /etc/ppp/ip-up.d ]; then
for SCRIPT in /etc/ppp/ip-up.d/*; do
[ -d $SCRIPT -o ! -x $SCRIPT ] && continue;
# ignore backup files and leftovers from rpm
case $SCRIPT in
*.rpmsave|*.rpmnew|*rpmorig|*~) continue ;;
esac
$SCRIPT "$@" | logger -p security.notice -t $SCRIPT > /dev/null &
done
fi
;;
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 ]; then
/sbin/modify_resolvconf restore -s pppd -e "$INTERFACE"
fi

#
# SuSE Firewall script: If you installed and configured your firewall
# in /etc/sysconfig/SuSEfirewall2 it will be started here:
#
start_firewall

# call ip-down.local if it exists and is executable:
if test -x /etc/ppp/ip-down.local ; then
/etc/ppp/ip-down.local "$@" | logger -p security.notice -t ip-down.local > /dev/null &
fi

# run additional scripts if they exist
if [ -d /etc/ppp/ip-down.d ]; then
for SCRIPT in /etc/ppp/ip-down.d/*; do
[ -d $SCRIPT -o ! -x $SCRIPT ] && continue;
# ignore backup files and leftovers from rpm
case $SCRIPT in
*.rpmsave|*.rpmnew|*rpmorig|*~) continue ;;
esac
$SCRIPT "$@" | logger -p security.notice -t $SCRIPT > /dev/null &
done
fi
;;
*)
;;
esac
;;
*)
# dont know...
;;
esac | logger -p security.notice -t $BASENAME

pibi
20.11.03, 16:22
Original geschrieben von AndiX
grossartig, danke pit. ich habe es nun verstanden und bin nun ein schritt als guru weiter ;-)Na prima, dann hat sich der Aufwand ja gelohnt! ;-)

möchte ich nun einen eigenen befehl in die up-down eintragen, wo kommt dieser in meinem script dann genau rein ??? das selbe mit ip-up: wo trage ich dann den speziellen befehl NUR für IP-UP ein in diesem script ?Genau dafuer gibt es das Script ip-up.local im gleichen Directory. Wenn es nicht existiert, dann erzeuge es, mache es ausfuehrbar und schreibe Deinen Befehl dort rein. ich nehme an, es geht um das Updaten irgendwelcher DynDNS-Server, oder?

Gruss Pit.

PS: Und wenn Du es ganz genau wissen willst, wo und wie das aufgerufen wird:
# call ip-up.local if it exists and is executable:
if test -x /etc/ppp/ip-up.local ; then
/etc/ppp/ip-up.local "$@" | logger -p security.notice -t ip-up.local > /dev/null &
fi

AndiX
20.11.03, 19:39
SUPER :D

hat alles wunderbar geklappt nach dem einrichten dieser beiden *.local files. danke für deine mühe. und ja: es ging um einen dynDNS dienst, der sich beim einloggen ins internet automatisch startet bzw. beendet.