2013-08-20 12:07:55 +0000 2013-08-20 12:07:55 +0000
34
34
Advertisement

need iptables rule to accept all incoming traffic

Advertisement

For my test environment I want to accept all incoming traffic, can someone please give me the iptable rule to be added.

My current iptables -L -n output looks like this

Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT all – 0. 0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED ACCEPT icmp – 0.0.0.0/0 0.0.0.0/0 ACCEPT all – 0.0.0.0/0 0.0.0.0/0 ACCEPT tcp – 0.0.0.0/0 0.0.0/0 state NEW tcp dpt:22 REJECT all – 0. 0.0.0/0 0.0.0.0/0 odrzuć - z icmp-host-prohibited ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 tcp dpt:8443 ACCEPT tcp – 0. 0,0.0/0 0,0.0.0/0 tcp dpt:8080 ACCEPT tcp – 0,0.0.0/0 0,0.0/0 tcp dpt:9443 ACCEPT tcp – 0,0.0.0/0 0,0.0.0. 0/0 tcp dpt:2124

Chain FORWARD (policy ACCEPT) target prot opt source destination REJECT all – 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT) target prot opt source destination

Thanks

Advertisement
Advertisement

Odpowiedzi (2)

54
54
54
2013-08-20 16:20:23 +0000

Biegnij dalej. Wstawi on regułę na górze twoich iptables i pozwoli na cały ruch, chyba że będzie on później obsługiwany przez inną regułę.

iptables -I INPUT -j ACCEPT

Możesz również spłukać całą konfigurację iptables za pomocą:

iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

Jeśli spłukujesz, możesz uruchomić coś podobnego:

iptables -A INPUT -i lo -j ACCEPT -m comment --comment "Allow all loopback traffic"
iptables -A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT -m comment --comment "Drop all traffic to 127 that doesn't use lo"
iptables -A OUTPUT -j ACCEPT -m comment --comment "Accept all outgoing"
iptables -A INPUT -j ACCEPT -m comment --comment "Accept all incoming"
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -m comment --comment "Allow all incoming on established connections"
iptables -A INPUT -j REJECT -m comment --comment "Reject all incoming"
iptables -A FORWARD -j REJECT -m comment --comment "Reject all forwarded"

Jeśli chcesz być nieco bezpieczniejszy z ruchem, nie używaj wszystkich reguł przychodzących, lub usuń je za pomocą “iptables -D INPUT -j ACCEPT -m komentarz -komentarz "Accept all incoming”, i dodaj bardziej szczegółowe reguły jak:

iptables -I INPUT -p tcp --dport 80 -j ACCEPT -m comment --comment "Allow HTTP"
iptables -I INPUT -p tcp --dport 443 -j ACCEPT -m comment --comment "Allow HTTPS"
iptables -I INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT -m comment --comment "Allow SSH"
iptables -I INPUT -p tcp --dport 8071:8079 -j ACCEPT -m comment --comment "Allow torrents"

UWAGA: Muszą być powyżej 2 reguł odrzucających na dole, więc użyj I do wstawienia ich na górze. Albo jeśli jesteś analny jak ja, użyj “iptables -nL –line-numbers” aby uzyskać numery linii, następnie użyj “iptables -I INPUT …” aby wstawić regułę na określony numer linii.

Na koniec, zapisz swoją pracę z:

iptables-save > /etc/network/iptables.rules #Or wherever your iptables.rules file is
16
16
16
2013-08-20 13:24:49 +0000

aby zaakceptować cały ruch przychodzący możesz użyć następującej komendy , -P jest to ustawienie domyślnej polityki jako akceptuj

iptables -P INPUT ACCEPT

jeśli nie wymagasz swoich poprzednich reguł po prostu spłucz/usuń je, a następnie użyj powyższej komendy. aby spłukać wszystkie reguły użyj

iptables -F
Advertisement

Pytania pokrewne

6
10
5
37
3
Advertisement
Advertisement