shinebayar-g / ufw-docker-automated

Manage docker containers firewall with UFW!
Apache License 2.0
198 stars 31 forks source link

When container has multiple networks, it only creates one network rules #44

Closed rodriciru closed 1 year ago

rodriciru commented 2 years ago

Hi. First, I must say I don't understand iptables, so maybe this is correct. I have a reverse proxy which has 2 networks (one has more priority over the other) When I launch your program, only one of these networks is created, and the other is deleted if already exist. Is correct this behavior?

 networks:
            proxy:                
                priority: 1000
            crowdsec:
ufw status numbered
Status: active

     To                         Action      From
     --                         ------      ----
[ 1] 22/tcp                     ALLOW IN    Anywhere
[ 2] 80/tcp                     ALLOW IN    Anywhere
[ 3] 443                        ALLOW IN    Anywhere
[ 4] 172.18.0.5 443/tcp         ALLOW FWD   Anywhere                   # traefik-traefik-1:0baf661347fb
[ 5] 172.18.0.5 80/tcp          ALLOW FWD   Anywhere                   # traefik-traefik-1:0baf661347fb
[ 6] 22/tcp (v6)                ALLOW IN    Anywhere (v6)
[ 7] 80/tcp (v6)                ALLOW IN    Anywhere (v6)
[ 8] 443 (v6)                   ALLOW IN    Anywhere (v6)

As you can see I should have 2 more rules like 4 and 5 but with IP 172.22.0.2 for example

shinebayar-g commented 2 years ago

Hi @rodriciru If I understand you correctly are we talking about multiple docker networks?

rodriciru commented 2 years ago

Yes, I have a composer with many services and one of them belongs to 2 networks

El mié, 26 oct 2022 17:51, Shinebayar G. @.***> escribió:

Hi @rodriciru https://github.com/rodriciru If I understand you correctly are we talking about multiple docker networks?

— Reply to this email directly, view it on GitHub https://github.com/shinebayar-g/ufw-docker-automated/issues/44#issuecomment-1292255740, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACR6MY3UCKX3X5N5ZNXP6ZDWFFHOZANCNFSM6AAAAAARO37M3U . You are receiving this because you were mentioned.Message ID: @.***>

rodriciru commented 2 years ago

How about this? Can you look at it?

shinebayar-g commented 2 years ago

~After #46 I'll look into this, thanks.~

kforeverisback commented 1 year ago

Hey @shinebayar-g, thank you for this awesome project. It's been useful for my home server!

I needed the multi-network support, so I've implemented myself. I have a branch which is working for multi-networks (tested for default, single, multi-network in docker-network).

https://github.com/kforeverisback/ufw-docker-automated/tree/feature/multi-network

I'll do a quick PR (unless you're planning to do so soon).