blob: 1c9b82e6b30b2614f2c14f27d9b750a427858f70 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#!/bin/sh
2#
3# $Id: nat.sh,v 1.4 2009-12-09 08:45:37 steven Exp $
4#
5# usage: nat.sh
6#
7
8path_sh=`nv get path_sh`
9. $path_sh/global.sh
10echo "Info: nat.sh start " >> $test_log
11
12ZTE_FORWARD_CHAIN=port_forward
13ZTE_DMZ_CHAIN=DMZ
14ZTE_MAPPING_CHAIN=port_mapping
15
16iptables -P INPUT ACCEPT
17iptables -P OUTPUT ACCEPT
18iptables -P FORWARD ACCEPT
19
20#clear nat
21iptables -t nat -F
22iptables -t nat -X $ZTE_FORWARD_CHAIN
23iptables -t nat -X $ZTE_DMZ_CHAIN
24iptables -t nat -X $ZTE_MAPPING_CHAIN
25
26
27#Make a new chain for nat
28iptables -t nat -N $ZTE_FORWARD_CHAIN
29iptables -t nat -N $ZTE_DMZ_CHAIN
30iptables -t nat -N $ZTE_MAPPING_CHAIN
31
32iptables -t nat -I PREROUTING 1 -j $ZTE_FORWARD_CHAIN
33iptables -t nat -I PREROUTING 1 -j $ZTE_DMZ_CHAIN
34iptables -t nat -I PREROUTING 1 -j $ZTE_MAPPING_CHAIN
35
36 lan_en=`nv get LanEnable`
37 nat_en=`nv get natenable`
38 if [ "-$nat_en" != "-0" -a "-$lan_en" == "-2" ]; then
39 iptables -t nat -A POSTROUTING -o ${defwan_rel%:*} -j MASQUERADE
40 elif [ "-$nat_en" != "-0" -a "-$lan_en" != "-0" ]; then
41 iptables -t nat -A POSTROUTING -o $defwan_rel -j MASQUERADE
42 fi
43
44clat46_en=1
45 if [ "-$clat46_en" = "-1" ]; then
46 iptables -t nat -A POSTROUTING -o clat4 -j MASQUERADE
47 fi
48
49