]> git.stg.codes - stg.git/blob - projects/stargazer/scripts/shaper_vpn_radius/firewall/firewall
Fix trailing whitespaces.
[stg.git] / projects / stargazer / scripts / shaper_vpn_radius / firewall / firewall
1 #!/bin/bash
2
3 #adsl-start
4
5 modprobe ip_queue
6
7 int_addr=10.0.0.2
8 ext_addr=192.168.1.34
9
10 int_net=10.0.0.0/16
11 ext_net=192.168.1.0/24
12
13 echo 1 > /proc/sys/net/ipv4/ip_forward
14
15 iptables -P INPUT DROP
16 iptables -P OUTPUT ACCEPT
17 iptables -P FORWARD ACCEPT
18
19 iptables -t nat -F
20 iptables -t filter -F
21
22 #
23 #iptables -A INPUT  -d $ip1 -j ACCEPT
24 #iptables -A OUTPUT -s $ip1 -j ACCEPT
25
26 # Разрешам говорить самому с собой
27 iptables -A INPUT  -d 127.0.0.1 -j ACCEPT
28 iptables -A OUTPUT -s 127.0.0.1 -j ACCEPT
29
30 #iptables -A INPUT  -d $ip4 -j ACCEPT
31 #iptables -A INPUT  -s $ip4 -j ACCEPT
32 #iptables -A OUTPUT -s $ip4 -j ACCEPT
33 #iptables -A OUTPUT -d $ip4 -j ACCEPT
34
35 iptables -A INPUT  -p icmp -j ACCEPT
36 iptables -A OUTPUT -p icmp -j ACCEPT
37
38 iptables -A INPUT  -p 47 -j ACCEPT
39 iptables -A FORWARD -p 47 -j ACCEPT
40 iptables -A OUTPUT -p 47 -j ACCEPT
41
42 #SSH On this machine
43 iptables -A INPUT  -p tcp -d $int_addr --dport 22 -j ACCEPT
44 iptables -A OUTPUT -p tcp -s $int_addr --sport 22 -j ACCEPT
45 iptables -A INPUT  -p tcp -d $ext_addr --dport 22 -j ACCEPT
46 iptables -A OUTPUT -p tcp -s $ext_addr --sport 22 -j ACCEPT
47
48 #WEB On this machine
49 #iptables -A INPUT  -p tcp -d $ip2 --dport 80 -j ACCEPT
50 #iptables -A OUTPUT -p tcp -s $ip2 --sport 80 -j ACCEPT
51 #iptables -A INPUT  -p tcp -d $ip3 --dport 80 -j ACCEPT
52 #iptables -A OUTPUT -p tcp -s $ip3 --sport 80 -j ACCEPT
53
54 #PPTP
55 iptables -A INPUT   -p tcp --dport 1723 -j ACCEPT
56 iptables -A OUTPUT  -p tcp --sport 1723 -j ACCEPT
57 iptables -A INPUT  -p udp --dport 1723 -j ACCEPT
58 iptables -A OUTPUT -p udp --sport 1723 -j ACCEPT
59
60 #FTP
61 #iptables -A INPUT  -p tcp -d $ip2 -j ACCEPT
62 #iptables -A OUTPUT -p tcp -s $ip2 -j ACCEPT
63 #iptables -A INPUT  -p tcp -d $ip3 -j ACCEPT
64 #iptables -A OUTPUT -p tcp -s $ip3 -j ACCEPT
65
66 #iptables -A INPUT  -p tcp -d $ip2 --dport 20:21 -j ACCEPT
67 #iptables -A OUTPUT -p tcp -s $ip2 --sport 20:21 -j ACCEPT
68 #iptables -A INPUT  -p tcp -d $ip3 --dport 20:21 -j ACCEPT
69 #iptables -A OUTPUT -p tcp -s $ip3 --sport 20:21 -j ACCEPT
70
71 #iptables -A INPUT  -p tcp -d $ip2 --dport 1024:65535 --sport 1024:65535 -j ACCEPT
72 #iptables -A INPUT  -p tcp -d $ip3 --dport 1024:65535 --sport 1024:65535 -j ACCEPT
73 #iptables -A OUTPUT -p tcp -s $ip2 --sport 1024:65535 --dport 1024:65535 -j ACCEPT
74 #iptables -A OUTPUT -p tcp -s $ip3 --sport 1024:65535 --dport 1024:65535 -j ACCEPT
75
76 #DNS
77 iptables -A INPUT  -p tcp --sport 53 -j ACCEPT
78 iptables -A OUTPUT -p tcp --dport 53 -j ACCEPT
79 iptables -A INPUT  -p udp --sport 53 -j ACCEPT
80 iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
81
82 #iptables -t nat -A PREROUTING -p tcp -d $ip1 --dport 80 -j ACCEPT
83 #iptables -t nat -A PREROUTING -p tcp -d $ip2 --dport 80 -j ACCEPT
84 #iptables -t nat -A PREROUTING -p tcp -d $ip3 --dport 80 -j ACCEPT
85 #iptables -t nat -A PREROUTING -p tcp -d $ip4 --dport 80 -j ACCEPT
86
87 #iptables -t nat -A PREROUTING -p tcp -s 192.168.1.7 -j ACCEPT
88 #iptables -t nat -A PREROUTING -p tcp -s 192.168.1.16 -j ACCEPT
89 #iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 3128
90
91 iptables -t nat -A POSTROUTING -d 0.0.0.0/0 -s 192.168.2.0/24 -j MASQUERADE
92
93
94