From nobody Wed Oct 18 09:35:33 2023 X-Original-To: freebsd-virtualization@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4S9Qhb2LKCz4xmrH for ; Wed, 18 Oct 2023 09:36:15 +0000 (UTC) (envelope-from odhiambo@gmail.com) Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4S9QhZ6Xk1z3gqY for ; Wed, 18 Oct 2023 09:36:14 +0000 (UTC) (envelope-from odhiambo@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2c3e23a818bso77948221fa.0 for ; Wed, 18 Oct 2023 02:36:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697621773; x=1698226573; darn=freebsd.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=aM02RmxxQlILJq3xEanrxcvR3t4ByAH4lNk7kAitbp4=; b=FuSlnYLcYDL67py227fsVX3Q4JWIh2P0OoTOawpchc+0JaXqlYyOPIrkIVrBm0wH/F cmRT4jpxvygFbR85stu/QtcFWv+JS9LPNzoRuF9o9kOmyqzlJnQZhT83X8TfJB6vXDZU /B3K6XamnJ3Mh2wfcn4sJ6gy8Rg/Z6uNGoLGuumtnKN3xSJLgikRuFh1LabPANXTbqJf QC02QDPA14jDxkrbOCVB2L1AMryxM94HIZ3fI1jnj6qSeXszu7NiQ0qw3GCRSwiZcDSP u9FQWp13cykRjoromSRVGnkpz4OOYa5AKL0p6pie/B7YbaiRJG1XbeW8ESnyOMX/41Ud uoUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697621773; x=1698226573; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=aM02RmxxQlILJq3xEanrxcvR3t4ByAH4lNk7kAitbp4=; b=n/0tJNo3FSjdZEdMSeAWJuDJBSpRClbf5FogcZoQs8LkDmUA1/4vl5MauV0Kp3ITi/ kzyemO1TnhadIx0htHfUSbiVGyXUasDspMEuHr6f9tFT9baIN6IKvd/kZZW5DgGyvSEc /pmeLRa8nBgYb0LhMCUutbkdmlTqBrXg9G2GsNGPppFBeCtVwdULGhptPaAmL4uZBSft OZdWYzrXhdPUc6LGc9RpijUe0oP/WftIcO7PuwsDlKlswfTsPSibCUWRqKLoViFIDtne k9Yc2bbgCVM6EaTHtA/xoX4/zDF9o6A6TkFUXNWuAp9CuGvTM0+8n+LWvX/cyK54wR5A 90IA== X-Gm-Message-State: AOJu0YwZsNZDKoDCbidEljSpNbKDMycnvMWiY8fu+vHcyyPg0Rr2l9gz jeKDLodo90aIXcqEbVBr1hCXtH3CjEm0vqOY6J7Ras3c4IvNJc/J X-Google-Smtp-Source: AGHT+IGRe5twfvdrq8r9szUWFX7xJgKRsMGSKwRdrIkaVNbI54AzmK+ryNYzLjnuE0nQ3HU/5ROfrV3afFcH3S2gqTo= X-Received: by 2002:a2e:9106:0:b0:2c5:8e7:77f with SMTP id m6-20020a2e9106000000b002c508e7077fmr1518022ljg.22.1697621772616; Wed, 18 Oct 2023 02:36:12 -0700 (PDT) List-Id: Discussion List-Archive: https://lists.freebsd.org/archives/freebsd-virtualization List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-virtualization@freebsd.org X-BeenThere: freebsd-virtualization@freebsd.org MIME-Version: 1.0 References: In-Reply-To: From: Odhiambo Washington Date: Wed, 18 Oct 2023 12:35:33 +0300 Message-ID: Subject: Re: Running a webserver inside a bhyve host and exposing it to the world via PF To: freebsd-virtualization@freebsd.org Cc: Paul Procacci Content-Type: multipart/alternative; boundary="000000000000b849a90607fa5ec4" X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US] X-Rspamd-Queue-Id: 4S9QhZ6Xk1z3gqY --000000000000b849a90607fa5ec4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Oct 17, 2023 at 6:03=E2=80=AFPM Paul Procacci = wrote: > > > On Tue, Oct 17, 2023 at 10:01=E2=80=AFAM Odhiambo Washington > wrote: > >> I am stuck on how I can achieve this. >> I have a Linux VM running under bhyve. I have installed a webserver >> running on port 80 that I'd like to expose to the outside world. >> I am unable to figure out how to achieve this with PF running on the hos= t >> machine. >> >> 1. I am able to access my VM using VNC Viewer >> 2. My VM is able to access the Internet >> 3. I am NOT able to ping my VM from the host >> 4. I am unable to SSH into the VM from the host. >> >> My hunch tells me it's about my PF.conf, but is there a guide somewhere >> on achieving the above? >> >> >> -- >> Best regards, >> Odhiambo WASHINGTON, >> Nairobi,KE >> +254 7 3200 0004/+254 7 2274 3223 >> "Oh, the cruft.", egrep -v '^$|^.*#' =C2=AF\_(=E3=83=84)_/=C2=AF :-) >> [How to ask smart questions: >> http://www.catb.org/~esr/faqs/smart-questions.html] >> > > Care to share what you tried with your PF.conf? > > It should be something as simple as: > rdr on proto tcp from to port > -> port > Two rules that aren't working: # VM HTTP rdr pass on $ext_if inet proto tcp from any to any port { 8081, 8999 } \ -> 172.16.0.99 port 80 # VM SSH rdr pass on $ext_if inet proto tcp from any to port { 2222 } \ -> 172.16.0.99 port 22 I am able to PING the VM from the HOST. >From the host, I am able to SSH to the VM. I am also able to do `telnet VM_IP 80` successfully. >From the WAN (Internet) when I do `ssh HOST:2222`, I expect to land in the VM, but that does not happen. So far I have: # bhyve bhyve_net=3D"172.16.0.0/24" And this NAT rule: nat on $ext_if from $bhyve_net to any -> ($ext_if) Do I need another PF rule to deal with the above issue? --=20 Best regards, Odhiambo WASHINGTON, Nairobi,KE +254 7 3200 0004/+254 7 2274 3223 "Oh, the cruft.", egrep -v '^$|^.*#' =C2=AF\_(=E3=83=84)_/=C2=AF :-) [How to ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html] --000000000000b849a90607fa5ec4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Tue, Oct 17, 2023 at 6:03=E2=80=AF= PM Paul Procacci <pprocacci@gmail= .com> wrote:


On Tue, Oct 17, 2023 at 10:0= 1=E2=80=AFAM Odhiambo Washington <odhiambo@gmail.com> wrote:
I am stuck on how I ca= n achieve this.
I have a Linux=C2=A0VM running under bhyve. I have inst= alled a webserver running on port=C2=A080 that I'd like to expose to th= e outside world.
I am unable to figure out how to achieve this wi= th PF running on the host machine.

1. I am able to= access my VM using VNC Viewer
2. My VM is able to access the Int= ernet
3. I am NOT able to ping my VM from the host
4. I= am unable to SSH into the VM from the host.=C2=A0

My hunch tells me it's about my PF.conf, but is there a guide somewher= e on achieving the above?


--
Best regards,
Odhi= ambo WASHINGTON,
Nairobi,KE
+254 7 3200 0004/+254 7 2274 3223
&quo= t;Oh, the cruft.",=C2=A0egrep -v= '^$|^.*#'=C2=A0=C2=AF\_(=E3=83=84)_/=C2= =AF=C2=A0:-)
[How to ask smart questions:=C2=A0http://www.catb.org/~esr/faqs/smart-questi= ons.html]

Care to share what you trie= d with your PF.conf?

It should be something as simple as:
= rdr on <interface> proto tcp from <source host> to <physical= host> port <physical port> -> <internal host> port <i= nternal port>

Two rules = that aren't working:

# VM HTTP
rdr pass on $ext_= if inet proto tcp from any to any port { 8081, 8999 } \
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 -> 172.16.0.99 port 80
# VM SSH
rdr pass on $ext_if = inet proto tcp from any to port { 2222 } \
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 -> 172.16.0.99 port 22
=C2=A0
I= am able to PING the VM from the=C2=A0HOST.

From the ho= st, I am able to SSH to the VM. I am also able to do `telnet VM_IP 80` succ= essfully.

From the WAN (Internet) when I do `ssh HOST:22= 22`, I expect to land in the VM, but that does not happen.

So far I have:

# bhyve
bhyve_net= =3D"172.16.0.0/24"
=

And this NAT rule:
nat on $ext_if from $bhyve= _net to any -> ($ext_if)

Do I need another = PF rule to deal with the above issue?

--
Best regards,
Odhiambo = WASHINGTON,
Nairobi,KE
+254 7 3200 0004/+254 7 2274 3223
"Oh, the cruft.",=C2=A0egrep -v '= ;^$|^.*#'=C2=A0=C2=AF\_(=E3=83=84)_/=C2=AF=C2=A0:-)
[How to ask smart questions:=C2=A0http://www.catb.org/~esr/faqs/smart-questions.h= tml]
--000000000000b849a90607fa5ec4--