* disable ikconfig by default
[openwrt.git] / package / iptables / files / firewall.awk
1 # Copyright (C) 2006 OpenWrt.org
2
3 BEGIN {
4 FS=":"
5 }
6
7 ($1 == "accept") || ($1 == "drop") || ($1 == "forward") {
8 delete _opt
9 str2data($2)
10 if ((_l["proto"] == "") && (_l["sport"] _l["dport"] != "")) {
11 _opt[0] = " -p tcp"
12 _opt[1] = " -p udp"
13 } else {
14 _opt[0] = ""
15 }
16 }
17
18 ($1 == "accept") {
19 target = " -j ACCEPT"
20 for (o in _opt) {
21 print "iptables -t nat -A prerouting_wan" _opt[o] str2ipt($2) target
22 print "iptables -A input_wan " _opt[o] str2ipt($2) target
23 print ""
24 }
25 }
26
27 ($1 == "drop") {
28 for (o in _opt) {
29 print "iptables -t nat -A prerouting_wan" _opt[o] str2ipt($2) " -j DROP"
30 print ""
31 }
32 }
33
34 ($1 == "forward") {
35 target = " -j DNAT --to " $3
36 fwopts = ""
37 if ($4 != "") {
38 if ((_l["proto"] == "tcp") || (_l["proto"] == "udp") || (_l["proto"] == "")) {
39 if (_l["proto"] != "") fwopts = " -p " _l["proto"]
40 fwopts = fwopts " --dport " $4
41 target = target ":" $4
42 }
43 else fwopts = ""
44 }
45 for (o in _opt) {
46 print "iptables -t nat -A prerouting_wan" _opt[o] str2ipt($2) target
47 print "iptables -A forwarding_wan " _opt[o] " -d " $3 fwopts " -j ACCEPT"
48 print ""
49 }
50 }
This page took 0.052649 seconds and 5 git commands to generate.