Chciałbym abyście sprawdzili mój firewall nie jestem jeszcze super rozeznany w iptables, jednak firewall całkiem dobrze działa tylko mimo wszystko nie potrafię sobie poradzić z odblokowaniem portu dla SSH na zewnątrz i CS-a. Wydaje mi się że o czymś zapomniałem bo udało mi się tak zrobić że np. w putty wpisuję swoje zewnętrzne IP i port i mogę się logować ale z zewnątrz już to nie wychodzi. Tak samo jest z csem wcześniej nie mogłem się połączyć przez zewnętrzne IP ze swojego komputera, teraz mogę ale dla ludzi spoza mojej sieci i tak jest nie widoczny i już naprawdę nie wiem co robię źle. Moja sieć wygląda tak:
Kod: Zaznacz cały
DSL--->Ruter---->Serwer Linux z firewallem
Kod: Zaznacz cały
#!/bin/sh
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
iptables -F
iptables -X
iptables -F -t nat
iptables -X -t nat
iptables -F -t filter
iptables -X -t filter
iptables -F -t filter
iptables -X -t filter
iptables -F -t filter
iptables -X -t filter
iptables -F -t filter
iptables -X -t nat
iptables -F -t filter
iptables -X
iptables -F -t nat
iptables -X -t nat
iptables -F -t filter
iptables -A INPUT -i ! eth0 -j ACCEPT
iptables -A INPUT -p tcp --dport 20 -m state --state NEW -j ACCEPT
iptables -A INPUT -p tcp --dport 21 -m state --state NEW -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -j ACCEPT
iptables -A INPUT -p tcp --dport 3128 -m state --state NEW -j ACCEPT
iptables -A INPUT -p tcp --dport 59184 -m state --state NEW -j ACCEPT
iptables -A INPUT -i eth0 -p icmp --icmp-type echo-request -j ACCEPT
iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
iptables -t filter -A FORWARD -s 192.168.1.0/24 -d 0/0 -j ACCEPT
iptables -t filter -A FORWARD -s 0/0 -d 192.168.1.0/24 -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j MASQUERADE
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 3128
iptables -t nat -A POSTROUTING -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
iptables -t nat -A PRETOUTING -i eth0 -p tcp --dport 22 -j REDIRECT --to-port 59184
iptables -t nat -A PREROUTING -p udp -d xx.xx.xx.xx --dport 27010:27020 -j DNAT --to-destination 10.0.2.2:27015
iptables -t nat -A PREROUTING -p tcp -d xx.xx.xx.xx --dport 27010:27039 -j DNAT --to-destination 10.0.2.2:27015
iptables -t nat -A PREROUTING -p udp -d xx.xx.xx.xx --dport 1200 -j DNAT --to-destination 10.0.2.2:27015
iptables -A OUTPUT -p tcp --dport 27010:27039 -j ACCEPT
iptables -A INPUT -p udp --dport 27015 -j ACCEPT
iptables -A OUTPUT -p udp --dport 27010:27015 -j ACCEPT
iptables -A OUTPUT -p udp --sport 26900 -j ACCEPT
iptables -t nat -I PREROUTING -p tcp -d xx.xx.xx.xx --destination-port 27015 -j DNAT --to-destination 10.0.2.2:27015
iptables -t nat -I PREROUTING -p tcp --destination-port 27015 -j DNAT --to-destination 10.0.2.2:27015
iptables -t nat -I PREROUTING -p tcp --destination-port 59184 -j DNAT --to-destination 10.0.2.2:59184
iptables -t nat -I PREROUTING -p udp --destination-port 1200 -j DNAT --to-destination 10.0.2.2:27015
iptables -A INPUT -i eth0 -p tcp --dport 27015 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -d xx.xx.xx.xx --dport 59184 -j DNAT --to-destination 10.0.2.2:59184
iptables -t nat -A PREROUTING -i eth0 -p udp --dport 27015:27016 -j DNAT --to-destination 10.0.2.2
iptables -A INPUT -p udp --dport 27015:27016 -j ACCEPT
iptables -A FORWARD -p udp --dport 27015:27016 -j ACCEPT
echo "Firewall jest teraz uruchomiony"