Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Selfhosted
  3. How to configure UFW rules for podman

How to configure UFW rules for podman

Scheduled Pinned Locked Moved Selfhosted
selfhosted
7 Posts 4 Posters 0 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S This user is from outside of this forum
    S This user is from outside of this forum
    [email protected]
    wrote on last edited by
    #1

    Note: I am using VPS for services, since I do not want to expose my home network to internet.
    I am using podman, .
    But firewall (using UFW frontend) seems to block all the routing and inter-container traffic, so I want to
    Currently I have UFW rules set as blanket open for all podman networks, like this:

    Status: active
    
    To                         Action      From
    --                         ------      ----
    22/tcp                     ALLOW       Anywhere                  
    222/tcp                    ALLOW       Anywhere                  
    80/tcp                     ALLOW       Anywhere                  
    Anywhere on podman1        ALLOW       Anywhere                  
    443/tcp                    ALLOW       Anywhere                  
    8080/tcp                   ALLOW       Anywhere                  
    Anywhere on podman0        ALLOW       Anywhere                  
    Anywhere on podman2        ALLOW       Anywhere                  
    Anywhere on podman3        ALLOW       Anywhere                  
    Anywhere on podman4        ALLOW       Anywhere                  
    Anywhere on podman5        ALLOW       Anywhere                  
    22/tcp (v6)                ALLOW       Anywhere (v6)             
    222/tcp (v6)               ALLOW       Anywhere (v6)             
    80/tcp (v6)                ALLOW       Anywhere (v6)             
    Anywhere (v6) on podman1   ALLOW       Anywhere (v6)             
    443/tcp (v6)               ALLOW       Anywhere (v6)             
    8080/tcp (v6)              ALLOW       Anywhere (v6)             
    Anywhere (v6) on podman0   ALLOW       Anywhere (v6)             
    Anywhere (v6) on podman2   ALLOW       Anywhere (v6)             
    Anywhere (v6) on podman3   ALLOW       Anywhere (v6)             
    Anywhere (v6) on podman4   ALLOW       Anywhere (v6)             
    Anywhere (v6) on podman5   ALLOW       Anywhere (v6)             
    
    Anywhere on podman1        ALLOW FWD   Anywhere on ens3          
    Anywhere on podman0        ALLOW FWD   Anywhere on ens3          
    Anywhere on podman2        ALLOW FWD   Anywhere on ens3          
    Anywhere on podman3        ALLOW FWD   Anywhere on ens3          
    Anywhere on podman4        ALLOW FWD   Anywhere on ens3          
    Anywhere on podman5        ALLOW FWD   Anywhere on ens3          
    Anywhere (v6) on podman1   ALLOW FWD   Anywhere (v6) on ens3     
    Anywhere (v6) on podman0   ALLOW FWD   Anywhere (v6) on ens3     
    Anywhere (v6) on podman2   ALLOW FWD   Anywhere (v6) on ens3     
    Anywhere (v6) on podman3   ALLOW FWD   Anywhere (v6) on ens3     
    Anywhere (v6) on podman4   ALLOW FWD   Anywhere (v6) on ens3     
    Anywhere (v6) on podman5   ALLOW FWD   Anywhere (v6) on ens3 
    

    This neither seems secure, nor extensible when I add another network.
    Is there some 'best practices' for firewall setup with podman networks?
    How do you gurus set up your firewall for containers?
    Thanks in advance!

    E G shimitar@downonthestreet.euS 3 Replies Last reply
    1
    1
    • System shared this topic on
    • S [email protected]

      Note: I am using VPS for services, since I do not want to expose my home network to internet.
      I am using podman, .
      But firewall (using UFW frontend) seems to block all the routing and inter-container traffic, so I want to
      Currently I have UFW rules set as blanket open for all podman networks, like this:

      Status: active
      
      To                         Action      From
      --                         ------      ----
      22/tcp                     ALLOW       Anywhere                  
      222/tcp                    ALLOW       Anywhere                  
      80/tcp                     ALLOW       Anywhere                  
      Anywhere on podman1        ALLOW       Anywhere                  
      443/tcp                    ALLOW       Anywhere                  
      8080/tcp                   ALLOW       Anywhere                  
      Anywhere on podman0        ALLOW       Anywhere                  
      Anywhere on podman2        ALLOW       Anywhere                  
      Anywhere on podman3        ALLOW       Anywhere                  
      Anywhere on podman4        ALLOW       Anywhere                  
      Anywhere on podman5        ALLOW       Anywhere                  
      22/tcp (v6)                ALLOW       Anywhere (v6)             
      222/tcp (v6)               ALLOW       Anywhere (v6)             
      80/tcp (v6)                ALLOW       Anywhere (v6)             
      Anywhere (v6) on podman1   ALLOW       Anywhere (v6)             
      443/tcp (v6)               ALLOW       Anywhere (v6)             
      8080/tcp (v6)              ALLOW       Anywhere (v6)             
      Anywhere (v6) on podman0   ALLOW       Anywhere (v6)             
      Anywhere (v6) on podman2   ALLOW       Anywhere (v6)             
      Anywhere (v6) on podman3   ALLOW       Anywhere (v6)             
      Anywhere (v6) on podman4   ALLOW       Anywhere (v6)             
      Anywhere (v6) on podman5   ALLOW       Anywhere (v6)             
      
      Anywhere on podman1        ALLOW FWD   Anywhere on ens3          
      Anywhere on podman0        ALLOW FWD   Anywhere on ens3          
      Anywhere on podman2        ALLOW FWD   Anywhere on ens3          
      Anywhere on podman3        ALLOW FWD   Anywhere on ens3          
      Anywhere on podman4        ALLOW FWD   Anywhere on ens3          
      Anywhere on podman5        ALLOW FWD   Anywhere on ens3          
      Anywhere (v6) on podman1   ALLOW FWD   Anywhere (v6) on ens3     
      Anywhere (v6) on podman0   ALLOW FWD   Anywhere (v6) on ens3     
      Anywhere (v6) on podman2   ALLOW FWD   Anywhere (v6) on ens3     
      Anywhere (v6) on podman3   ALLOW FWD   Anywhere (v6) on ens3     
      Anywhere (v6) on podman4   ALLOW FWD   Anywhere (v6) on ens3     
      Anywhere (v6) on podman5   ALLOW FWD   Anywhere (v6) on ens3 
      

      This neither seems secure, nor extensible when I add another network.
      Is there some 'best practices' for firewall setup with podman networks?
      How do you gurus set up your firewall for containers?
      Thanks in advance!

      E This user is from outside of this forum
      E This user is from outside of this forum
      [email protected]
      wrote on last edited by
      #2

      I'm currently experimenting if I can convert my stack to rootless podman.

      I found in my notes, that

      A user-mode networking tool for unprivileged network namespaces must be installed on the machine in order for Podman to run in a rootless environment.

      Podman supports two rootless networking tools: pasta (provided by passt) and slirp4netns.

      Could this be your problem?

      Taken from https://github.com/containers/podman/blob/main/docs/tutorials/rootless_tutorial.md

      S 1 Reply Last reply
      0
      • E [email protected]

        I'm currently experimenting if I can convert my stack to rootless podman.

        I found in my notes, that

        A user-mode networking tool for unprivileged network namespaces must be installed on the machine in order for Podman to run in a rootless environment.

        Podman supports two rootless networking tools: pasta (provided by passt) and slirp4netns.

        Could this be your problem?

        Taken from https://github.com/containers/podman/blob/main/docs/tutorials/rootless_tutorial.md

        S This user is from outside of this forum
        S This user is from outside of this forum
        [email protected]
        wrote on last edited by
        #3

        Thanks, I am running rootful containers so I don't think this applies.

        1 Reply Last reply
        0
        • S [email protected]

          Note: I am using VPS for services, since I do not want to expose my home network to internet.
          I am using podman, .
          But firewall (using UFW frontend) seems to block all the routing and inter-container traffic, so I want to
          Currently I have UFW rules set as blanket open for all podman networks, like this:

          Status: active
          
          To                         Action      From
          --                         ------      ----
          22/tcp                     ALLOW       Anywhere                  
          222/tcp                    ALLOW       Anywhere                  
          80/tcp                     ALLOW       Anywhere                  
          Anywhere on podman1        ALLOW       Anywhere                  
          443/tcp                    ALLOW       Anywhere                  
          8080/tcp                   ALLOW       Anywhere                  
          Anywhere on podman0        ALLOW       Anywhere                  
          Anywhere on podman2        ALLOW       Anywhere                  
          Anywhere on podman3        ALLOW       Anywhere                  
          Anywhere on podman4        ALLOW       Anywhere                  
          Anywhere on podman5        ALLOW       Anywhere                  
          22/tcp (v6)                ALLOW       Anywhere (v6)             
          222/tcp (v6)               ALLOW       Anywhere (v6)             
          80/tcp (v6)                ALLOW       Anywhere (v6)             
          Anywhere (v6) on podman1   ALLOW       Anywhere (v6)             
          443/tcp (v6)               ALLOW       Anywhere (v6)             
          8080/tcp (v6)              ALLOW       Anywhere (v6)             
          Anywhere (v6) on podman0   ALLOW       Anywhere (v6)             
          Anywhere (v6) on podman2   ALLOW       Anywhere (v6)             
          Anywhere (v6) on podman3   ALLOW       Anywhere (v6)             
          Anywhere (v6) on podman4   ALLOW       Anywhere (v6)             
          Anywhere (v6) on podman5   ALLOW       Anywhere (v6)             
          
          Anywhere on podman1        ALLOW FWD   Anywhere on ens3          
          Anywhere on podman0        ALLOW FWD   Anywhere on ens3          
          Anywhere on podman2        ALLOW FWD   Anywhere on ens3          
          Anywhere on podman3        ALLOW FWD   Anywhere on ens3          
          Anywhere on podman4        ALLOW FWD   Anywhere on ens3          
          Anywhere on podman5        ALLOW FWD   Anywhere on ens3          
          Anywhere (v6) on podman1   ALLOW FWD   Anywhere (v6) on ens3     
          Anywhere (v6) on podman0   ALLOW FWD   Anywhere (v6) on ens3     
          Anywhere (v6) on podman2   ALLOW FWD   Anywhere (v6) on ens3     
          Anywhere (v6) on podman3   ALLOW FWD   Anywhere (v6) on ens3     
          Anywhere (v6) on podman4   ALLOW FWD   Anywhere (v6) on ens3     
          Anywhere (v6) on podman5   ALLOW FWD   Anywhere (v6) on ens3 
          

          This neither seems secure, nor extensible when I add another network.
          Is there some 'best practices' for firewall setup with podman networks?
          How do you gurus set up your firewall for containers?
          Thanks in advance!

          G This user is from outside of this forum
          G This user is from outside of this forum
          [email protected]
          wrote on last edited by
          #4

          If you really want to stick to UFW, you can ignore me, but this looks like a situation where finding another firewall may be best. UFW is a front end for IPtables and is mostly meant for desktop or simple server app usage. I'd recommend Shorewall, which is also a front end for IPtables but implements a zone based firewall and allows for more complex setups to be handled easier than with UFW. You can put your podman containers into a zone and define all of the network access you need for that zone separate from the host system.

          S 1 Reply Last reply
          0
          • G [email protected]

            If you really want to stick to UFW, you can ignore me, but this looks like a situation where finding another firewall may be best. UFW is a front end for IPtables and is mostly meant for desktop or simple server app usage. I'd recommend Shorewall, which is also a front end for IPtables but implements a zone based firewall and allows for more complex setups to be handled easier than with UFW. You can put your podman containers into a zone and define all of the network access you need for that zone separate from the host system.

            S This user is from outside of this forum
            S This user is from outside of this forum
            [email protected]
            wrote on last edited by
            #5

            Thanks, though Shorewall looks intimidating. Do you have any good resources to go over how to set it up?

            G 1 Reply Last reply
            0
            • S [email protected]

              Note: I am using VPS for services, since I do not want to expose my home network to internet.
              I am using podman, .
              But firewall (using UFW frontend) seems to block all the routing and inter-container traffic, so I want to
              Currently I have UFW rules set as blanket open for all podman networks, like this:

              Status: active
              
              To                         Action      From
              --                         ------      ----
              22/tcp                     ALLOW       Anywhere                  
              222/tcp                    ALLOW       Anywhere                  
              80/tcp                     ALLOW       Anywhere                  
              Anywhere on podman1        ALLOW       Anywhere                  
              443/tcp                    ALLOW       Anywhere                  
              8080/tcp                   ALLOW       Anywhere                  
              Anywhere on podman0        ALLOW       Anywhere                  
              Anywhere on podman2        ALLOW       Anywhere                  
              Anywhere on podman3        ALLOW       Anywhere                  
              Anywhere on podman4        ALLOW       Anywhere                  
              Anywhere on podman5        ALLOW       Anywhere                  
              22/tcp (v6)                ALLOW       Anywhere (v6)             
              222/tcp (v6)               ALLOW       Anywhere (v6)             
              80/tcp (v6)                ALLOW       Anywhere (v6)             
              Anywhere (v6) on podman1   ALLOW       Anywhere (v6)             
              443/tcp (v6)               ALLOW       Anywhere (v6)             
              8080/tcp (v6)              ALLOW       Anywhere (v6)             
              Anywhere (v6) on podman0   ALLOW       Anywhere (v6)             
              Anywhere (v6) on podman2   ALLOW       Anywhere (v6)             
              Anywhere (v6) on podman3   ALLOW       Anywhere (v6)             
              Anywhere (v6) on podman4   ALLOW       Anywhere (v6)             
              Anywhere (v6) on podman5   ALLOW       Anywhere (v6)             
              
              Anywhere on podman1        ALLOW FWD   Anywhere on ens3          
              Anywhere on podman0        ALLOW FWD   Anywhere on ens3          
              Anywhere on podman2        ALLOW FWD   Anywhere on ens3          
              Anywhere on podman3        ALLOW FWD   Anywhere on ens3          
              Anywhere on podman4        ALLOW FWD   Anywhere on ens3          
              Anywhere on podman5        ALLOW FWD   Anywhere on ens3          
              Anywhere (v6) on podman1   ALLOW FWD   Anywhere (v6) on ens3     
              Anywhere (v6) on podman0   ALLOW FWD   Anywhere (v6) on ens3     
              Anywhere (v6) on podman2   ALLOW FWD   Anywhere (v6) on ens3     
              Anywhere (v6) on podman3   ALLOW FWD   Anywhere (v6) on ens3     
              Anywhere (v6) on podman4   ALLOW FWD   Anywhere (v6) on ens3     
              Anywhere (v6) on podman5   ALLOW FWD   Anywhere (v6) on ens3 
              

              This neither seems secure, nor extensible when I add another network.
              Is there some 'best practices' for firewall setup with podman networks?
              How do you gurus set up your firewall for containers?
              Thanks in advance!

              shimitar@downonthestreet.euS This user is from outside of this forum
              shimitar@downonthestreet.euS This user is from outside of this forum
              [email protected]
              wrote on last edited by
              #6

              Podman works with nft, not iptables. Ufw iirc uses iptables.

              Try a different firewall tool, or use nft directly

              If your containers are bound to 127.0.0.1 and you only have a reverse proxy on 443, you probably don't even really need a firewall.

              Run rootless podman and segregate each container stack on its own network, podman will take care of it for you.

              1 Reply Last reply
              0
              • S [email protected]

                Thanks, though Shorewall looks intimidating. Do you have any good resources to go over how to set it up?

                G This user is from outside of this forum
                G This user is from outside of this forum
                [email protected]
                wrote on last edited by
                #7

                For so many Linux server packages I find the manual to be more of a reference than a guide, so not very useful if you're just getting started and aren't sure what to do, but Shorewall is an exception, its manual is wonderful and Tom the creator really goes into detail about how to fit it into many different setups.

                https://shorewall.org/GettingStarted.html

                You'll probably want to follow the two interface guide, the two interfaces in your case are your public IP interface, and the virtual interface connected to the Podman network side. You'll essentially treat shorewall as a firewall/router for your Podman containers which will act as your "LAN" in this case. The warning about not installing Shorewall on a remote system is not to be ignored, you're generally fine to install the package, but do not start the shorewall service without first setting up some rules to allow SSH. The safest way is to log in via your VPS console instead of SSH to keep you from getting locked out. Most VPS providers have some sort of out-of-band connection utility like VNC or a simple console access you'll want to use.

                1 Reply Last reply
                0
                • System shared this topic on
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups