Gék wordt je van IPTABLES. Ik heb op mijn eigen webserver een firewall, welke naar mijn idee zeer redelijk draait.
Dezelfde firewall heb ik gepoot op een oude machine, werkt prima.
Dezelfde firewall heb ik gepoot op een server, werkt prima, maar ipt_recent barft!
De originele firewall:
Bovenstaande firewall werkt perfect. Ik wil wél graag aanpassingen weten als iemand nog tips heeft!
Edoch, uit bovenstaande firewall kwam onderstaande rollen:
Deze firewall lijkt te werken, maar gaat nat op de onderste 4 regels:
Waar de "lightning" (mijn webserver) het perfect doet, doet deze firewall ("IL2") het niet. Het enige grote verschil is de kernel. De Lightning draait met Linux diedx.nl 2.6.8, de IL2 met Linux linux.imagelibrary.com 2.4.27. Maar dat is toch dezelfde Netfilter config?
aargh?! Wie ziet de fout? Ik heb reeds gegoogled, maar 4 hits, en alle 4 meer broncode dan oplossing!
Dezelfde firewall heb ik gepoot op een oude machine, werkt prima.
Dezelfde firewall heb ik gepoot op een server, werkt prima, maar ipt_recent barft!
De originele firewall:
code:
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
| #!/bin/bash
#############################
# DiedX Firewall #
#############################
ALL="0.0.0.0/0.0.0.0"
echo "Setting proc thingies"
if [ -f /proc/sys/net/ipv4/tcp_syncookies ]; then
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
fi
if [ -f /proc/sys/net/ipv4/ip_always_defrag ]; then
echo 1 > /proc/sys/net/ipv4/ip_always_defrag
fi
if [ -f /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts ]; then
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
fi
if [ -f /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses ]; then
echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
fi
if [ -f /proc/sys/net/ipv4/tcp_fin_timeout ]; then
echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout
fi
if [ -f /proc/sys/net/ipv4/tcp_syn_retries ]; then
echo 4 > /proc/sys/net/ipv4/tcp_syn_retries
fi
if [ -f /proc/sys/net/ipv4/tcp_retries2 ]; then
echo 7 > /proc/sys/net/ipv4/tcp_retries2
fi
if [ -f /proc/sys/net/ipv4/tcp_keepalive_time ]; then
echo 300 > /proc/sys/net/ipv4/tcp_keepalive_time
fi
if [ -f /proc/sys/net/ipv4/tcp_keepalive_intvl ]; then
echo 30 > /proc/sys/net/ipv4/tcp_keepalive_intvl
fi
echo "Ok, proc thingy set!"
echo "Resetting WHOLE firewall thing"
iptables -F
iptables -X
echo "Done. Creating some loopback devices!"
iptables -A INPUT -s ALL -d ALL -i lo -j ACCEPT
iptables -A OUTPUT -s ALL -d ALL -o lo -j ACCEPT
echo "Done. Creating trusted networks!"
echo "ddh.nl"
iptables -A INPUT -s ddh.nl -j ACCEPT
echo "Thunder!"
iptables -A INPUT -s 62.59.28.75 -j ACCEPT
echo "IL2!"
iptables -A INPUT -s 62.221.212.184 -j ACCEPT
echo "Home..."
iptables -A INPUT -s 80.56.219.152 -j ACCEPT
iptables -A OUTPUT -s 80.56.219.152 -j ACCEPT
echo "Work"
iptables -A INPUT -s 82.92.45.10 -j ACCEPT
iptables -A OUTPUT -s 82.92.45.10 -j ACCEPT
# Testing my day away!
iptables -A INPUT -m recent --update --seconds 60 -j DROP
echo "Opening up some shizzle!"
echo "Opening FTP (yeah, sux!)"
iptables -A INPUT --protocol tcp -s ${ALL} --destination-port 21 -j ACCEPT
iptables -A INPUT --protocol udp -s ${ALL} --destination-port 21 -j ACCEPT
echo "Opening SMTP (It must die)"
iptables -A INPUT --protocol tcp -s ${ALL} --destination-port 25 -j ACCEPT
echo "Opening HTTP"
iptables -A INPUT --protocol tcp -s ${ALL} --destination-port 80 -j ACCEPT
iptables -A INPUT --protocol udp -s ${ALL} --destination-port 80 -j ACCEPT
echo "Opening DNS!"
iptables -A INPUT --protocol tcp -s ${ALL} --destination-port 53 -j ACCEPT
iptables -A INPUT --protocol udp -s ${ALL} --destination-port 53 -j ACCEPT
iptables -A INPUT -p udp --source-port 53 -j ACCEPT
iptables -A OUTPUT -p udp --source-port 53 -j ACCEPT
echo "Opening POP3"
iptables -A INPUT --protocol tcp -s ${ALL} --destination-port 110 -j ACCEPT
iptables -A INPUT --protocol udp -s ${ALL} --destination-port 110 -j ACCEPT
echo "Opening AUTH"
iptables -A INPUT --protocol tcp -s ${ALL} --destination-port 113 -j ACCEPT
iptables -A INPUT --protocol udp -s ${ALL} --destination-port 113 -j ACCEPT
echo "Opening IMAP"
iptables -A INPUT --protocol tcp -s ${ALL} --destination-port 113 -j ACCEPT
iptables -A INPUT --protocol udp -s ${ALL} --destination-port 113 -j ACCEPT
echo "Opening HTTPS"
iptables -A INPUT --protocol tcp -s ${ALL} --destination-port 443 -j ACCEPT
iptables -A INPUT --protocol udp -s ${ALL} --destination-port 443 -j ACCEPT
echo "Opening SMTPS"
iptables -A INPUT --protocol tcp -s ${ALL} --destination-port 465 -j ACCEPT
iptables -A INPUT --protocol udp -s ${ALL} --destination-port 465 -j ACCEPT
echo "Opening IMAPS"
iptables -A INPUT --protocol tcp -s ${ALL} --destination-port 993 -j ACCEPT
iptables -A INPUT --protocol udp -s ${ALL} --destination-port 993 -j ACCEPT
echo "Shutting down illegal networks"
iptables -A INPUT -s 10.0.0.0/8 -d 62.59.28.75/8 -j REJECT
iptables -A INPUT -s 172.16.0.0/12 -d 62.59.28.75/8 -j REJECT
iptables -A INPUT -s 192.168.0.0/16 -d 62.59.28.75/8 -j REJECT
iptables -A INPUT -s 127.0.0.0/8 -d 62.59.28.75/8 -j REJECT
# Testing SYN geblaat! (http://the-devil.dnsalias.net/home/extremist)
ILIMIT="-m limit --limit 3/m"
LOGLEVEL="info"
INT="eth0"
iptables -A INPUT -i $INT -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP
iptables -A INPUT -i $INT -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
iptables -A INPUT -i $INT -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
iptables -A INPUT -i $INT -p tcp --tcp-flags ALL FIN -j DROP
iptables -A INPUT -i $INT -p tcp --tcp-flags ALL ALL -j DROP
iptables -A INPUT -i $INT -p tcp --tcp-flags ALL NONE -j DROP
iptables -A INPUT -i $INT -p tcp --tcp-flags FIN,RST FIN,RST -j DROP
iptables -A INPUT -i $INT -p tcp --tcp-flags ACK,FIN FIN -j DROP
iptables -A INPUT -i $INT -p tcp --tcp-flags ACK,PSH PSH -j DROP
iptables -A INPUT -i $INT -p tcp --tcp-flags ACK,URG URG -j DROP
iptables -A INPUT -i $INT -p tcp --tcp-option 64 -j DROP
iptables -A INPUT -i $INT -p tcp --tcp-option 128 -j DROP
echo "Making sure things WORK with related stuff!"
iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i eth0 -m state --state NEW,INVALID -m recent --set -j DROP
#Deze werken, maar zijn even NIET interessant!
#iptables -A INPUT -i eth0 -m state --state NEW,INVALID -j LOG
#iptables -A INPUT -i eth0 -m state --state NEW,INVALID -j DROP |
Bovenstaande firewall werkt perfect. Ik wil wél graag aanpassingen weten als iemand nog tips heeft!
Edoch, uit bovenstaande firewall kwam onderstaande rollen:
code:
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
| #!/bin/bash
#############################
# DiedX Firewall #
#############################
ALL="0.0.0.0/0.0.0.0"
echo "Setting proc thingies"
if [ -f /proc/sys/net/ipv4/tcp_syncookies ]; then
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
fi
if [ -f /proc/sys/net/ipv4/ip_always_defrag ]; then
echo 1 > /proc/sys/net/ipv4/ip_always_defrag
fi
if [ -f /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts ]; then
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
fi
if [ -f /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses ]; then
echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
fi
if [ -f /proc/sys/net/ipv4/tcp_fin_timeout ]; then
echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout
fi
if [ -f /proc/sys/net/ipv4/tcp_syn_retries ]; then
echo 4 > /proc/sys/net/ipv4/tcp_syn_retries
fi
if [ -f /proc/sys/net/ipv4/tcp_retries2 ]; then
echo 7 > /proc/sys/net/ipv4/tcp_retries2
fi
if [ -f /proc/sys/net/ipv4/tcp_keepalive_time ]; then
echo 300 > /proc/sys/net/ipv4/tcp_keepalive_time
fi
if [ -f /proc/sys/net/ipv4/tcp_keepalive_intvl ]; then
echo 30 > /proc/sys/net/ipv4/tcp_keepalive_intvl
fi
echo "Ok, proc thingy set!"
echo "Resetting WHOLE firewall thing"
iptables -F
iptables -X
echo "Done. Creating some loopback devices!"
iptables -A INPUT -s ALL -d ALL -i lo -j ACCEPT
iptables -A OUTPUT -s ALL -d ALL -o lo -j ACCEPT
echo "Done. Creating trusted networks!"
echo "ddh.nl"
iptables -A INPUT -s ddh.nl -j ACCEPT
echo "Thunder!"
iptables -A INPUT -s 62.59.28.75 -j ACCEPT
echo "Lightning!"
iptables -A INPUT -s 213.239.177.50 -j ACCEPT
echo "Home..."
iptables -A INPUT -s 80.56.219.152 -j ACCEPT
iptables -A OUTPUT -s 80.56.219.152 -j ACCEPT
echo "Work"
iptables -A INPUT -s 82.92.45.10 -j ACCEPT
iptables -A OUTPUT -s 82.92.45.10 -j ACCEPT
# Testing my day away!
iptables -A INPUT -m recent --set -j DROP
#iptables -A INPUT -m recent --update --seconds 60 -j LOG
iptables -A INPUT -m recent --update --seconds 60 -j DROP
echo "Opening up some shizzle!"
echo "Opening FTP (yeah, sux!)"
iptables -A INPUT --protocol tcp -s ${ALL} --destination-port 21 -j ACCEPT
iptables -A INPUT --protocol udp -s ${ALL} --destination-port 21 -j ACCEPT
#echo "Opening SMTP (It must die)"
#iptables -A INPUT --protocol tcp -s ${ALL} --destination-port 25 -j ACCEPT
echo "Opening HTTP"
iptables -A INPUT --protocol tcp -s ${ALL} --destination-port 80 -j ACCEPT
iptables -A INPUT --protocol udp -s ${ALL} --destination-port 80 -j ACCEPT
echo "Opening AUTH"
iptables -A INPUT --protocol tcp -s ${ALL} --destination-port 113 -j ACCEPT
iptables -A INPUT --protocol udp -s ${ALL} --destination-port 113 -j ACCEPT
echo "Shutting down illegal networks"
iptables -A INPUT -s 10.0.0.0/8 -d 62.59.28.75/8 -j REJECT
iptables -A INPUT -s 172.16.0.0/12 -d 62.59.28.75/8 -j REJECT
iptables -A INPUT -s 192.168.0.0/16 -d 62.59.28.75/8 -j REJECT
iptables -A INPUT -s 127.0.0.0/8 -d 62.59.28.75/8 -j REJECT
# Testing SYN geblaat! (http://the-devil.dnsalias.net/home/extremist)
echo "Testing SYN!"
ILIMIT="-m limit --limit 3/m"
LOGLEVEL="info"
INT="eth0"
iptables -A INPUT -i $INT -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP
iptables -A INPUT -i $INT -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
iptables -A INPUT -i $INT -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
iptables -A INPUT -i $INT -p tcp --tcp-flags ALL FIN -j DROP
iptables -A INPUT -i $INT -p tcp --tcp-flags ALL ALL -j DROP
iptables -A INPUT -i $INT -p tcp --tcp-flags ALL NONE -j DROP
iptables -A INPUT -i $INT -p tcp --tcp-flags FIN,RST FIN,RST -j DROP
iptables -A INPUT -i $INT -p tcp --tcp-flags ACK,FIN FIN -j DROP
iptables -A INPUT -i $INT -p tcp --tcp-flags ACK,PSH PSH -j DROP
iptables -A INPUT -i $INT -p tcp --tcp-flags ACK,URG URG -j DROP
iptables -A INPUT -i $INT -p tcp --tcp-option 64 -j DROP
iptables -A INPUT -i $INT -p tcp --tcp-option 128 -j DROP
echo "Making sure things WORK with related stuff!"
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
echo "Closing up!"
iptables -A INPUT -m state --state NEW,INVALID -m recent --set -j DROP |
Deze firewall lijkt te werken, maar gaat nat op de onderste 4 regels:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| linux:~# ./firewall2 Setting proc thingies Ok, proc thingy set! Resetting WHOLE firewall thing Done. Creating some loopback devices! Done. Creating trusted networks! ddh.nl Thunder! Lightning! Home... Work Opening up some shizzle! Opening FTP (yeah, sux!) Opening HTTP Opening AUTH Shutting down illegal networks Testing SYN! Making sure things WORK with related stuff! iptables: No chain/target/match by that name Closing up! iptables: No chain/target/match by that name |
Waar de "lightning" (mijn webserver) het perfect doet, doet deze firewall ("IL2") het niet. Het enige grote verschil is de kernel. De Lightning draait met Linux diedx.nl 2.6.8, de IL2 met Linux linux.imagelibrary.com 2.4.27. Maar dat is toch dezelfde Netfilter config?
aargh?! Wie ziet de fout? Ik heb reeds gegoogled, maar 4 hits, en alle 4 meer broncode dan oplossing!
DiedX supports the Roland™, Sound Blaster™ and Ad Lib™ sound cards