Nowe posty

Autor Wątek: iptables blokuje?  (Przeczytany 3339 razy)

RolloTomassi

  • Gość
iptables blokuje?
« dnia: 2009-05-23, 00:58:20 »
Witam.

Mam problem z serwerem na SUSE 11.0

Jest on u kolegi w sieci za routerem, router ma otwarty forwarding na porcie 22 i widze serwer w jego sieci. Jednak nie moge go osiagnac! W sieci moge sie podlaczyc przez port 22 do serwera przy pomocy putty i moge sie zalogowac. Przez internet jednak nie jest to mozliwe! Przypuszczam, ze to ma cos wspólnego ze skryptem iptables, ale skrypt ktos mi kiedys napisal, a ja sie jeszcze na tyle nie znam, aby go dokladnie sprawdzic na bledy.

Móglby mi prosze ktos pomóc?

#!/bin/sh

# szukaj iptables
iptables=`which iptables`
 
# jak nie ma iptables to wyjsc
test -f $iptables || exit 0
 
case "$1" in
   start)
      echo "firewall wlaczony"
      # skasuj wszystkie reguly
      $iptables -t nat -F
      $iptables -t filter -F
      $iptables -X
 
      # nowe reguly
      $iptables -N garbage
      $iptables -I garbage -p TCP -j LOG --log-prefix="DROP TCP-Packet: " --log-level err
      $iptables -I garbage -p UDP -j LOG --log-prefix="DROP UDP-Packet: " --log-level err
      $iptables -I garbage -p ICMP -j LOG --log-prefix="DROP ICMP-Packet: " --log-level err
 
      # default Policy
      $iptables -P INPUT DROP
      $iptables -P OUTPUT DROP
      $iptables -P FORWARD DROP
 
      # przez Loopback wszystko wolno
      $iptables -I INPUT -i lo -j ACCEPT
      $iptables -I OUTPUT -o lo -j ACCEPT
 
      #####################################################
      # wychodzace polaczenia
      # Port 21
      $iptables -I OUTPUT -o eth0 -p TCP --sport 1024:65535 --dport 21 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
      $iptables -I INPUT -i eth0 -p TCP --sport 21 --dport 1024:65535 -m state --state ESTABLISHED,RELATED -j ACCEPT
      $iptables -I OUTPUT -o eth0 -p TCP --sport 49152:65535 --dport 20 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
      $iptables -I INPUT -i eth0 -p TCP --sport 20 --dport 49152:65535 -m state --state ESTABLISHED,RELATED -j ACCEPT
      # Port 22
      $iptables -I OUTPUT -o eth0 -p TCP --sport 1024:65535 --dport 22 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
      $iptables -I INPUT -i eth0 -p TCP --sport 22 --dport 1024:65535 -m state --state ESTABLISHED,RELATED -j ACCEPT
      # Port 80
      $iptables -I OUTPUT -o eth0 -p TCP --sport 1024:65535 --dport 80 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
      $iptables -I INPUT -i eth0 -p TCP --sport 80 --dport 1024:65535 -m state --state ESTABLISHED,RELATED -j ACCEPT
      # Port 443
      $iptables -I OUTPUT -o eth0 -p TCP --sport 1024:65535 --dport 443 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
      $iptables -I INPUT -i eth0 -p TCP --sport 443 --dport 1024:65535 -m state --state ESTABLISHED,RELATED -j ACCEPT
      # ICMP
      $iptables -I OUTPUT -o eth0 -p ICMP --icmp-type echo-reply -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
      $iptables -I INPUT -i eth0 -p ICMP --icmp-type echo-reply -m state --state ESTABLISHED,RELATED -j ACCEPT
 
      #####################################################
      # przychodzace polaczenia
      # Port 21
      $iptables -I INPUT -i eth0 -p TCP --sport 1024:65535 --dport 21 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
      $iptables -I OUTPUT -o eth0 -p TCP --sport 21 --dport 1024:65535 -m state --state ESTABLISHED,RELATED -j ACCEPT
      $iptables -I INPUT -i eth0 -p TCP --sport 1024:65535 --dport 1024:65535 -m state --state NEW -j ACCEPT
      $iptables -I INPUT -i eth0 -p TCP --sport 1024:65535 --dport 20 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
      $iptables -I OUTPUT -o eth0 -p TCP --sport 49152:65535 --dport 1024:65535 -m state --state ESTABLISHED,RELATED -j ACCEPT
      $iptables -I OUTPUT -o eth0 -p TCP --sport 20 --dport 1024:65535 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
      # Port 22
      $iptables -I INPUT -i eth0 -p TCP --sport 1024:65535 --dport 22 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
      $iptables -I OUTPUT -o eth0 -p TCP --sport 22 --dport 1024:65535 -m state --state ESTABLISHED,RELATED -j ACCEPT
      # Port 80
      $iptables -I INPUT -i eth0 -p TCP --sport 1024:65535 --dport 80 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
      $iptables -I OUTPUT -o eth0 -p TCP --sport 80 --dport 1024:65535 -m state --state ESTABLISHED,RELATED -j ACCEPT
      # Port 123
      $iptables -I INPUT -i eth0 -p TCP --sport 1024:65535 --dport 123 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
      $iptables -I OUTPUT -o eth0 -p TCP --sport 123 --dport 1024:65535 -m state --state ESTABLISHED,RELATED -j ACCEPT
      $iptables -I INPUT -i eth0 -p UDP --sport 1024:65535 --dport 123 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
      $iptables -I OUTPUT -o eth0 -p UDP --sport 123 --dport 1024:65535 -m state --state ESTABLISHED,RELATED -j ACCEPT
      # Port 443
      $iptables -I INPUT -i eth0 -p TCP --sport 1024:65535 --dport 443 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
      $iptables -I OUTPUT -o eth0 -p TCP --sport 443 --dport 1024:65535 -m state --state ESTABLISHED,RELATED -j ACCEPT
 
      #####################################################
      # inne funkcje
      # SynFlood
      $iptables -A FORWARD -p tcp --syn -m limit --limit 1/s -j ACCEPT
      # PortScan
      $iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT
      # Ping-of-Death
      $iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
 
      #####################################################
      # akceptuj egzystujace polaczenia
      $iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
      $iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
 
      #####################################################
      # przekaz garbage jesli niedozwolone
      $iptables -A INPUT -m state --state NEW,INVALID -j garbage
 
      #####################################################
      # zabron wszystkiego do tej pory dozwolonego
      $iptables -A INPUT -j garbage
      $iptables -A OUTPUT -j garbage
      $iptables -A FORWARD -j garbage
      ;;
   stop)
      echo "firewall wylaczony"
      $iptables -t nat -F
      $iptables -t filter -F
      $iptables -X
      $iptables -P INPUT ACCEPT
      $iptables -P OUTPUT ACCEPT
      $iptables -P FORWARD ACCEPT
      ;;
   restart|reload|force-reload)
   $0 stop
   $0 start
      ;;
   *)
      echo "Jak uzyc: /etc/init.d/firewall (start|stop)"
      exit 1
      ;;
esac
exit 0

RyszardLin

  • Gość
iptables blokuje?
« Odpowiedź #1 dnia: 2009-05-25, 22:11:59 »
Witam

Jak jest skofigurowany sshd? Czy dopuszcza wejście z interfesju publicznego?

RolloTomassi

  • Gość
iptables blokuje?
« Odpowiedź #2 dnia: 2009-05-26, 02:13:12 »
Podstawowa konfiguracja - niczego nie zmienialismy bo wydawalo nam sie, ze jak w sieci LAN dziala, to i przez internet powinno. Mozesz zdefiniowac pojecie "interfejs publiczny"?

RolloTomassi

  • Gość
iptables blokuje?
« Odpowiedź #3 dnia: 2009-05-28, 23:40:03 »
Ok, sprawa zalatwiona. Przy naprawie plików systemem ratunkowym z plyty aktywowal sie równolegle oryginalny skrypt "SUSEfirewall" czyli byly dwa skrypty.

Teraz mam ale inny problem. Powyzszy skrypt powinien utrzymywac istniejace polaczenie ssh i go nie przerywac, ale za to nie dopuszczac do nowych polaczen. Nie widze bledu - moze mi ktos prosze pomóc?