
Mi objetivo es cargar una colección de iptables
reglas al inicio. Estoy ejecutando Ubuntu 20.04.1.
Tengo una colección de iptables
reglas definidas en /etc/iptables/rules.v4
. Lo tengo iptables-persistent
e netfilter-persistent
instalé. Este último es un systemd
servicio habilitado y se ejecuta correctamente después de reiniciar, como systemctl status netfilter-persistent
se indica, pero las reglas definidas en /etc/iptables/rules.v4
sonnoaplicado después de un reinicio.
Fundamentalmente: reiniciar manualmente el servicio ( systemctl restart netfilter-persistent
) hace que se carguen las reglas. El servicio funciona y las reglas son válidas. Es como si algún otro servicio apareciera después de netfilter-persistent
las ejecuciones y salidas, borrando las reglas.
¿Alguien tiene alguna idea? No tengo idea de cómo proceder, ya que nadie más parece tener este problema.
Si algún otro detalle sería útil, hágamelo saber. Siento como si estuviera perdiendo la cabeza.
Editar:Los contenidos de /etc/iptables/rules.v4
son:
*nat
:PREROUTING ACCEPT [29:8848]
:INPUT ACCEPT [29:8848]
:OUTPUT ACCEPT [6720:404317]
:POSTROUTING ACCEPT [96:8382]
:DOCKER - [0:0]
-A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
-A OUTPUT ! -d 127.0.0.0/8 -m addrtype --dst-type LOCAL -j DOCKER
-A POSTROUTING -s 172.17.0.0/16 ! -o docker0 -j MASQUERADE
-A POSTROUTING -o enp39s0 -j MASQUERADE
-A DOCKER -i docker0 -j RETURN
COMMIT
*filter
:INPUT ACCEPT [9418:3194873]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [17003:1327822]
:DOCKER - [0:0]
:DOCKER-ISOLATION-STAGE-1 - [0:0]
:DOCKER-ISOLATION-STAGE-2 - [0:0]
:DOCKER-USER - [0:0]
-A FORWARD -j DOCKER-USER
-A FORWARD -j DOCKER-ISOLATION-STAGE-1
-A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -o docker0 -j DOCKER
-A FORWARD -i docker0 ! -o docker0 -j ACCEPT
-A FORWARD -i docker0 -o docker0 -j ACCEPT
-A DOCKER-ISOLATION-STAGE-1 -i docker0 ! -o docker0 -j DOCKER-ISOLATION-STAGE-2
-A DOCKER-ISOLATION-STAGE-1 -j RETURN
-A DOCKER-ISOLATION-STAGE-2 -o docker0 -j DROP
-A DOCKER-ISOLATION-STAGE-2 -j RETURN
-A DOCKER-USER -j RETURN
COMMIT
Después de un arranque, iptables --list -v
devuelve:
Chain INPUT (policy ACCEPT 5587 packets, 1329K bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 DOCKER-USER all -- any any anywhere anywhere
0 0 DOCKER-ISOLATION-STAGE-1 all -- any any anywhere anywhere
0 0 ACCEPT all -- any docker0 anywhere anywhere ctstate RELATED,ESTABLISHED
0 0 DOCKER all -- any docker0 anywhere anywhere
0 0 ACCEPT all -- docker0 !docker0 anywhere anywhere
0 0 ACCEPT all -- docker0 docker0 anywhere anywhere
0 0 ACCEPT all -- wg0 any anywhere anywhere
Chain OUTPUT (policy ACCEPT 6845 packets, 956K bytes)
pkts bytes target prot opt in out source destination
Chain DOCKER (1 references)
pkts bytes target prot opt in out source destination
Chain DOCKER-ISOLATION-STAGE-1 (1 references)
pkts bytes target prot opt in out source destination
0 0 DOCKER-ISOLATION-STAGE-2 all -- docker0 !docker0 anywhere anywhere
0 0 RETURN all -- any any anywhere anywhere
Chain DOCKER-ISOLATION-STAGE-2 (1 references)
pkts bytes target prot opt in out source destination
0 0 DROP all -- any docker0 anywhere anywhere
0 0 RETURN all -- any any anywhere anywhere
Chain DOCKER-USER (1 references)
pkts bytes target prot opt in out source destination
0 0 RETURN all -- any any anywhere anywhere
Tenga en cuenta, en particular, que la política ADELANTE es DROP, no ACEPTAR, y que wg0
se agregan reglas WireGuard ().