|
1 #! /bin/sh
2
3 trusthost='192.168.10.100'
4 myhost='192.168.20.200'
5 any='0.0.0.0/0'
6
7 ##############
8 #Flush & Reset
9 ##############
10 iptables -F
11 iptables -X
12 ##############
13 #Deafult Rule
14 ##############
15 iptables -P INPUT DROP
16 iptables -P OUTPUT DROP
17 iptables -P FORWARD DROP
18 #########
19 #loopback
20 #########
21 iptables -A INPUT -i lo -j ACCEPT
22 iptables -A OUTPUT -o lo -j ACCEPT
23 #######################
24 #ICMP trusthost->myhost
25 #######################
26 iptables -A INPUT -p icmp --icmp-type echo-request -s $trusthost -d $myhost -j ACCEPT
27 iptables -A OUTPUT -p icmp --icmp-type echo-reply -s $myhost -d $trusthost -j ACCEPT
28 #######################
29 #ICMP myhost->trusthost
30 #######################\
31 iptables -A OUTPUT -p icmp --icmp-type echo-request -s $myhost -d $trusthost -j ACCEPT
32 iptables -A INPUT -p icmp --icmp-type echo-reply -s $trusthost -d $myhost -j ACCEPT
33 #######################
34 #ssh trusthost-> myhost
35 #######################
36 iptables -A INPUT -p tcp -s $trusthost -d $myhost --dport 22 -j ACCEPT
37 iptables -A OUTPUT -p tcp -s $myhost --sport 22 -d $trusthost -j ACCEPT
38 #################
39 #www ANY-> myhost
40 #################
41 iptables -A INPUT -p tcp -s $any -d $myhost --dport 80 -j ACCEPT
42 iptables -A OUTPUT -p tcp -s $myhost --sport 80 -d $any -j ACCEPT
43 #########
44 #logging
45 #########
46 iptables -N LOGGING
47 iptables -A LOGGING -j LOG --log-level warning --log-prefix "DROP:" -m limit
48 iptables -A LOGGING -j DROP
49 iptables -A INPUT -j LOGGING
50 iptables -A OUTPUT -j LOGGING |
|