Because in between things have changed and I got no answer from the Forum, I like to try a new post. What do I have?
-FreeBSD 13.0
-A jail with a running webserver
-I'm using the firewall IPFW with NAT settings to connect to the jail from outside the host and from inside to outside. Now this works without any other firewall rules.
The solution, to reach the web server in the jail with ipfw NAT, is:
First delete all ipfw firwall settings
Then restart the NAT ipfw rules
"restart" will restart a ipfw script with these rules (I abstract the IP-numbers for security reasons):
Normally without the jail I use /etc/rc.firewall.
But when I activate this, then the connection to the the jail get losing. I tested this with:
When I activate in rc.conf the firewall rules with
I found out, with deleting rules by rules, that there are some rules in the "workstation" firewall set, that block the connection to the jail:
Q1)I do not understand this rules exactly and why these rules are blocking the jail connection? How could I fixed this?
I have try to call the
Calling the ipfw firewall regular in rc.conf these errors are gone but again also the connection to the jail.
So this is no solution. What to do without touching the standard FreeBSD firewall script for ipfw?
Q2) Also, I found a usefull ipfw rule in the manual
But without the workstation firewall rules - just this one rule in addition, the connection to the jail is also losing.
How can I use the antispoof rule with the NAT rules for the jail?
-FreeBSD 13.0
-A jail with a running webserver
-I'm using the firewall IPFW with NAT settings to connect to the jail from outside the host and from inside to outside. Now this works without any other firewall rules.
The solution, to reach the web server in the jail with ipfw NAT, is:
First delete all ipfw firwall settings
ipfw -q -f flush
ipfw nat show config
ipfw nat 1 delete
Then restart the NAT ipfw rules
/etc/rc.d/ipfw restart
"restart" will restart a ipfw script with these rules (I abstract the IP-numbers for security reasons):
That is all what it needs. But there is no more a firewall. That make no sense: to have a jail for more security and not using the firewall# /etc/ipfw.rules
#
#-----------------------------------------------------------------------
# NAT for Jails (IPFW)
cmd="ipfw -q add"
nwinterface="<my host network interface>"
#sh /etc/rc.firewall workstation
ipfw nat 1 config if $nwinterface redirect_port tcp Jail.IP.IP.IP:443 443 redirect_port tcp Jail.IP.IP.IP:80 80
${cmd} 410 nat 1 ip from Jail.IP.0.0/27 to any out via $nwinterface
${cmd} 420 nat 1 ip from any to HOST.IP.IP.IP
Normally without the jail I use /etc/rc.firewall.
But when I activate this, then the connection to the the jail get losing. I tested this with:
curl -v -m 5 www.myvirtdomain.tld
and curl -v -m 8 -k https://www.433domain.tld
When I activate in rc.conf the firewall rules with
firewall_type="workstation"
I can see the list of rules with: ipfw list | less
I found out, with deleting rules by rules, that there are some rules in the "workstation" firewall set, that block the connection to the jail:
Code:
0100 allow ip from any to any via lo0
1200 allow tcp from me to any established
1300 allow tcp from me to any setup keep-state :default
I have try to call the
firewall_type="workstation"
after ipfw NAT rules. That has first worked, but then there was a very strange error with bind:
Code:
rndc stop
error: rndc: connect failed: 127.0.0.1#953: permission denied
Code:
host <mydomain.com>
error: net.c:538: probing sendmsg() with IP_TOS=b8 failed: Permission denied
So this is no solution. What to do without touching the standard FreeBSD firewall script for ipfw?
Q2) Also, I found a usefull ipfw rule in the manual
Code:
ipfw add deny ip from any to any not antispoof in
How can I use the antispoof rule with the NAT rules for the jail?
Last edited by a moderator: