LINUX.ORG.RU

Ошибка iptables

 ,


0

1

Iptables при старте службы выводит следующую ошибку:

systemd[1]: Starting IPv4 firewall with iptables...
iptables.init[9875]: iptables: Applying firewall rules: iptables-restore v1.4.21: Port `0' not valid
iptables.init[9875]: Error occurred at line: 39
iptables.init[9875]: Try `iptables-restore -h' or 'iptables-restore --help' for more information.
iptables.init[9875]: [FAILED]
systemd[1]: iptables.service: main process exited, code=exited, status=1/FAILURE
systemd[1]: Failed to start IPv4 firewall with iptables.
systemd[1]: Unit iptables.service entered failed state.
systemd[1]: iptables.service failed.

Конфиг iptables выглядит следующим образом:

[root@bxenv1 tasks]# cat /etc/sysconfig/iptables
# Generated by iptables-save v1.4.21 on Sun Dec 27 18:58:31 2020
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:bx_public - [0:0]
:bx_trusted - [0:0]
-A INPUT -j bx_trusted
-A INPUT -j bx_public
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
-A bx_public -p tcp -m state --state NEW -m tcp --dport 8070 -m comment --comment "BX: requests for pool update" -j ACCEPT
-A bx_public -p tcp -m state --state NEW -m tcp --dport 80 -m comment --comment "BX: web ports" -j ACCEPT
-A bx_public -p tcp -m state --state NEW -m tcp --dport 443 -m comment --comment "BX: web ports" -j ACCEPT
-A bx_public -p tcp -m state --state NEW -m tcp --dport 8890 -m comment --comment "BX: web ports" -j ACCEPT
-A bx_public -p tcp -m state --state NEW -m tcp --dport 8891 -m comment --comment "BX: web ports" -j ACCEPT
-A bx_public -p tcp -m state --state NEW -m tcp --dport 8893 -m comment --comment "BX: web ports" -j ACCEPT
-A bx_public -p tcp -m state --state NEW -m tcp --dport 8894 -m comment --comment "BX: web ports" -j ACCEPT
-A bx_public -p tcp -m state --state NEW -m tcp --dport 5222 -m comment --comment "BX: web ports" -j ACCEPT
-A bx_public -p tcp -m state --state NEW -m tcp --dport 5223 -m comment --comment "BX: web ports" -j ACCEPT
-A bx_trusted -s 10.10.0.4/32 -p tcp -m tcp -m comment --comment "BX: server1" -j ACCEPT
-A bx_trusted -s 10.10.0.4/32 -p udp -m udp -m comment --comment "BX: server1" -j ACCEPT
COMMIT
# Completed on Sun Dec 27 18:58:31 2020
# Generated by iptables-save v1.4.21 on Sun Dec 27 18:58:31 2020
*nat
:PREROUTING ACCEPT [7:1225]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [1413:84840]
:POSTROUTING ACCEPT [2799:191448]
:DOCKER_OUTPUT - [0:0]
:DOCKER_POSTROUTING - [0:0]
-A OUTPUT -d 127.0.0.11/32 -j DOCKER_OUTPUT
-A POSTROUTING -d 127.0.0.11/32 -j DOCKER_POSTROUTING
-A DOCKER_OUTPUT -d 127.0.0.11/32 -p tcp -m tcp --dport 53 -j DNAT --to-destination 0.0.0.0:0 --random --persistent --to-destination 0.0.0.0:0 --random --persistent --to-destination 0.0.0.0 --random --persistent
-A DOCKER_OUTPUT -d 127.0.0.11/32 -p udp -m udp --dport 53 -j DNAT --to-destination 0.0.0.0:0 --random --persistent --to-destination 0.0.0.0:0 --random --persistent --to-destination 0.0.0.0 --random --persistent
-A DOCKER_POSTROUTING -s 127.0.0.11/32 -p tcp -m tcp --sport 36221 -j SNAT --to-source :53
-A DOCKER_POSTROUTING -s 127.0.0.11/32 -p udp -m udp --sport 60692 -j SNAT --to-source :53
COMMIT
# Completed on Sun Dec 27 18:58:31 2020

Сам с iptables знаком плохо, конфиг сгенерирован автоматически. В нём какая-то ошибка?

-A DOCKER_OUTPUT -d 127.0.0.11/32 -p tcp -m tcp --dport 53 -j DNAT --to-destination 0.0.0.0:0 --random --persistent --to-destination 0.0.0.0:0 --random --persistent --to-destination 0.0.0.0 --random --persistent

-A DOCKER_OUTPUT -d 127.0.0.11/32 -p udp -m udp --dport 53 -j DNAT --to-destination 0.0.0.0:0 --random --persistent --to-destination 0.0.0.0:0 --random --persistent --to-destination 0.0.0.0 --random --persistent

ты не первый наступил на эти грабли https://github.com/moby/moby/issues/40428

imho сохранять и восстанавливать правила iptables - глупость (если только не идет борьба за счетчики пакетов/байт).

Правильнее просто создавать свои привила при старте, своим скриптом.

vel ★★★★★
()
Ответ на: комментарий от vel

О, спасибо огромное. Правильно ли я понял, что это значит, что косячат какие-то скрипты докера, которые прописывают правила в конфиг iptables? То есть сценарий предположительно такой: запускается контейнер, в нём прописаны правила докера (в iptables), внутри контейнера отрабатывает какой-то скрипт-установщик (написанный не мной), который (видимо) затирает правила докера и прописывает свои, а потом докер пытается дописать снова свои правила - и пишет что-то не совсем корректное?

Novascriptum
() автор топика
Ответ на: комментарий от Novascriptum

Правила, которые iptables пытается восстановить, некорректны.
А точнее

--to-destination 0.0.0.0:0

anonymous
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.