public inbox for passt-user@passt.top
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: "jklaiho@iki.fi" <jklaiho@iki.fi>
Cc: passt-user@passt.top
Subject: Re: Pasta-networked rootless Podman container gets Connection Refused with the host's public IP
Date: Wed, 28 Jun 2023 21:43:04 +1000	[thread overview]
Message-ID: <ZJwcyDTZgO1mdgsM@zatzit> (raw)
In-Reply-To: <f35191b6-4fcc-4ace-8d9c-1d6906b3e5de@Canary>

[-- Attachment #1: Type: text/plain, Size: 3910 bytes --]

On Wed, Jun 28, 2023 at 11:02:55AM +0300, jklaiho@iki.fi wrote:
> Hi; I previously asked this on the Podman mailing list, but I'm not
> sure if the issue in question is a feature of Podman or Passt (or
> both), and I got no replies from the Podman list, so I figured I'd
> try here as well.

This behaviour is a property of passt.  It's a consequence of a
tradeoff that we make differently from slirp or kernel masquerading
approaches.

Pasta (usually) avoids NAT, which can avoid a number of problems, but
the way it does this is by giving the container the host's IP address
(or one of them, if the host has multiple).  The tradeoff is that that
implies the container can't contact the host by that IP address.

> We're running some rootless Podman containers set up to use Pasta
> 2023_03_29.b10b983 for networking. One of the containers needs to
> access the host machine port 443 with its public IP address, but
> this causes a Connection Refused error. Any other public IP is
> accessible normally.

Right, this is expected.  Because the container itself also has that
IP, it will route that traffic to itself.  It will never even reach
pasta, let alone the host.  I'm assuming there's no server on that
port in the container, hence, connection refused.

> This is specific to the containers; the host has no problem
> accessing itself with the public IP.
> 
> The containers are set up with systemd generators (quadlet), with networking configured very simply:
> 
> "Network=pasta:-t,auto,-T,auto"
> 
> Podman has a --map-gw option useable with Pasta that seemed like it
> might help, but it didn't.
> 
> "Network=pasta:--map-gw,-t,auto,-T,auto" fails like this at container startup:
> 
> Error: failed to start pasta:
> Port forwarding mode 'none' conflicts with previous mode
> 
> "Network=pasta:-t,auto,-T,auto,--map-gw" started the container fine,
> but did not fix the Connection Refused error. Apparently --map-gw
> just isn't the right option here.

It's odd that those last two approaches gave different results, AFAIK
just changing the order of options shouldn't make a difference here.

But in any case, --map-gw (which from pasta's point of view is
removing the --no-map-gw option) will not do what you want for two
reasons.
   1. map-gw does provide a means for the container to access the
      host, but it's not via the host's normal public IP (that's
      impossible if the guest has it).  Instead it repurposes the IP
      of the default gateway to refer to the host when used from the
      container.  So to use this you'd need to change the address that
      your clients in the container use, which I gather isn't
      possible.

   2. With map-gw, traffic forwaded appears on the host side to both
      come from and go to the loopback interface.  That is from the
      servier's point of view the connection will go to 127.0.0.1, not
      the host's public IP.  AIUI that won't work for your situation.

> I don't know if the inability to contact the public IP is a feature
> of Podman or Pasta, but I'm hoping you're able to at least narrow it
> down for me.
> 
> Is there a workaround on the Pasta side?

Maybe.  You can add the -a <address> option to the pasta command line
which will tell it to assign the given address to the guest instead of
the host's address.  This should make the host contactable using it's
public IP.  However, it may cause other issues, since the container's
IP as it sees itself will no longer be the same as the container's IP
as things outside see it.  You'll obviously also have to pick an
address which won't conflict with anything else the guest needs to
contact.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

       reply	other threads:[~2023-06-28 11:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <f35191b6-4fcc-4ace-8d9c-1d6906b3e5de@Canary>
2023-06-28 11:43 ` David Gibson [this message]
2023-06-28 12:01 ` Pasta-networked rootless Podman container gets Connection Refused with the host's public IP Stefano Brivio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZJwcyDTZgO1mdgsM@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=jklaiho@iki.fi \
    --cc=passt-user@passt.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).