I messed up sshd service when I'm following Bastille tutorial about network configuration inside a jail.
First, create the loopback interface:
Second, enable the firewall:
Create the firewall rules:
/etc/pf.conf
The nat routes traffic from the loopback interface to the external interface for outbound access.
The
Note that if you are redirecting ports where the host is also listening (eg. ssh) you should make sure that the host service is not listening on the cloned interface - eg. for ssh set sshd_flags in rc.conf
Finally, start up the firewall:
At this point you’ll likely be disconnected from the host. Reconnect the ssh session and continue.
This step only needs to be done once in order to prepare the host.
Look I'm not able to connect anymore
First, create the loopback interface:
Code:
ishmael ~ # sysrc cloned_interfaces+=lo1
ishmael ~ # sysrc ifconfig_lo1_name="bastille0"
ishmael ~ # service netif cloneup
Code:
ishmael ~ # sysrc pf_enable="YES"
/etc/pf.conf
Code:
ext_if="vtnet0"
set block-policy return
scrub in on $ext_if all fragment reassemble
set skip on lo
table <jails> persist
nat on $ext_if from <jails> to any -> ($ext_if:0)
rdr-anchor "rdr/*"
block in all
pass out quick keep state
antispoof for $ext_if inet
pass in inet proto tcp from any to any port ssh flags S/SA modulate state
- Make sure to change the ext_if variable to match your host system interface.
- Make sure to include the last line (port ssh) or you’ll end up locked out.
Code:
nat on $ext_if from <jails> to any -> ($ext_if)
Code:
rdr-anchor "rdr/*"
rdr-anchor “rdr/*”
enables dynamic rdr rules to be setup using the bastille rdr command at runtime - eg.
Code:
bastille rdr <jail> tcp 2001 22 # Redirects tcp port 2001 on host to 22 on jail
bastille rdr <jail> udp 2053 53 # Same for udp
bastille rdr <jail> list # List dynamic rdr rules
bastille rdr <jail> clear # Clear dynamic rdr rules
Code:
sshd_flags=”-o ListenAddress=<hostname>”
Code:
ishmael ~ # service pf restart
This step only needs to be done once in order to prepare the host.
Look I'm not able to connect anymore