概要 - ホームLAN(192.168.1.0/24)に1つのネットワークカード、プライベート内部対仮想ボックスネットワーク(10.9.9.0/24)に1つのネットワークカード、およびPassを使用してFreeBSD仮想マシンを設定したいです。 2つの間を行き来するすべてのトラフィック。
長いLinuxユーザー(サーバーのDebian)ですが、FreeBSDを1日ほど使用しました。 :)
とにかく私の研究室には2つのネットワークインターフェースを備えた仮想マシンがあります。 1つはホームLANに接続され、もう1つは内部専用ネットワークに接続されます。このシステムはブロックレスルータに設定されており、送信元や宛先に関係なく、eth0とeth1の間でパケットを転送するだけです。 iptablesを使うと簡単です。
iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
しかし、私は部分的な成功だけでpfで動作するように努めてきました。
そして
gateway_enable="YES"
pf_enable="YES"
pf_rules="/etc/pf.conf"
私の中に/etc/rc.conf
含ま/etc/pf.conf
れる
pass from em1:network to any keep state
pass from em0:network to any keep state
pass in inet proto tcp to any keep state
pass in inet proto udp to any keep state
pass out inet proto tcp to any keep state
pass out inet proto udp to any keep state
内部VMにのみ接続されたライブCD VMを起動でき、em1のIPをデフォルトゲートウェイに設定し、em1、ping em0をpingできますが、実行中のホストvbox、または自分のLANまたはhttp、sshを介して他のコンピュータをpingすることはできません。そして他の接続。
[root@bsdtest ~]# pfctl -sa
FILTER RULES:
pass in inet proto tcp all flags S/SA keep state
pass in inet proto udp all keep state
pass out inet proto tcp all flags S/SA keep state
pass out inet proto udp all keep state
pass inet from 10.9.9.0/24 to any flags S/SA keep state
pass inet from 192.168.1.0/24 to any flags S/SA keep state
STATES:
all tcp 192.168.1.90:22 <- 192.168.1.10:48102 ESTABLISHED:ESTABLISHED
all udp 192.168.1.2:53 <- 10.9.9.5:59075 NO_TRAFFIC:SINGLE
all udp 10.9.9.5:59075 -> 192.168.1.2:53 SINGLE:NO_TRAFFIC
all udp 192.168.1.2:53 <- 10.9.9.5:34207 NO_TRAFFIC:SINGLE
all udp 10.9.9.5:34207 -> 192.168.1.2:53 SINGLE:NO_TRAFFIC
all udp 192.168.1.2:53 <- 10.9.9.5:43515 NO_TRAFFIC:SINGLE
all udp 10.9.9.5:43515 -> 192.168.1.2:53 SINGLE:NO_TRAFFIC
all udp 192.168.1.2:53 <- 10.9.9.5:1636 NO_TRAFFIC:SINGLE
all udp 10.9.9.5:1636 -> 192.168.1.2:53 SINGLE:NO_TRAFFIC
all udp 192.168.1.2:53 <- 10.9.9.5:60124 NO_TRAFFIC:SINGLE
all udp 10.9.9.5:60124 -> 192.168.1.2:53 SINGLE:NO_TRAFFIC
all udp 192.168.1.2:53 <- 10.9.9.5:8866 NO_TRAFFIC:SINGLE
all udp 10.9.9.5:8866 -> 192.168.1.2:53 SINGLE:NO_TRAFFIC
all udp 192.168.1.2:53 <- 10.9.9.5:25534 NO_TRAFFIC:SINGLE
all udp 10.9.9.5:25534 -> 192.168.1.2:53 SINGLE:NO_TRAFFIC
all udp 192.168.1.2:53 <- 10.9.9.5:30141 NO_TRAFFIC:SINGLE
all udp 10.9.9.5:30141 -> 192.168.1.2:53 SINGLE:NO_TRAFFIC
INFO:
Status: Enabled for 0 days 00:08:28 Debug: Urgent
State Table Total Rate
current entries 17
searches 1990 3.9/s
inserts 253 0.5/s
removals 236 0.5/s
Counters
match 253 0.5/s
bad-offset 0 0.0/s
fragment 0 0.0/s
short 0 0.0/s
normalize 0 0.0/s
memory 0 0.0/s
bad-timestamp 0 0.0/s
congestion 0 0.0/s
ip-option 0 0.0/s
proto-cksum 0 0.0/s
state-mismatch 0 0.0/s
state-insert 0 0.0/s
state-limit 0 0.0/s
src-limit 0 0.0/s
synproxy 0 0.0/s
map-failed 0 0.0/s
TIMEOUTS:
tcp.first 120s
tcp.opening 30s
tcp.established 86400s
tcp.closing 900s
tcp.finwait 45s
tcp.closed 90s
tcp.tsdiff 30s
udp.first 60s
udp.single 30s
udp.multiple 60s
icmp.first 20s
icmp.error 10s
other.first 60s
other.single 30s
other.multiple 60s
frag 30s
interval 10s
adaptive.start 6000 states
adaptive.end 12000 states
src.track 0s
LIMITS:
states hard limit 10000
src-nodes hard limit 10000
frags hard limit 5000
table-entries hard limit 200000
OS FINGERPRINTS:
758 fingerprints loaded
[root@bsdtest ~]#
どんなアイデアがありますか? 10.9.9.5(マイライブディスク)から192.168.1.2までのudpトラフィックに関するラインは、私のホームLANネームサーバーへのDNSに使用されますが、応答は到着しません...これはhttpリクエストが示すものです。
[root@bsdtest ~]# pfctl -sa | grep 80
all tcp 192.168.1.10:80 <- 10.9.9.5:59436 CLOSED:SYN_SENT
all tcp 10.9.9.5:59436 -> 192.168.1.10:80 SYN_SENT:CLOSED
all tcp 192.168.1.10:80 <- 10.9.9.5:59438 CLOSED:SYN_SENT
all tcp 10.9.9.5:59438 -> 192.168.1.10:80 SYN_SENT:CLOSED
アイデアはありますか?
ベストアンサー1
さて、解決策を見つけました。
私の/etc/rc.confは大丈夫です...
/etc/pf.conf は次のようになります。
# cat /etc/pf.conf
ext_if="em0"
int_if="em1"
boxnet = $int_if:network
homenet = $ext_if:network
nat on $ext_if from $boxnet to any -> ($ext_if)
pass quick from { lo0, $boxnet, $homenet } to any keep state
変数が多すぎるため、元のem0 / em1のみを使用できます。とにかく、これはあなたに -
[root@bsdtest ~]# pfctl -vnf /etc/pf.conf
ext_if = "em0"
int_if = "em1"
icmp_types = "echoreq"
boxnet = "em1:network"
homenet = "em0:network"
nat on em0:network inet from 10.9.9.0/24 to any -> 192.168.1.0/24
nat on em1:network inet from 192.168.1.0/24 to any -> 10.9.9.0/24
pass quick inet from 127.0.0.0/8 to any flags S/SA keep state
pass quick inet from 192.168.1.0/24 to any flags S/SA keep state