FreeBSD Jail允许Ping/tracerouter命令
时间:2020-01-09 10:38:36 来源:igfitidea点击:
无法从FreeBSD监狱(监狱)ping通。
无法解析名称或将ftp/http用于端口,但是ping和traceroute访问被禁用。
如何允许虚拟化的监狱应用程序/用户执行traceroute和ping命令?
默认情况下,FreeBSD不允许监狱用户/应用创建原始套接字。
这是一项安全功能。
使用原始套接字,可以使用perl/python或nc等工具来创建原始套接字并发起攻击。
但是,可以使用sysctl命令从主机环境中修改监狱环境的这些方面。
security.jail.allow_raw_sockets MIB条目确定是否允许监狱根创建原始套接字。
将此MIB设置为1可使诸如ping和traceroute之类的实用程序在监狱内运行。
执行以下命令:
# sysctl security.jail.allow_raw_sockets=1
现在使用jexec登录到监狱:
host # jexec 1 csh jail# ping theitroad.local
将以下行添加到sysctl.conf中:
# echo 'security.jail.allow_raw_sockets=1' >> /etc/sysctl.conf
关于MIB的说明
这是可选配置。
MIB之上的变量会影响系统上的所有监狱。
换句话说,所有的监狱都将能够使用ping和traceroute命令。
您可以使用主机防火墙(例如PF)拒绝或允许访问某些监狱。
这是一个示例PF防火墙:
# interface
int_if="em0"
ext_if="em1"
# ICMP types
icmp_types = "{ echoreq, unreach }"
# Allowed ips for traceroute
troute_outbound_ips = "{ 10.24.55.101, 10.24.55.103, 10.24.55.111 }"
# Allowed ips for ping
ping_outbound_ips = "{ 10.24.55.103, 10.24.55.111 }"
# Some defaults
set block-policy return
set loginterface $ext_if
scrub in all
# Drop ALL - drop incoming and everything else
block log all
# skip loopback and vpn interface
set skip on {lo0, $int_if}
block in quick from urpf-failed
antispoof log for $ext_if
## your other rules STARTS ###
## add your other pf rules to open port and other stuff
# ...
# ...
## your other rules ENDS ###
### Allow ping and trace route from selected jails ###
pass out on $ext_if inet proto udp from $troute_outbound_ips to any port 33433 >< 33626 keep state
### Allow ping pong from selected jails ###
pass out on $ext_if inet proto icmp from $ping_outbound_ips to any icmp-type $icmp_types keep state

