使用带环回功能的 IPFW 进行 FreeBSD jail - 无法连接环回接口

使用带环回功能的 IPFW 进行 FreeBSD jail - 无法连接环回接口

我正在尝试配置一个带有环回接口的 IP 监狱,但我不确定如何配置 IPFW 规则以允许流量在监狱和服务器上的网卡之间传递。

我已经关注http://blog.burghardt.pl/2009/01/multiple-freebsd-jails-sharing-one-ip-address/https://forums.freebsd.org/viewtopic.php?&t=30063

但没有成功,这是我的ipfw.rules

# vim /usr/local/etc/ipfw.rules

ext_if="igb0"
jail_if="lo666"
IP_PUB="192.168.0.2"
IP_JAIL_WWW="10.6.6.6"
NET_JAIL="10.6.6.0/24"

IPF="ipfw -q add"
ipfw -q -f flush
#loopback
$IPF 10 allow all from any to any via lo0
$IPF 20 deny all from any to 127.0.0.0/8
$IPF 30 deny all from 127.0.0.0/8 to any
$IPF 40 deny tcp from any to any frag
# statefull
$IPF 50 check-state
$IPF 60 allow tcp from any to any established
$IPF 70 allow all from any to any out keep-state
$IPF 80 allow icmp from any to any
# open port ftp (20,21), ssh (22), mail (25)
# ssh (22), , dns (53) etc
$IPF 120 allow tcp from any to any 21 out
$IPF 130 allow tcp from any to any 22 in
$IPF 140 allow tcp from any to any 22 out
$IPF 150 allow tcp from any to any 25 in
$IPF 160 allow tcp from any to any 25 out
$IPF 170 allow udp from any to any 53 in
$IPF 175 allow tcp from any to any 53 in
$IPF 180 allow udp from any to any 53 out
$IPF 185 allow tcp from any to any 53 out

# HTTP
$IPF 300 skipto 63000 tcp from any to me http,https setup keep-state
$IPF 300 skipto 63000 tcp from any to me http,https setup keep-state
# deny and log everything
$IPF 500 deny log all from any to any
# NAT
$IPF 63000 divert natd ip from any to any via $jail_if out
$IPF 63000 divert natd ip from any to any via $jail_if in

但是当我创建一个监狱时:

# ezjail-admin create -f continental -c zfs node 10.6.6.7
/usr/jails/node/.
/usr/jails/node/./etc
/usr/jails/node/./etc/resolv.conf
/usr/jails/node/./etc/ezjail.flavour.continental
/usr/jails/node/./etc/rc.d
/usr/jails/node/./etc/rc.conf
4 blocks
find: /usr/jails/node/pkg/: No such file or directory
Warning: IP 10.6.6.7 not configured on a local interface.
Warning: Some services already seem to be listening on all IP, (including 10.6.6.7)
  This may cause some confusion, here they are:
root     syslogd    1203  6  udp6   *:514                 *:*
root     syslogd    1203  7  udp4   *:514                 *:*

我收到这些警告,然后当我进入监狱环境时,我无法安装任何端口。

任何建议都非常感谢。

答案1

您链接的指南在其示例中都使用了 pf 防火墙而不是 ipfw,因此如果您也使用 pf,可能会更容易排除故障。我自己只熟悉配置 pf,但我可以建议您尝试一些方法。

  1. 使用该命令确保您使用的外部和环回接口确实处于活动状态ifconfig
  2. 确保/etc/rc.conf以下几行存在:

cloned_interfaces="lo666"

ifconfig_lo666_alias0="inet 10.6.6.6 网络掩码 255.255.255.255"

gateway_enable="YES"

如果您决定使用 pf 而不是 ipfw,我可以尽力提供进一步的帮助。

相关内容