Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: optional ext_if6 macro in pf.conf to enable rdr for non-VNET dual-stack jails #627

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

waseigo
Copy link

@waseigo waseigo commented Nov 5, 2023

  1. Added an optional parameter ext_if6 for an IPv6 interface in pf.conf interface next to the default ext_if (for IPv4) in bastille.conf.
  2. Adjusted rdr.sh so that rdr rules are also added and persisted for the ext_if6 interface.

This makes it possible to have a non-VNET jail that can deal with packets coming from a Wireguard interface (IPv4) and from an Yggdrasil (IPv6) interface.

For example, I am running caddy in a non-VNET dual-stack jail, and this way I can have it reverse-proxy to other jails.

Prior to this change, if I didn't want to deal with VNET, I would have to have a separate non-VNET IPv6-only jail running caddy to deal with requests coming from the Yggdrasil interface.

This doesn't affect the creation of an IPv4-only jail.

I have not changed anything in create.sh. After creating an IPv4-only jail, I edit its jail.conf and add ip6.addr = fd80:... (in this case, a link-local address) and delete the line ip6 = new;

For an IPv6-only jail, an improvement to this would be to make create.sh set ip4 = disabled; (for which other scripts might need to be adjusted).

The changes to the "standard" pf.conf look like this:

ext_if=wg0
ext_if6=ygg0

set block-policy return
scrub in on { $ext_if, $ext_if6 } all fragment reassemble
set skip on lo

table <jails> persist
nat on $ext_if from <jails> to any -> ($ext_if:0)
nat on $ext_if6 from <jails> to any -> ($ext_if6:0)
rdr-anchor "rdr/*"

block in all
pass out quick keep state
antispoof for $ext_if inet
antispoof for $ext_if6 inet6
pass in inet proto tcp from any to any port ssh flags S/SA modulate state
pass in inet6 proto tcp from any to any port ssh flags S/SA modulate state

… to default ext_if (IPv4) interface in bastille.conf, and adjusted rdr.sh so that rdr rules are also added for the ext_if6 interface
@@ -45,6 +45,7 @@ bastille_conf_check
. /usr/local/etc/bastille/bastille.conf
# Set default values for config properties added during the current major version:
: "${bastille_network_pf_ext_if:=ext_if}"
: "${bastille_network_pf_ext_if:=ext_if6}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this variable is meant to be ${bastille_network_pf_ext_if6:=ext_if6}?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are correct... I fixed it locally but forgot to push.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@waseigo can you push the change so we can review it again?

@@ -62,7 +63,7 @@ bastille_perms_check() {
bastille_perms_check

## version
BASTILLE_VERSION="0.10.20231013"
BASTILLE_VERSION=b7d741b5cd3b0c758f0983fd9546e88fba0354d7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be included in the patch.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, will keep it in mind for next time!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@waseigo please then remove the change from your PR

@waseigo
Copy link
Author

waseigo commented Nov 20, 2023

@cedwards I am not terribly proficient at this (to put it mildly), so haven't run it through the gauntlet, so to say, to see if other things break.

@yaazkal yaazkal added the enhancement New feature or request label Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants