yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | test_log=`nv get telog_path` |
| 3 | if [ "$test_log" == "" ]; then |
| 4 | test_log=`nv get path_log`"te.log" |
| 5 | fi |
| 6 | echo "Info: psext_down.sh $1 start" >> $test_log |
| 7 | c_id=$1 |
| 8 | ps_if=`nv get pswan`$c_id |
| 9 | eth_if=`nv get "ps_ext"$c_id` |
| 10 | ext_br="br"$c_id |
| 11 | |
| 12 | #ɾ³ý¶ÔÓ¦µÄ·ÓɹæÔò |
| 13 | route_del() |
| 14 | { |
| 15 | pdp_ip=`nv get $ps_if"_pdp_ip"` |
| 16 | ps_ip=`nv get $ps_if"_ip"` |
| 17 | br_ip=`nv get $ext_br"_ip"` |
| 18 | marknum=`expr $c_id + 10` |
| 19 | rt_num=`expr $c_id + 100` |
| 20 | |
| 21 | iptables -t mangle -D PREROUTING -i $ext_br -j MARK --set-mark $marknum |
| 22 | ip rule del from $pdp_ip fwmark $marknum table $rt_num |
| 23 | ip route del default dev $ps_if table $rt_num |
| 24 | |
| 25 | marknum=`expr $c_id + 20` |
| 26 | rt_num=`expr $c_id + 120` |
| 27 | iptables -t mangle -D PREROUTING -i $ps_if -j MARK --set-mark $marknum |
| 28 | ip rule del to $pdp_ip fwmark $marknum table $rt_num |
| 29 | ip route del default dev $ext_br table $rt_num |
| 30 | #±¾µØÍøÂçÅäÖà |
| 31 | iptables -t nat -D POSTROUTING -s $ps_ip -o $ps_if -j SNAT --to $pdp_ip |
| 32 | if [ $? -ne 0 ];then |
| 33 | echo "cmd <<iptables -t nat -D POSTROUTING -s $ps_ip -o $ps_if -j SNAT --to $pdp_ip>> exec failed" >> $test_log |
| 34 | fi |
| 35 | route delete default dev $ps_if |
| 36 | if [ $? -ne 0 ];then |
| 37 | echo "cmd <<route delete default dev $ps_if>> exec failed" >> $test_log |
| 38 | fi |
| 39 | |
| 40 | ifconfig $ext_br 0.0.0.0 |
| 41 | ifconfig $ext_br down 2>>$test_log |
| 42 | if [ $? -ne 0 ];then |
| 43 | echo "Error: ifconfig $ext_br down failed." >> $test_log |
| 44 | fi |
| 45 | |
| 46 | ifconfig $ps_if 0.0.0.0 |
| 47 | ifconfig $ps_if down 2>>$test_log |
| 48 | if [ $? -ne 0 ];then |
| 49 | echo "Error: ifconfig $ps_if down failed." >> $test_log |
| 50 | fi |
| 51 | |
| 52 | #reset nv |
| 53 | nv set $ext_br"_ip"=0.0.0.0 |
| 54 | nv set $ext_br"_nm"=0.0.0.0 |
| 55 | nv set $ps_if"_pdp_ip"=0.0.0.0 |
| 56 | nv set $ps_if"_pridns"=0.0.0.0 |
| 57 | nv set $ps_if"_secdns"=0.0.0.0 |
| 58 | nv set $ps_if"_ip"=0.0.0.0 |
| 59 | } |
| 60 | tc_tbf.sh down $c_id |
| 61 | route_del |
| 62 | ifconfig $eth_if down |
| 63 | ifconfig $ext_br down |
| 64 | brctl delif $ext_br $eth_if |
| 65 | brctl delbr $ext_br |