-
Notifications
You must be signed in to change notification settings - Fork 0
/
ipt.sh
48 lines (37 loc) · 1001 Bytes
/
ipt.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#! /bin/bash
EXTIF=$1
INIF=""
INNET=""
iptables -F
iptables -X
iptables -Z
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -p icmp -j ACCEPT
iptables -A OUTPUT -p icmp -j ACCEPT
if [ -f ipt_deny.sh ]; then
sh ipt_deny.sh
fi
if [ -f ipt_allow.sh ]; then
sh ipt_allow.sh
fi
if [ -f ipt_http.sh ]; then
sh ipt_http.sh
fi
iptables -A INPUT -i $EXTIF -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -i $EXTIF -p udp --dport 1701 -j ACCEPT
iptables -A INPUT -i $EXTIF -p udp --dport 500 -j ACCEPT
iptables -A INPUT -i $EXTIF -p udp --dport 4500 -j ACCEPT
# NAT
iptables -F -t nat
iptables -X -t nat
iptables -Z -t nat
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT
#iptables -A INPUT -i $INIF -j ACCEPT
iptables -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE
service iptables save