iptables-restore falhou na linha COMMIT, sem descrição detalhada

2

Eu estou tentando configurar o iptables (usando o iptables-restore) para um novo servidor e estava olhando os documentos de segurança de Linode , então basicamente usam seus modelos para IPv4 e IPv6. Ambos estão falhando na mensagem COMMIT, mas acho que o erro está em outro lugar.

alessio@scw-272444:~$ sudo iptables-restore < /tmp/v4
iptables-restore: line 37 failed

IPv4:

*filter

# Allow all loopback (lo0) traffic and reject traffic
# to localhost that does not originate from lo0.
-A INPUT -i lo -j ACCEPT
-A INPUT ! -i lo -s 127.0.0.0/8 -j REJECT

# Allow ping and traceroute.
-A INPUT -p icmp --icmp-type 3 -j ACCEPT
-A INPUT -p icmp --icmp-type 8 -j ACCEPT
-A INPUT -p icmp --icmp-type 11 -j ACCEPT

# Allow SSH connections.
-A INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT

# Allow HTTP and HTTPS connections from anywhere
# (the normal ports for web servers).
-A INPUT -p tcp --dport 80 -j ACCEPT
-A INPUT -p tcp --dport 443 -j ACCEPT

# Accept inbound traffic from established connections.
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# Log what was incoming but denied (optional but useful).
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables_INPUT_denied: " --log-level 7

# Reject all other inbound.
-A INPUT -j REJECT

# Log any traffic which was sent to you
# for forwarding (optional but useful).
-A FORWARD -m limit --limit 5/min -j LOG --log-prefix "iptables_FORWARD_denied: " --log-level 7

# Reject all traffic forwarding.
-A FORWARD -j REJECT

COMMIT

IPv6:

*filter

# Allow all loopback (lo0) traffic and reject traffic
# to localhost that does not originate from lo0.
-A INPUT -i lo -j ACCEPT
-A INPUT ! -i lo -s ::1/128 -j REJECT

# Allow ICMP
-A INPUT  -p icmpv6 -j ACCEPT

# Allow HTTP and HTTPS connections from anywhere
# (the normal ports for web servers).
-A INPUT -p tcp --dport 80 -j ACCEPT
-A INPUT -p tcp --dport 443 -j ACCEPT

# Accept inbound traffic from established connections.
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# Log what was incoming but denied (optional but useful).
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "ip6tables_INPUT_denied: " --log-level 7

# Reject all other inbound.
-A INPUT -j REJECT

# Log any traffic which was sent to you
# for forwarding (optional but useful).
-A FORWARD -m limit --limit 5/min -j LOG --log-prefix "ip6tables_FORWARD_denied: " --log-level 7

# Reject all traffic forwarding.
-A FORWARD -j REJECT

COMMIT
    
por alessioalex 29.10.2015 / 14:12

1 resposta

0

A linha COMMIT falhou porque talvez haja alguns erros antes desta linha. Por favor, verifique cada linha em sua configuração (cole como argumentos para o iptables).

Ou você pode converter sua configuração do iptables como um script bash e executar o bash -x para visualizar o erro de configuração:


#!/bin/bash
#
# this file is: iptables_v4.sh

# Allow all loopback (lo0) traffic and reject traffic
# to localhost that does not originate from lo0.
iptables -A  INPUT -i lo -j ACCEPT
iptables -A  INPUT ! -i lo -s 127.0.0.0/8 -j REJECT

# Allow ping and traceroute.
iptables -A  INPUT -p icmp --icmp-type 3 -j ACCEPT
iptables -A  INPUT -p icmp --icmp-type 8 -j ACCEPT
iptables -A  INPUT -p icmp --icmp-type 11 -j ACCEPT

# Allow SSH connections.
iptables -A  INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT

# Allow HTTP and HTTPS connections from anywhere
# (the normal ports for web servers).
iptables -A  INPUT -p tcp --dport 80 -j ACCEPT
iptables -A  INPUT -p tcp --dport 443 -j ACCEPT

# Accept inbound traffic from established connections.
iptables -A  INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# Log what was incoming but denied (optional but useful).
iptables -A  INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables_INPUT_denied: " --log-level 7

# Reject all other inbound.
iptables -A  INPUT -j REJECT

# Log any traffic which was sent to you
# for forwarding (optional but useful).
iptables -A  FORWARD -m limit --limit 5/min -j LOG --log-prefix "iptables_FORWARD_denied: " --log-level 7

# Reject all traffic forwarding.
iptables -A  FORWARD -j REJECT

Para depurar: :

root$bash -x iptables_v4.sh
    
por 04.11.2016 / 04:11