Zdarzyło mi się to już dwa razy. Zainstalowałem Debiana z sieci z jednym środowiskiem XFCE (bez GNOME), poprzez sconfigurowany wlan w pliku /etc/network/interfaces
auto wlan0
iface wlan0 inet dhcp
wpa-ssid Nazwa sieci
wpa-psk Haslo do sieci
Debian działał bardzo dobrze, sieć startowała automatycznie poprzez interfaces (nie chciałem instalować menadżera sieci gdyż nie ma dedykowanego dla XFCE). Potem postanowiłem postawić firewalla używając iptables. Nie jestem ekspertem w sieciach jak i w iptables ale poszperałem i zastoswałem takiego gotowca. Ma dosyć mocne ustawienia, jak się orientuję, ale nie jestem pewien reguł.
#!/bin/bash
### BEGIN INIT INFO
# Provides: firewall.sh
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
# CZYSZCZENIE STARYCH REGUŁ
iptables -F
iptables -X
iptables -F -t nat
iptables -X -t nat
iptables -F -t filter
iptables -X -t filter
# USTAWIENIE POLITYKI DZIAŁANIA
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p icmp --icmp-type echo-request -j REJECT --reject-with icmp-host-unreachable
# OCHRONA PRZED SKANOWANIEM ACK SCAN
iptables -A INPUT -m conntrack --ctstate NEW -p tcp --tcp-flags SYN,RST,ACK,FIN,URG,PSH ACK -j LOG --log-prefix "ACK scan: "
iptables -A INPUT -m conntrack --ctstate NEW -p tcp --tcp-flags SYN,RST,ACK,FIN,URG,PSH ACK -j DROP # Metoda ACK (nmap -sA)
#OCHRONA PRZED SKANOWANIEM FIN SCAN
iptables -A INPUT -m conntrack --ctstate NEW -p tcp --tcp-flags SYN,RST,ACK,FIN,URG,PSH FIN -j LOG --log-prefix "FIN scan: "
iptables -A INPUT -m conntrack --ctstate NEW -p tcp --tcp-flags SYN,RST,ACK,FIN,URG,PSH FIN -j DROP # Skanowanie FIN (nmap -sF)
#OCHRONA PRZED SKANOWANIEM XMAS TREE SCAN
iptables -A INPUT -m conntrack --ctstate NEW -p tcp --tcp-flags SYN,RST,ACK,FIN,URG,PSH PSH -j LOG --log-prefix "Xmas scan: "
iptables -A INPUT -m conntrack --ctstate NEW -p tcp --tcp-flags SYN,RST,ACK,FIN,URG,PSH FIN,URG,PSH -j DROP # Metoda Xmas Tree (nmap -sX)
#OCHRONA PRZED SKANOWANIEM NULL SCAN
iptables -A INPUT -m conntrack --ctstate INVALID -p tcp ! --tcp-flags SYN,RST,ACK,FIN,PSH,URG SYN,RST,ACK,FIN,PSH,URG -j LOG --log-prefix "Null scan: "
#OCHRONA PRZED ATAKIEM Dos
iptables -A INPUT -m conntrack --ctstate INVALID -p tcp ! --tcp-flags SYN,RST,ACK,FIN,PSH,URG SYN,RST
iptables -N syn-flood
iptables -A INPUT -p tcp --syn -j syn-flood
iptables -A syn-flood -m limit --limit 1/s --limit-burst 4 -j RETURN
iptables -A syn-flood -m limit --limit 1/s --limit-burst 4 -j LOG --log-prefix "SYN-flood: "
iptables -A syn-flood -j DROP
# OCHRONA PRZED ATAKIEM PING OF DEATH
iptables -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1/s -j LOG --log-prefix "Ping: "
iptables -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT # Ping of death
# ZABLOKOWANIE PINGOWANIA
iptables -A INPUT -p icmp --icmp-type echo-request -j REJECT --reject-with icmp-host-unreachable
# BLOKOWANIE TELNETU
iptables -A OUTPUT -p tcp --dport telnet -j REJECT
iptables -A INPUT -p tcp --dport telnet -j REJECT
#ZAPIS DO LOGA ODRZUCONYCH PAKIETÓW PRZYCHODZĄCYCH W KATALOGU var/log/messages
iptables -N LOGGING
iptables -A INPUT -j LOGGING
iptables -A LOGGING -m limit --limit 2/min -j LOG --log-prefix "IPTables-Dropped: " --log-level 4
iptables -A LOGGING -j DROP
Zapisuje skrypt do pliku a potem w terminalu daje
sudo cp firewall /etc/init.d/
chmod +x /etc/init.d/firewall
update-rc.d firewall defaults 90
Być może problem jest z update-rc firewall defaults 90 (czy na pewno 90?) druga sprawa czy sieć startuje z pliku interfaces pierwsza a potem reguły z init.d. Nie wiem co się dzieje. Wydaje się, że ten gotowiec jest całkiem niezły.