/etc/rc.conf
ifconfig_alc0=" inet 193.26.xxx.xxx netmask 255.255.255.248"
ifconfig_em0=" inet 192.168.0.1 netmask 255.255.0.0"

gateway_enable="YES"
defaultrouter="193.26.xxx.zzz"

firewall_enable="YES"
firewall_script="/etc/firewall"
firewall_logging="YES"
firewall_nat_enable="YES"
firewall_nat_interface="alc0"

Скрипт с правилами
/etc/firewall
#!/bin/sh
FwCMD="/sbin/ipfw"
LanOut="alc0"
LanIn="em0"

IpOut="193.26.xxx.xxx"
IpIn="192.168.0.1"
NetMask="16"
NetIn="192.168.0.0"

${FwCMD} -f flush
${FwCMD} add check-state

${FwCMD} add allow ip from any to any via ${LanIn}

${FwCMD} nat 1 config log if ${LanOut} same_ports unreg_only
${FwCMD} add nat 1 all from ${NetIn}/${NetMask} to any
${FwCMD} add nat 1 all from any to ${IpOut}

${FwCMD} add allow tcp from any to ${IpOut} 2332 via ${LanOut}
${FwCMD} add allow tcp from any to ${IpOut} 5900 via ${LanOut}

${FwCMD} add deny ip from any to any

sysctl
net.inet.ip.fw.one_pass: 1

IPFW скомпилирован по умолчанию открытм.
Подскажите как закрыть файрволом ${LanOut} оставив открытыми порты 2332 и 5900 
и при этом оставить рабочим нат?
В гуглил 100500 статей но чет не получается сделать.

Ответить