Strona 1 z 1

Iptables nie blokuje adresu IP

: 22 marca 2011, 17:34
autor: Baneling
Witam serdecznie wszystkich. To mój pierwszy post, więc warto się przywitać.

Jestem bardzo początkującym użytkownikiem Debiana i postanowiłem jakiś czas temu zacząć uczyć się administracją tym systemem.

Napotkałem pewien problem związany z iptables. Poniżej moje wpisy.

Kod: Zaznacz cały

iptables -t filter -F
iptables -t filter -X
iptables -t filter -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

iptables -t filter -P INPUT DROP
iptables -t filter -P FORWARD DROP
iptables -t filter -P OUTPUT DROP

iptables -t filter -A INPUT -i lo -j ACCEPT
iptables -t filter -A OUTPUT -o lo -j ACCEPT

iptables -t filter -A OUTPUT -p tcp --dport 53 -j ACCEPT
iptables -t filter -A OUTPUT -p udp --dport 53 -j ACCEPT
iptables -t filter -A INPUT -p tcp --dport 53 -j ACCEPT
iptables -t filter -A INPUT -p udp --dport 53 -j ACCEPT

iptables -t filter -A OUTPUT -p udp --dport 123 -j ACCEPT

iptables -t filter -A OUTPUT -p tcp --dport 20:21 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 30000:50000 -j ACCEPT
iptables -t filter -A INPUT -p tcp --dport 20:21 -j ACCEPT
iptables -t filter -A INPUT -p tcp --dport 30000:50000 -j ACCEPT
iptables -t filter -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

iptables -t filter -A OUTPUT -p tcp --dport 80 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 443 -j ACCEPT
iptables -t filter -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -t filter -A INPUT -p tcp --dport 443 -j ACCEPT

iptables -t filter -A INPUT -p tcp --dport 110 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 110 -j ACCEPT

iptables -t filter -A INPUT -p tcp --dport 143 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 143 -j ACCEPT
Od razu przyznaję się, że konfig jest zerżnięty jako żywo z jakiejś strony. Ale wydaje się chyba działać. Problem pojawia się, gdy chcę zablokować konkretny adres IP na wszystkich portach.

Kod: Zaznacz cały

iptables -t filter -A INPUT -s 173.201.37.18 -j DROP
Niestety nie działa. Jak mówiłem, jestem zielony, więc proszę o wyrozumiałość. Mógłby ktoś mnie oświecić gdzie popełniam błąd?

: 22 marca 2011, 19:45
autor: grzesiek
Bo reguła jest na końcu...

Kod: Zaznacz cały

iptables -t filter -A INPUT 1 -s 173.201.37.18 -j DROP

: 23 marca 2011, 09:12
autor: Bastian
Dokładnie. Ktoś łączy się z tego IP na porty, które udostępniasz, więc firewall go przepuszcza, a potem to już wchodzi przez regułę RELATED, i twoja reguła w ogole nie jest sprawdzana.