#!/bin/sh #---------------------------------------------------------------------------- # /etc/rc.d/rc340.circuits.pppoe_in_kernel - configuration of PPPoE # was file /etc/rc.d/pppoe # # Creation: 09.09.2000 fm # Last Update: $Id$ #---------------------------------------------------------------------------- case $OPT_PPPOE in yes) begin_script CIRCUITS_PPPOE "starting pppoe ..." : ${PPPOE_NF_MSS:=MTU} lcp_interval=30 # LCP interval lcp_failure=5 # LCP failure count pppoe_timeout=120 # should be 4 * lcp_interval ip link set dev $PPPOE_ETH mtu 1500 # set mtu to 1500 ip link set dev $PPPOE_ETH up debug='' usepeerdns='' active_filter='' idle= case "$PPPOE_DEBUG" in yes) debug='debug' ;; esac case ${DIALMODE}${PPPOE_HUP_TIMEOUT} in autonever) mode=persist ;; *) active_filter=$(ppp_filter_get) [ -n "$active_filter" ] && active_filter="active-filter \"$active_filter\"" mode=demand idle="idle $PPPOE_HUP_TIMEOUT" ;; esac case "$PPPOE_USEPEERDNS" in yes) usepeerdns='usepeerdns' ;; esac pppoe_dev=$PPPOE_ETH case $pppoe_dev in br*|dummy*) pppoe_dev="nic-$pppoe_dev" ;; esac echo "\"$PPPOE_USER\" * \"$PPPOE_PASS\" *" >> /etc/ppp/pap-secrets do_modprobe pppoe if [ "$START_IMOND" = "yes" ] then defaultroute='' # imond handles default route echo $DIALMODE >/var/run/pppoe.dialmode else defaultroute='defaultroute' echo auto >/var/run/pppoe.dialmode fi eval mtu="$PPPOE_MTU" eval mru="$PPPOE_MRU" : ${mtu:=1492} : ${mru:=1492} local=10.112.112.112 remote=10.112.112.113 localll=::200:0:0:1 remotell=::200:0:0:2 dev=pppoe echo $local >/var/run/$dev.conf echo $remote >>/var/run/$dev.conf case "$OPT_IPV6" in yes) ipv6enable='+ipv6' ipv6ifidentifier="ipv6 $localll,$remotell" echo $localll >/var/run/$dev.conf.ipv6 echo $remotell >>/var/run/$dev.conf.ipv6 ;; *) ipv6enable='noipv6' ipv6ifidentifier='' ;; esac > /var/run/pppoe.HUP mkdir -p /etc/ppp/peers cat < /etc/ppp/peers/circuit.$dev $usepeerdns plugin rp-pppoe.so noipdefault noauth $defaultroute hide-password nodetach local $debug mtu $mtu mru $mru noaccomp noccp nobsdcomp nodeflate nopcomp novj novjccomp user "$PPPOE_USER" lcp-echo-interval $lcp_interval lcp-echo-failure $lcp_failure holdoff 3 maxfail 0 $local:$remote $ipv6enable $ipv6ifidentifier ipcp-accept-remote ipcp-accept-local connect true ktune $mode $idle $active_filter EOF # device for pppoe is present and ethernet link is active attempts=60 wsleeps="1 5 60" # this means that the first 60 attempts are performed once per second # the second 60 attempts are performed once per five seconds # all following attempts are performed once per minute wsleep="$wsleeps" widx=0 (sleep 5; while true do pppoe_device_is_ready_to_use=0 if ip a s $pppoe_dev >/dev/null 2>&1 then pppoe_device_is_ready_to_use=1 if ! ip a s $pppoe_dev | grep -q NO-CARRIER then pppoe_device_is_ready_to_use=2 pppd call circuit.$dev $pppoe_dev [ -f /etc/ppp/peers/circuit.$dev ] || exit 1 imond-stat "pppoe: restart" wsleep="$wsleeps" widx=0 continue fi fi if [ $pppoe_device_is_ready_to_use -lt 2 ] then set -- $wsleep if [ $widx -eq 0 ] then case $pppoe_device_is_ready_to_use in 0) log_error "PPPoE device $pppoe_dev is not available, can't start ppp daemon" ;; 1) log_error "PPPoE device $pppoe_dev has no link, can't start ppp daemon" ;; esac fi sleep $1 widx=$((widx + 1)) if [ $widx -eq $attempts ] then widx=0 if [ $# -gt 1 ] then shift wsleep="$@" fi fi fi done) & case $PPPOE_NF_MSS in MTU) tcpmss_opt=--clamp-mss-to-pmtu ;; *) tcpmss_opt="--set-mss $PPPOE_NF_MSS" ;; esac echo "/sbin/iptables -I FORWARD -o \`cat /var/run/pppoe-device\` -p tcp --tcp-flags SYN,RST SYN -j TCPMSS $tcpmss_opt" > /etc/rc.d/fwrules.pre.pppoe type=pppoe times="$PPPOE_TIMES" usepeerdns="$PPPOE_USEPEERDNS" name="$PPPOE_NAME" chargeint="$PPPOE_CHARGEINT" case ${PPPOE_HUP_TIMEOUT} in never) hup_timeout='0' ;; *) hup_timeout="$PPPOE_HUP_TIMEOUT" ;; esac . /etc/rc.d/dsl-circuit-common if [ -f /usr/local/sbin/pppoe-status ] then /usr/local/sbin/pppoe-status >/dev/tty3 & fi end_script ;; esac