gpt-2741gnac_root_files/_mtdblock5.img.extracted/squashfs-root/usr/script/wan_start.sh
2023-11-26 03:26:24 -03:00

856 lines
28 KiB
Bash
Executable file

#!/bin/sh
EtherWan=`head -n 1 /proc/tc3162/eth_portmap`
PROFILE_CFG=/userfs/profile.cfg
if [ -f $PROFILE_CFG ] ; then
. $PROFILE_CFG
fi
if [ "$TCSUPPORT_7526G_RGMII0" != "" ] ;then
EtherWan=`head -n 1 /proc/tc3162/eth_portmap | sed 's/,user_soc_lanport([0-9])//g'`
fi
if [ "$TCSUPPORT_UNIQUEMAC" != "" ] ;then
if [ $# -gt 3 ] ; then
echo "usage: $0 [PVCn] [UniqueMac Flag] [Unique Mac]"
exit 0
fi
else
if [ "$TCSUPPORT_MULTISERVICE_ON_WAN" != "" ] && [ "$TCSUPPORT_WAN_PTM" != "" -o "$TCSUPPORT_WAN_ETHER" != "" ] ;then
if [ $# != 2 ]; then
echo "usage: $0 [PVCn] [Service_Num]"
exit 0
fi
else
if [ $# != 1 ] ; then
echo "usage: $0 [PVCn]"
exit 0
fi
fi
fi
i=$1
k=$1
if [ "$i" = "8" ] || [ "$i" = "9" ] || [ "$i" = "10" ] ; then
isPTMETHER=1
else
isPTMETHER=0
fi
if [ "$TCSUPPORT_MULTISERVICE_ON_WAN" != "" ] && [ "$TCSUPPORT_WAN_PTM" != "" -o "$TCSUPPORT_WAN_ETHER" != "" ] ;then
if [ "$isPTMETHER" = "1" ] ; then
org_i=$i
serv_num=$2
i="$i"_"$serv_num"
k="$org_i""$serv_num"
fi
ifconfig nas$org_i up
fi
if [ "$TCSUPPORT_UNIQUEMAC" != "" ] ;then
UNIQUEMAC_FLAG=$2
UNIQUE_MAC=$3
fi
CONFFILE=/etc/isp$i.conf
echo $CONFFILE
if [ -f $CONFFILE ] ; then
chmod 777 $CONFFILE
. $CONFFILE
else
exit 0
fi
MAC_CONFFILE=/etc/mac.conf
if [ -f $MAC_CONFFILE ]; then
chmod 777 $MAC_CONFFILE
. $MAC_CONFFILE
fi
WAN_MAC_BASE=$LAN_MAC
LAST_MAC=`echo $WAN_MAC_BASE | cut -c 17`;
if [ $LAST_MAC = "0" ] ; then
WanMacForPVC=`echo $WAN_MAC_BASE | cut -c -16`$i
elif [ $LAST_MAC = "8" ] ; then
if [ $i = "0" ] ; then
WanMacForPVC=`echo $WAN_MAC_BASE | cut -c -16`8
elif [ $i = "1" ] ; then
WanMacForPVC=`echo $WAN_MAC_BASE | cut -c -16`9
elif [ $i = "2" ] ; then
WanMacForPVC=`echo $WAN_MAC_BASE | cut -c -16`A
elif [ $i = "3" ] ; then
WanMacForPVC=`echo $WAN_MAC_BASE | cut -c -16`B
elif [ $i = "4" ] ; then
WanMacForPVC=`echo $WAN_MAC_BASE | cut -c -16`C
elif [ $i = "5" ] ; then
WanMacForPVC=`echo $WAN_MAC_BASE | cut -c -16`D
elif [ $i = "6" ] ; then
WanMacForPVC=`echo $WAN_MAC_BASE | cut -c -16`E
elif [ $i = "7" ] ; then
WanMacForPVC=`echo $WAN_MAC_BASE | cut -c -16`F
fi
fi
if [ "$Active" != "Yes" ] ; then
exit 0
fi
if [ $ISP = "0" ] ; then
if [ "$TCSUPPORT_WAN_GPON" != "" ] || [ "$TCSUPPORT_WAN_EPON" != "" ]; then
if [ "$EtherWan" = "-1" ]; then
if [ "$BridgeInterface" = "Yes" ] ; then
/usr/bin/smuxctl add ipoe_bi pon nas$i
else
/usr/bin/smuxctl add ipoe pon nas$i
fi
else
if [ "$BridgeInterface" = "Yes" ] ; then
/usr/bin/smuxctl add ipoe_bi nas10 nas$i
else
/usr/bin/smuxctl add ipoe nas10 nas$i
fi
fi
else
if [ "$TCSUPPORT_MULTISERVICE_ON_WAN" != "" ] && [ "$TCSUPPORT_WAN_PTM" != "" -o "$TCSUPPORT_WAN_ETHER" != "" ] && [ "$isPTMETHER" = "1" ]; then
if [ "$BridgeInterface" = "Yes" ] ; then
/usr/bin/smuxctl add ipoe_bi nas$org_i nas$i
else
/usr/bin/smuxctl add ipoe nas$org_i nas$i
fi
fi
fi
if [ "$IPVERSION" = "IPv4/IPv6" ] ; then
echo 0 > /proc/sys/net/ipv6/conf/nas$i/disable_ipv6
echo 1 > /proc/sys/net/ipv6/conf/nas$i/accept_ra
elif [ "$IPVERSION" = "IPv6" ] ; then
echo 0 > /proc/sys/net/ipv6/conf/nas$i/disable_ipv6
echo 1 > /proc/sys/net/ipv6/conf/nas$i/accept_ra
elif [ "$IPVERSION" = "IPv4" ] ; then
echo 1 > /proc/sys/net/ipv6/conf/nas$i/disable_ipv6
fi
if [ "$TCSUPPORT_WAN_GPON" = "" ] && [ "$TCSUPPORT_WAN_EPON" = "" ]; then
if [ "$QOS" = "ubr" ] ; then
PCR_V="-p $PCR"
elif [ "$QOS" = "cbr" ] || [ "$QOS" = "rt-vbr" ] || [ "$QOS" = "nrt-vbr" ] ; then
PCR_V="-p $PCR -q $SCR -m $MBS"
fi
if [ "$ENCAP" = "1483 Bridged IP LLC" ] ; then
ENCAP_T="-e 0"
elif [ "$ENCAP" = "1483 Bridged IP VC-Mux" ] ; then
ENCAP_T="-e 1"
elif [ "$ENCAP" = "1483 Routed IP LLC(IPoA)" ] ; then
ENCAP_T="-e 2"
elif [ "$ENCAP" = "1483 Routed IP VC-Mux" ] ; then
ENCAP_T="-e 3"
fi
if [ "$TCSUPPORT_WAN_ATM" != "" -o "$TCSUPPORT_WAN_PTM" != "" -o "$TCSUPPORT_WAN_ETHER" != "" ]; then
#ATM only
if [ "$isPTMETHER" = "0" ] ; then
br2684ctl -c $i $ENCAP_T -t $QOS $PCR_V -a 0.$VPI.$VCI &
echo $! > /var/run/nas$i.pid
sleep 1
fi
else
br2684ctl -c $i $ENCAP_T -t $QOS $PCR_V -a 0.$VPI.$VCI &
echo $! > /var/run/nas$i.pid
sleep 1
fi
if [ "$TCSUPPORT_UNIQUEMAC" != "" ] ;then
if [ "$UNIQUEMAC_FLAG" = "1" ]; then
/sbin/ifconfig nas$i hw ether $UNIQUE_MAC
else
if [ "$WAN_MAC" != "" ]; then
/sbin/ifconfig nas$i hw ether $WAN_MAC
fi
fi
else
if [ "$TCSUPPORT_MULTISERVICE_ON_WAN" = "" ] || [ "$TCSUPPORT_WAN_PTM" = "" -a "$TCSUPPORT_WAN_ETHER" = "" ] || [ "$isPTMETHER" != "1" ] ;then
if [ "$WAN_MAC" != "" ]; then
/sbin/ifconfig nas$i hw ether $WAN_MAC
fi
fi
fi
fi
if [ "$MSTC_FIXED_WAN_MAC" != "" ] && [ "$WanMacForPVC" != "" ];then
/sbin/ifconfig nas$i hw ether $WanMacForPVC
fi
if [ "$IPVERSION" != "IPv4" ] && [ "$EnableDynIPv6" = "0" ]; then
echo 1 > /proc/sys/net/ipv6/conf/nas$i/autoconf
if [ "$TCSUPPORT_IPV6_PRIVACYADDRS" != "" ] ;then
echo $IPv6Extension > /proc/sys/net/ipv6/conf/nas$i/use_tempaddr
fi
fi
/sbin/ifconfig nas$i 0.0.0.0
if [ "$MTU" = "0" ] || [ "$MTU" = "" ] ; then
/sbin/ifconfig nas$i mtu 1500
else
/sbin/ifconfig nas$i mtu $MTU
fi
if [ "$IPVERSION" != "IPv6" ] ; then
if [ "$TCSUPPORT_UNIQUEMAC" != "" ] ;then
if [ "$UNIQUEMAC_FLAG" = "1" ]; then
if [ "$DEFAULTROUTE" = "Yes" ] ; then
/sbin/udhcpc -i nas$i -s /usr/script/udhcpc.sh -p /var/run/udhcpc-nas$i.pid&
else
/sbin/udhcpc -i nas$i -s /usr/script/udhcpc_nodef.sh -p /var/run/udhcpc-nas$i.pid&
fi
else
if [ "$WAN_MAC" != "" ]; then
if [ "$DEFAULTROUTE" = "Yes" ] ; then
/sbin/udhcpc -i nas$i -s /usr/script/udhcpc.sh -p /var/run/udhcpc-nas$i.pid &
else
/sbin/udhcpc -i nas$i -s /usr/script/udhcpc_nodef.sh -p /var/run/udhcpc-nas$i.pid&
fi
fi
fi
else
if [ "$TCSUPPORT_WPA_SUPPLICANT" = "" ] || [ "$IPOE_DOT1X_STATUS" != "Enable" ];then
if [ "$WAN_MAC" != "" ]; then
if [ "$DEFAULTROUTE" = "Yes" ] ; then
/sbin/udhcpc -i nas$i -s /usr/script/udhcpc.sh -p /var/run/udhcpc-nas$i.pid&
else
/sbin/udhcpc -i nas$i -s /usr/script/udhcpc_nodef.sh -p /var/run/udhcpc-nas$i.pid&
fi
fi
fi
fi
if [ "$NATENABLE" = "Enable" ] || [ "$NATENABLE" = "FullNAT" -a "$MSTC_VDSL_COLUMBIA_SPECIAL_IPADDRMAP" != "" ]; then
# iptables -t nat -A POSTROUTING -j ADDRMAP_POS$i
if [ "$TCSUPPORT_MULTI_NAT" != "" ] ;then
iptables -t nat -A ADDRMAP_POS -j ADDRMAP_POS$i
fi
iptables -t nat -A POSTROUTING -o nas$i -j MASQUERADE
iptables -t nat -A PREROUTING -j VS_PRE$i
iptables -t nat -A PREROUTING -j DMZ_PRE$i
# iptables -t nat -A PREROUTING -j ADDRMAP_PRE$i
if [ "$TCSUPPORT_MULTI_NAT" != "" ] ;then
iptables -t filter -A ADDRMAP_FORWARD -j ADDRMAP_FORWARD$i
fi
if [ "$TCSUPPORT_PORT_TRIGGER" != "" ] ;then
iptables -t nat -A PREROUTING -i nas$i -j PREROUTING_WAN
iptables -t filter -A FORWARD -i nas$i -j FORWARD_WAN
fi
fi
fi
WAN_IF=nas$i
if [ "$IPVERSION" == "IPv4" ] ; then
echo 1 > /proc/sys/net/ipv6/conf/nas$i/disable_ipv6
fi
elif [ $ISP = "1" ] ; then
if [ "$TCSUPPORT_WAN_GPON" != "" ] || [ "$TCSUPPORT_WAN_EPON" != "" ]; then
if [ "$EtherWan" = "-1" ]; then
if [ "$BridgeInterface" = "Yes" ] ; then
/usr/bin/smuxctl add ipoe_bi pon nas$i
else
/usr/bin/smuxctl add ipoe pon nas$i
fi
else
if [ "$BridgeInterface" = "Yes" ] ; then
/usr/bin/smuxctl add ipoe_bi nas10 nas$i
else
/usr/bin/smuxctl add ipoe nas10 nas$i
fi
fi
else
if [ "$TCSUPPORT_MULTISERVICE_ON_WAN" != "" ] && [ "$TCSUPPORT_WAN_PTM" != "" -o "$TCSUPPORT_WAN_ETHER" != "" ] && [ "$isPTMETHER" = "1" ]; then
if [ "$BridgeInterface" = "Yes" ] ; then
/usr/bin/smuxctl add ipoe_bi nas$org_i nas$i
else
/usr/bin/smuxctl add ipoe nas$org_i nas$i
fi
fi
fi
if [ "$IPVERSION" = "IPv4/IPv6" ] ; then
echo 0 > /proc/sys/net/ipv6/conf/nas$i/disable_ipv6
echo 1 > /proc/sys/net/ipv6/conf/nas$i/accept_ra
elif [ "$IPVERSION" = "IPv6" ] ; then
echo 0 > /proc/sys/net/ipv6/conf/nas$i/disable_ipv6
echo 1 > /proc/sys/net/ipv6/conf/nas$i/accept_ra
elif [ "$IPVERSION" = "IPv4" ] ; then
echo 1 > /proc/sys/net/ipv6/conf/nas$i/disable_ipv6
fi
if [ "$TCSUPPORT_WAN_GPON" = "" ] && [ "$TCSUPPORT_WAN_EPON" = "" ]; then
if [ "$QOS" = "ubr" ] ; then
PCR_V="-p $PCR"
elif [ "$QOS" = "cbr" ] || [ "$QOS" = "rt-vbr" ] || [ "$QOS" = "nrt-vbr" ] ; then
PCR_V="-p $PCR -q $SCR -m $MBS"
fi
if [ "$ENCAP" = "1483 Bridged IP LLC" ] ; then
ENCAP_T="-e 0"
elif [ "$ENCAP" = "1483 Bridged IP VC-Mux" ] ; then
ENCAP_T="-e 1"
elif [ "$ENCAP" = "1483 Routed IP LLC(IPoA)" ] ; then
ENCAP_T="-e 2"
elif [ "$ENCAP" = "1483 Routed IP VC-Mux" ] ; then
ENCAP_T="-e 3"
fi
if [ "$TCSUPPORT_WAN_ATM" != "" -o "$TCSUPPORT_WAN_PTM" != "" -o "$TCSUPPORT_WAN_ETHER" != "" ]; then
#ATM only
if [ "$isPTMETHER" = "0" ] ; then
br2684ctl -c $i $ENCAP_T -t $QOS $PCR_V -a 0.$VPI.$VCI &
echo $! > /var/run/nas$i.pid
sleep 1
fi
else
br2684ctl -c $i $ENCAP_T -t $QOS $PCR_V -a 0.$VPI.$VCI &
echo $! > /var/run/nas$i.pid
sleep 1
fi
if [ "$TCSUPPORT_UNIQUEMAC" != "" ] ;then
if [ "$UNIQUEMAC_FLAG" = "1" ]; then
/sbin/ifconfig nas$i hw ether $UNIQUE_MAC
else
if [ "$WAN_MAC" != "" ]; then
/sbin/ifconfig nas$i hw ether $WAN_MAC
fi
fi
else
if [ "$TCSUPPORT_MULTISERVICE_ON_WAN" = "" ] || [ "$TCSUPPORT_WAN_PTM" = "" -a "$TCSUPPORT_WAN_ETHER" = "" ] || [ "$isPTMETHER" != "1" ] ;then
if [ "$WAN_MAC" != "" ]; then
/sbin/ifconfig nas$i hw ether $WAN_MAC
fi
fi
fi
fi
if [ "$MSTC_FIXED_WAN_MAC" != "" ] && [ "$WanMacForPVC" != "" ];then
/sbin/ifconfig nas$i hw ether $WanMacForPVC
fi
# /sbin/ifconfig nas$i $IPADDR netmask $NETMASK up
# /sbin/ifconfig nas$i $IPADDR6/$PREFIX6
# echo -e "server=$DNSIPv61st@nas$i\\nserver=$DNSIPv62nd@nas$i">>/etc/dnsmasq.conf
# echo -e "nameserver $DNSIPv61st\\nnameserver $DNSIPv62nd">/var/run/dhcp6c-nas$i.info
if [ "$MTU" = "0" ] || [ "$MTU" = "" ] ; then
/sbin/ifconfig nas$i mtu 1500
else
/sbin/ifconfig nas$i mtu $MTU
fi
if [ "$IPVERSION" != "IPv6" ] ; then
if [ "$NATENABLE" = "Enable" ] ; then
# iptables -t nat -A POSTROUTING -j ADDRMAP_POS$i
if [ "$TCSUPPORT_MULTI_NAT" != "" ] ;then
iptables -t nat -A ADDRMAP_POS -j ADDRMAP_POS$i
fi
iptables -t nat -A POSTROUTING -o nas$i -j MASQUERADE
iptables -t nat -A PREROUTING -j VS_PRE$i
iptables -t nat -A PREROUTING -j DMZ_PRE$i
# iptables -t nat -A PREROUTING -j ADDRMAP_PRE$i
if [ "$TCSUPPORT_MULTI_NAT" != "" ] ;then
iptables -t filter -A ADDRMAP_FORWARD -j ADDRMAP_FORWARD$i
fi
if [ "$TCSUPPORT_PORT_TRIGGER" != "" ] ;then
iptables -t nat -A PREROUTING -i nas$i -j PREROUTING_WAN
iptables -t filter -A FORWARD -i nas$i -j FORWARD_WAN
fi
fi
fi
/sbin/ifconfig nas$i up
if [ "$IPVERSION" != "IPv6" ] ; then
/sbin/ifconfig nas$i $IPADDR netmask $NETMASK
fi
if [ "$IPVERSION" != "IPv4" ] ; then
/sbin/ifconfig nas$i $IPADDR6/$PREFIX6
echo -e "nameserver $DNSIPv61st\\nnameserver $DNSIPv62nd">/var/run/dhcp6c-nas$i.info
fi
if [ "$DEFAULTROUTE" = "Yes" ] ; then
if [ "$IPVERSION" != "IPv6" ] ; then
route add default gw $GATEWAY dev nas$i
fi
if [ "$IPVERSION" != "IPv4" ] ; then
ip -6 route del default
route -A inet6 add default gw $DEFGATEWAY6 dev nas$i
echo -e "$IPADDR6/$PREFIX6">/var/tmp/ipaddr6_nas$i.msg
echo -e "$DEFGATEWAY">/var/tmp/gw6_nas$i.msg
fi
#/sbin/route -A inet6 add $IPADDR6/$PREFIX6 gw $DEFGATEWAY6 dev $WAN_IF
#echo -e "server=$DNSIPv61st@nas$i\\nserver=$DNSIPv62nd@nas$i">>/etc/dnsmasq.conf
# route add default gw
fi
WAN_IF=nas$i
if [ "$IPVERSION" == "IPv4" ] ; then
echo 1 > /proc/sys/net/ipv6/conf/nas$i/disable_ipv6
fi
elif [ $ISP = "2" ] ; then
if [ "$TCSUPPORT_WAN_GPON" != "" ] || [ "$TCSUPPORT_WAN_EPON" != "" ]; then
if [ "$EtherWan" = "-1" ]; then
if [ "$BridgeInterface" = "Yes" ] ; then
/usr/bin/smuxctl add pppoe_bi pon nas$i
else
/usr/bin/smuxctl add pppoe pon nas$i
fi
else
if [ "$BridgeInterface" = "Yes" ] ; then
/usr/bin/smuxctl add pppoe_bi nas10 nas$i
else
/usr/bin/smuxctl add pppoe nas10 nas$i
fi
fi
else
if [ "$TCSUPPORT_MULTISERVICE_ON_WAN" != "" ] && [ "$TCSUPPORT_WAN_PTM" != "" -o "$TCSUPPORT_WAN_ETHER" != "" ] && [ "$isPTMETHER" = "1" ]; then
if [ "$BridgeInterface" = "Yes" ] ; then
/usr/bin/smuxctl add pppoe_bi nas$org_i nas$i
else
/usr/bin/smuxctl add pppoe nas$org_i nas$i
fi
fi
fi
if [ "$MSTC_FIXED_WAN_MAC" != "" ] && [ "$WanMacForPVC" != "" ];then
/sbin/ifconfig nas$i hw ether $WanMacForPVC
fi
if [ "$CONNECTION" != "Connect_Manually" ] ; then
#make sure the LCP echo will take no effect about ppp
if [ "$MSTC_TELEFONICA_UNIFYFW" != "" ] ; then
case `cat /proc/country` in
D0)
PPP_PARAM="unit $i user $USERNAME password $PASSWORD nodetach holdoff 4 maxfail 0 usepeerdns lcp-echo-interval 30 lcp-echo-failure 3"
;;
C6)
echo "$PASSWORD" > /var/tmp/ppppasswd$i.conf
PPP_PARAM="unit $i user $USERNAME password fakepassword nodetach holdoff 5 maxfail 0 usepeerdns lcp-echo-interval 30 lcp-echo-failure 5"
;;
*)
PPP_PARAM="unit $i user $USERNAME password $PASSWORD nodetach holdoff 5 maxfail 0 usepeerdns lcp-echo-interval 30 lcp-echo-failure 5"
;;
esac
else #MSTC_TELEFONICA_UNIFYFW
if [ "$TCSUPPORT_CZ_GENERAL" != "" ] ;then
if [ "$TCSUPPORT_MULTISERVICE_ON_WAN" != "" ] && [ "$TCSUPPORT_WAN_PTM" != "" -o "$TCSUPPORT_WAN_ETHER" != "" ] && [ "$isPTMETHER" = "1" ]; then
#yanbing: lcp-echo-failure from 60 to 5
PPP_PARAM="unit "$org_i""$serv_num" user $USERNAME password $PASSWORD nodetach holdoff 4 maxfail 0 usepeerdns lcp-echo-interval 10 lcp-echo-failure 5"
else
#yanbing: lcp-echo-failure from 60 to 5
PPP_PARAM="unit $i user $USERNAME password $PASSWORD nodetach holdoff 4 maxfail 0 usepeerdns lcp-echo-interval 10 lcp-echo-failure 5"
fi
elif [ "$MSTC_TELEFONICA_BRAZIL_LOCAL" != "" ] ; then
PPP_PARAM="unit $i user $USERNAME password $PASSWORD nodetach holdoff 4 maxfail 0 usepeerdns lcp-echo-interval 30 lcp-echo-failure 3"
elif [ "$MSTC_TELEFONICA_HGU_ARGENTINA" != "" ] ; then
echo "$PASSWORD" > /var/tmp/ppppasswd$i.conf
PPP_PARAM="unit $i user $USERNAME password fakepassword nodetach holdoff 5 maxfail 0 usepeerdns lcp-echo-interval 30 lcp-echo-failure 5"
elif [ "$MSTC_TELEFONICA_HGU_SPAIN" != "" ] ; then
PPP_PARAM="unit $i user $USERNAME password $PASSWORD nodetach holdoff 5 maxfail 0 usepeerdns lcp-echo-interval 30 lcp-echo-failure 5"
else
if [ "$TCSUPPORT_MULTISERVICE_ON_WAN" != "" ] && [ "$TCSUPPORT_WAN_PTM" != "" -o "$TCSUPPORT_WAN_ETHER" != "" ] && [ "$isPTMETHER" = "1" ]; then
PPP_PARAM="unit "$org_i""$serv_num" user $USERNAME password $PASSWORD nodetach holdoff 4 maxfail 0 usepeerdns lcp-echo-interval 1 lcp-echo-failure 60"
else
PPP_PARAM="unit $i user $USERNAME password $PASSWORD nodetach holdoff 4 maxfail 0 usepeerdns lcp-echo-interval 1 lcp-echo-failure 60"
fi
fi
fi #MSTC_TELEFONICA_UNIFYFW
if [ "$TCSUPPORT_WAN_GPON" != "" ] || [ "$TCSUPPORT_WAN_EPON" != "" ]; then
PPP_PARAM="$PPP_PARAM plugin pppoe nas$i"
if [ "$SRVNAME" != "" ] ; then
# PPP_PARAM="$PPP_PARAM rp_pppoe_service $SRVNAME"
PPP_PARAM="$PPP_PARAM pppoe_srv_name $SRVNAME"
fi
if [ "$AUTHEN" = "CHAP" ] ; then
PPP_PARAM="$PPP_PARAM -pap"
elif [ "$AUTHEN" = "PAP" ] ; then
# PPP_PARAM="$PPP_PARAM -chap -mschap -mschap-v2"
PPP_PARAM="$PPP_PARAM -chap"
fi
/sbin/ifconfig nas$i 0.0.0.0
else
if [ "$TCSUPPORT_WAN_ATM" != "" -o "$TCSUPPORT_WAN_PTM" != "" -o "$TCSUPPORT_WAN_ETHER" != "" ]; then
if [ "$isPTMETHER" = "1" ] ; then
PPP_PARAM="$PPP_PARAM plugin pppoe nas$i"
if [ "$SRVNAME" != "" ] ; then
PPP_PARAM="$PPP_PARAM rp_pppoe_service $SRVNAME"
fi
ENCAP=""
fi
fi
if [ "$ENCAP" = "PPPoE LLC" ] || [ "$ENCAP" = "PPPoE VC-Mux" ] ; then
PPP_PARAM="$PPP_PARAM plugin pppoe"
if [ "$SRVNAME" != "" ] ; then
PPP_PARAM="$PPP_PARAM rp_pppoe_service $SRVNAME"
fi
PPP_PARAM="$PPP_PARAM nas$i"
elif [ "$ENCAP" = "PPPoA LLC" ] ; then
PPP_PARAM="$PPP_PARAM plugin pppoa llc-encaps $VPI.$VCI"
elif [ "$ENCAP" = "PPPoA VC-Mux" ] ; then
PPP_PARAM="$PPP_PARAM plugin pppoa vc-encaps $VPI.$VCI"
fi
if [ "$TCSUPPORT_WAN_ATM" != "" -o "$TCSUPPORT_WAN_PTM" != "" -o "$TCSUPPORT_WAN_ETHER" != "" ]; then
if [ "$isPTMETHER" = "1" ] ; then
if [ "$AUTHEN" = "CHAP" ] ; then
PPP_PARAM="$PPP_PARAM -pap"
elif [ "$AUTHEN" = "PAP" ] ; then
PPP_PARAM="$PPP_PARAM -chap -mschap -mschap-v2"
fi
if [ "$TCSUPPORT_UNIQUEMAC" != "" ] ;then
if [ "$UNIQUEMAC_FLAG" = "1" ]; then
/sbin/ifconfig nas$i hw ether $UNIQUE_MAC
else
if [ "$WAN_MAC" != "" ]; then
/sbin/ifconfig nas$i hw ether $WAN_MAC
fi
fi
else
if [ "$TCSUPPORT_MULTISERVICE_ON_WAN" = "" ] || [ "$TCSUPPORT_WAN_PTM" = "" -a "$TCSUPPORT_WAN_ETHER" = "" ] || [ "$isPTMETHER" != "1" ] ;then
if [ "$WAN_MAC" != "" ]; then
/sbin/ifconfig nas$i hw ether $WAN_MAC
fi
fi
fi
/sbin/ifconfig nas$i 0.0.0.0
ENCAP=""
AUTHEN=""
fi
fi
# PPPoE
if [ "$ENCAP" = "PPPoE LLC" ] || [ "$ENCAP" = "PPPoE VC-Mux" ] ; then
if [ "$AUTHEN" = "CHAP" ] ; then
PPP_PARAM="$PPP_PARAM -pap"
elif [ "$AUTHEN" = "PAP" ] ; then
PPP_PARAM="$PPP_PARAM -chap -mschap -mschap-v2"
fi
if [ "$QOS" = "ubr" ] ; then
PCR_V="-p $PCR"
elif [ "$QOS" = "cbr" ] || [ "$QOS" = "rt-vbr" ] || [ "$QOS" = "nrt-vbr" ] ; then
PCR_V="-p $PCR -q $SCR -m $MBS"
fi
if [ "$ENCAP" = "PPPoE LLC" ] ; then
ENCAP_T="-e 0"
elif [ "$ENCAP" = "PPPoE VC-Mux" ] ; then
ENCAP_T="-e 1"
fi
br2684ctl -c $i $ENCAP_T -t $QOS $PCR_V -a 0.$VPI.$VCI &
echo $! > /var/run/nas$i.pid
sleep 1
if [ "$TCSUPPORT_UNIQUEMAC" != "" ] ;then
if [ "$UNIQUEMAC_FLAG" = "1" ]; then
/sbin/ifconfig nas$i hw ether $UNIQUE_MAC
else
if [ "$WAN_MAC" != "" ]; then
/sbin/ifconfig nas$i hw ether $WAN_MAC
fi
fi
else
if [ "$TCSUPPORT_MULTISERVICE_ON_WAN" = "" ] || [ "$TCSUPPORT_WAN_PTM" = "" -a "$TCSUPPORT_WAN_ETHER" = "" ] || [ "$isPTMETHER" != "1" ] ;then
if [ "$WAN_MAC" != "" ]; then
/sbin/ifconfig nas$i hw ether $WAN_MAC
fi
fi
fi
/sbin/ifconfig nas$i 0.0.0.0
/sbin/ifconfig nas$i -arp
# PPPoA
else
if [ "$AUTHEN" = "CHAP" ] ; then
PPP_PARAM="$PPP_PARAM -pap"
elif [ "$AUTHEN" = "PAP" ] ; then
PPP_PARAM="$PPP_PARAM -chap -mschap -mschap-v2"
fi
PCR_V=""
if [ "$QOS" = "ubr" ] ; then
PCR_V="qos UBR qos_pcr $PCR"
elif [ "$QOS" = "cbr" ] || [ "$QOS" = "rt-vbr" ] || [ "$QOS" = "nrt-vbr" ] ; then
if [ "$QOS" = "cbr" ] ; then
PCR_V="qos CBR"
elif [ "$QOS" = "rt-vbr" ] ; then
PCR_V="qos VBR"
elif [ "$QOS" = "nrt-vbr" ] ; then
PCR_V="qos NRTVBR"
fi
PCR_V="$PCR_V qos_pcr $PCR qos_scr $SCR qos_mbs $MBS"
fi
if [ "$TCSUPPORT_WAN_ATM" != "" -o "$TCSUPPORT_WAN_PTM" != "" -o "$TCSUPPORT_WAN_ETHER" != "" ]; then
if [ "$isPTMETHER" = "1" ] ; then
PCR_V=""
fi
fi
PPP_PARAM="$PPP_PARAM $PCR_V"
fi
fi
if [ "$DEFAULTROUTE" = "Yes" ] ; then
PPP_PARAM="$PPP_PARAM defaultroute"
fi
if [ "$PPPGETIP" = "Dynamic" ] ; then
PPP_PARAM="$PPP_PARAM noipdefault"
else
PPP_PARAM="$PPP_PARAM $IPADDR:$GATEWAY"
fi
if [ "$NETMASK" != "" ] ; then
PPP_PARAM="$PPP_PARAM netmask $NETMASK"
fi
if [ "$CONNECTION" = "Connect_on_Demand" ] ; then
# transform minute to second. shnwind 2008.4.17
IDLETIME=$(expr $CLOSEIFIDLE \* 60)
PPP_PARAM="$PPP_PARAM demand idle $IDLETIME"
else
PPP_PARAM="$PPP_PARAM persist"
fi
if [ "$MSTC_TELEFONICA_HGU_COLOMBIA" != "" ] ; then
if [ "$MTU" != "0" ] && [ "$MTU" != "" ] ; then
PPP_PARAM="$PPP_PARAM mtu $MTU"
else
PPP_PARAM="$PPP_PARAM mtu 1492"
fi
if [ "$MRU" != "0" ] && [ "$MRU" != "" ] ; then
PPP_PARAM="$PPP_PARAM mru $MRU"
else
PPP_PARAM="$PPP_PARAM mru 1492"
fi
else
if [ "$MTU" != "0" ] && [ "$MTU" != "" ] ; then
PPP_PARAM="$PPP_PARAM mtu $MTU mru $MTU"
else
PPP_PARAM="$PPP_PARAM mtu 1492 mru 1492"
fi
fi
if [ "$IPVERSION" = "IPv4/IPv6" ] ; then
echo 0 > /proc/sys/net/ipv6/conf/nas$i/accept_ra
strident=`/bin/maceui mac $WAN_MAC`
localIP="::$strident"
remoteIP="::22$i"
if [ "$CONNECTION" = "Connect_on_Demand" ] ; then
PPP_PARAM="$PPP_PARAM ipv6 $localIP,$remoteIP "
else
PPP_PARAM="$PPP_PARAM ipv6 $localIP, "
fi
elif [ "$IPVERSION" = "IPv6" ] ; then
echo 0 > /proc/sys/net/ipv6/conf/nas$i/accept_ra
strident=`/bin/maceui mac $WAN_MAC`
localIP="::$strident"
remoteIP="::22$i"
if [ "$CONNECTION" = "Connect_on_Demand" ] ; then
PPP_PARAM="$PPP_PARAM ipv6 $localIP,$remoteIP noip"
else
PPP_PARAM="$PPP_PARAM ipv6 $localIP, noip"
fi
fi
pppd $PPP_PARAM &
echo $! > /var/run/ppp$k.pid
echo "pppd $PPP_PARAM &" > /var/tmp/ppp$k.conf
if [ "$IPVERSION" != "IPv6" ] ; then
if [ "$MSTC_TELEFONICA_UNIFYFW" != "" ] ; then
UNIFYFW_COUNTRYCODE = "FF"
case `cat /proc/country` in
C4)
UNIFYFW_COUNTRYCODE = "C4"
;;
esac
if [ "$NATENABLE" = "Enable" ] || [ "$NATENABLE" = "FullNAT" -a "$UNIFYFW_COUNTRYCODE" = "C4" ]; then
if [ "$TCSUPPORT_MULTI_NAT" != "" ] ;then
iptables -t nat -A ADDRMAP_POS -j ADDRMAP_POS$i
fi
if [ "$TCSUPPORT_MULTISERVICE_ON_WAN" != "" ] && [ "$TCSUPPORT_WAN_PTM" != "" -o "$TCSUPPORT_WAN_ETHER" != "" ] && [ "$isPTMETHER" = "1" ]; then
iptables -t nat -A POSTROUTING -o ppp"$org_i""$serv_num" -j MASQUERADE
else
iptables -t nat -A POSTROUTING -o ppp$i -j MASQUERADE
fi
iptables -t nat -A PREROUTING -j VS_PRE$i
iptables -t nat -A PREROUTING -j DMZ_PRE$i
if [ "$TCSUPPORT_MULTI_NAT" != "" ] ;then
iptables -t filter -A ADDRMAP_FORWARD -j ADDRMAP_FORWARD$i
fi
if [ "$TCSUPPORT_PORT_TRIGGER" != "" ] ;then
if [ "$TCSUPPORT_MULTISERVICE_ON_WAN" != "" ] && [ "$TCSUPPORT_WAN_PTM" != "" -o "$TCSUPPORT_WAN_ETHER" != "" ] && [ "$isPTMETHER" = "1" ]; then
iptables -t nat -A PREROUTING -i ppp"$org_i""$serv_num" -j PREROUTING_WAN
iptables -t filter -A FORWARD -i ppp"$org_i""$serv_num" -j FORWARD_WAN
else
iptables -t nat -A PREROUTING -i ppp$i -j PREROUTING_WAN
iptables -t filter -A FORWARD -i ppp$i -j FORWARD_WAN
fi
fi
fi
else #MSTC_TELEFONICA_UNIFYFW
if [ "$NATENABLE" = "Enable" ] || [ "$NATENABLE" = "FullNAT" -a "$MSTC_COLOMBIA_SPECIAL_IPADDRMAP" != "" ]; then
if [ "$TCSUPPORT_MULTI_NAT" != "" ] ;then
iptables -t nat -A ADDRMAP_POS -j ADDRMAP_POS$i
fi
if [ "$TCSUPPORT_MULTISERVICE_ON_WAN" != "" ] && [ "$TCSUPPORT_WAN_PTM" != "" -o "$TCSUPPORT_WAN_ETHER" != "" ] && [ "$isPTMETHER" = "1" ]; then
iptables -t nat -A POSTROUTING -o ppp"$org_i""$serv_num" -j MASQUERADE
else
iptables -t nat -A POSTROUTING -o ppp$i -j MASQUERADE
fi
iptables -t nat -A PREROUTING -j VS_PRE$i
iptables -t nat -A PREROUTING -j DMZ_PRE$i
if [ "$TCSUPPORT_MULTI_NAT" != "" ] ;then
iptables -t filter -A ADDRMAP_FORWARD -j ADDRMAP_FORWARD$i
fi
if [ "$TCSUPPORT_PORT_TRIGGER" != "" ] ;then
if [ "$TCSUPPORT_MULTISERVICE_ON_WAN" != "" ] && [ "$TCSUPPORT_WAN_PTM" != "" -o "$TCSUPPORT_WAN_ETHER" != "" ] && [ "$isPTMETHER" = "1" ]; then
iptables -t nat -A PREROUTING -i ppp"$org_i""$serv_num" -j PREROUTING_WAN
iptables -t filter -A FORWARD -i ppp"$org_i""$serv_num" -j FORWARD_WAN
else
iptables -t nat -A PREROUTING -i ppp$i -j PREROUTING_WAN
iptables -t filter -A FORWARD -i ppp$i -j FORWARD_WAN
fi
fi
fi
fi #MSTC_TELEFONICA_UNIFYFW
fi
if [ "$TCSUPPORT_DHCP_NOFORWARD" != "" ] ;then
if [ "$TCSUPPORT_MULTISERVICE_ON_WAN" != "" ] && [ "$TCSUPPORT_WAN_PTM" != "" -o "$TCSUPPORT_WAN_ETHER" != "" ] && [ "$isPTMETHER" = "1" ]; then
iptables -t filter -I FORWARD -o ppp"$org_i""$serv_num" -p udp --sport 67 -j DROP
else
iptables -t filter -I FORWARD -o ppp$i -p udp --sport 67 -j DROP
fi
fi
if [ "$TCSUPPORT_MULTISERVICE_ON_WAN" != "" ] && [ "$TCSUPPORT_WAN_PTM" != "" -o "$TCSUPPORT_WAN_ETHER" != "" ] && [ "$isPTMETHER" = "1" ]; then
WAN_IF=ppp"$org_i""$serv_num"
else
WAN_IF=ppp$i
fi
# feature added by rclv 20100536 for ipv6 options
fi
#end of code added by rclv
if [ "$IPVERSION" == "IPv4" ] ; then
echo 1 > /proc/sys/net/ipv6/conf/nas$i/disable_ipv6
fi
elif [ $ISP = "3" ] ; then
if [ "$TCSUPPORT_WAN_GPON" != "" ] || [ "$TCSUPPORT_WAN_EPON" != "" ]; then
if [ "$EtherWan" = "-1" ]; then
/usr/bin/smuxctl add bridge pon nas$i
else
/usr/bin/smuxctl add bridge nas10 nas$i
fi
else
if [ "$TCSUPPORT_MULTISERVICE_ON_WAN" != "" ] && [ "$TCSUPPORT_WAN_PTM" != "" -o "$TCSUPPORT_WAN_ETHER" != "" ] && [ "$isPTMETHER" = "1" ]; then
/usr/bin/smuxctl add bridge nas$org_i nas$i
fi
fi
if [ "$TCSUPPORT_CZ_GENERAL" != "" ] ;then
if [ "$IPVERSION" != "IPv4" ] ; then
ebtables -t filter -A OUTPUT -o nas$i -p IPv6 --ip6-proto 58 --ip6-icmpv6type 134 -j DROP
fi
fi
if [ "$TCSUPPORT_WAN_GPON" = "" ] && [ "$TCSUPPORT_WAN_EPON" = "" ]; then
if [ "$QOS" = "ubr" ] ; then
PCR_V="-p $PCR"
elif [ "$QOS" = "cbr" ] || [ "$QOS" = "rt-vbr" ] || [ "$QOS" = "nrt-vbr" ] ; then
PCR_V="-p $PCR -q $SCR -m $MBS"
fi
if [ "$ENCAP" = "1483 Bridged Only LLC" ] ; then
ENCAP_T="-e 0"
elif [ "$ENCAP" = "1483 Bridged Only VC-Mux" ] ; then
ENCAP_T="-e 1"
fi
if [ "$TCSUPPORT_WAN_ATM" != "" -o "$TCSUPPORT_WAN_PTM" != "" -o "$TCSUPPORT_WAN_ETHER" != "" ]; then
#ATM only
if [ "$isPTMETHER" = "0" ] ; then
br2684ctl -c $i $ENCAP_T -t $QOS $PCR_V -a 0.$VPI.$VCI &
echo $! > /var/run/nas$i.pid
sleep 1
fi
else
br2684ctl -c $i $ENCAP_T -t $QOS $PCR_V -a 0.$VPI.$VCI &
echo $! > /var/run/nas$i.pid
sleep 1
fi
if [ "$TCSUPPORT_UNIQUEMAC" != "" ] ;then
if [ "$UNIQUEMAC_FLAG" = "1" ]; then
if [ "$LAN_MAC" != "" ]; then
/sbin/ifconfig nas$i hw ether $LAN_MAC
fi
else
if [ "$WAN_MAC" != "" ]; then
/sbin/ifconfig nas$i hw ether $WAN_MAC
fi
fi
else
if [ "$TCSUPPORT_MULTISERVICE_ON_WAN" = "" ] || [ "$TCSUPPORT_WAN_PTM" = "" -a "$TCSUPPORT_WAN_ETHER" = "" ] || [ "$isPTMETHER" != "1" ] ;then
if [ "$WAN_MAC" != "" ]; then
/sbin/ifconfig nas$i hw ether $WAN_MAC
fi
fi
fi
fi
if [ "$MSTC_FIXED_WAN_MAC" != "" ] && [ "$WanMacForPVC" != "" ];then
/sbin/ifconfig nas$i hw ether $WanMacForPVC
fi
/sbin/ifconfig nas$i 0.0.0.0
brctl addif br0 nas$i
WAN_IF=nas$i
ebtables -t filter -A INPUT -i nas$i -p IPv4 --ip-proto 17 --ip-dport 67 -j DROP
ebtables -t filter -A INPUT -i nas$i -p IPv6 --ip6-proto 17 --ip6-dport 547 -j DROP
fi
#jrchen
# if [ "$IPVERSION" = "IPv4/IPv6" ] ; then
# sleep 1
# /sbin/ifconfig $WAN_IF inet6 $IPADDR6/$PREFIX6
# sleep 1
# route -A inet6 add default gw $DEFGATEWAY6 dev $WAN_IF &
# fi
/usr/script/ether_mac.sh &
if [ $ISP = "2" ] ; then
if [ "$CONNECTION" != "Connect_Manually" ] ; then
if [ $BridgeInterface = "Yes" ] ; then
echo 1 > /var/run/pass-through_nas$i.conf
brctl addif br0 nas$i
ebtables -t broute -D BROUTING -i nas$i -p ! 0x8863 -j poebrnas$i >/dev/null 2>/dev/null
ebtables -t broute -X poebrnas$i >/dev/null 2>/dev/null
ebtables -t broute -N poebrnas$i >/dev/null 2>/dev/null
ebtables -t broute -P poebrnas$i RETURN >/dev/null 2>/dev/null
ebtables -t broute -I poebrnas$i 1 -i nas$i -p ! 0x8864 -j DROP >/dev/null 2>/dev/null
ebtables -t broute -I BROUTING 1 -i nas$i -p ! 0x8863 -j poebrnas$i >/dev/null 2>/dev/null
ebtables -t nat -D POSTROUTING -o nas$i -p ! 0x8863 -j poebrnas$i >/dev/null 2>/dev/null
ebtables -t nat -X poebrnas$i >/dev/null 2>/dev/null
ebtables -t nat -N poebrnas$i >/dev/null 2>/dev/null
ebtables -t nat -P poebrnas$i RETURN >/dev/null 2>/dev/null
ebtables -t nat -I poebrnas$i 1 -o nas$i -p ! 0x8864 -j DROP >/dev/null 2>/dev/null
ebtables -t nat -I POSTROUTING 1 -o nas$i -p ! 0x8863 -j poebrnas$i >/dev/null 2>/dev/null
fi
fi
fi
/usr/bin/qoscmd dev add nas$i &
#FW_CONF=/etc/firewall.conf
#if [ -f $FW_CONF ]; then
# chmod +x $FW_CONF
# . $FW_CONF
# if [ "$spi_status" = "1" ]; then
# echo spi status
# /usr/bin/iptables -A SPI_FW -i $WAN_IF -m state --state NEW,INVALID -j DROP
# echo spi status2
# /usr/bin/iptables -A SPI_FW -i $WAN_IF -p icmp --icmp-type echo-request -j DROP
# fi
#fi
#/usr/script/ipfilter_start.sh #wtw add
#if [ "$TCSUPPORT_CZ_OTE" != "" ] ;then
# if [ $ISP != "3" ] ; then
# iptables -t filter -A DNS_chain -i $WAN_IF -p udp --dport 53 -j DROP
# fi
#fi