全部
我有一個 Cisco 877 路由器和一個運行 OpenBSD 5.9 的 Linode VPS,其間運行著 GRE 隧道,效果很好,我可以從任意一側 ping 通。我已經在Cisco 路由器中設定了一條靜態路由,將流量路由到WhatsMyIP.org(這樣我就可以查看它是否正常工作),但是,盡我所能,我無法讓OpenBSD 的PF 將NAT 應用於來自GRE隧道的流量。配置解析、流量路由,但我沒有產生任何狀態。
我想要實現的目標有可能嗎?我的拓樸/etc.pf.conf
如下。 (註:根據 Bink 的回答進行更新)
# $OpenBSD: pf.conf,v 1.54 2014/08/23 05:49:42 deraadt Exp $
#
# See pf.conf(5) and /etc/examples/pf.conf
set skip on lo
block return # block stateless traffic
ext_if = "em0"
int_if = "gre0"
int_net = "192.168.2.0/24"
pass out on $ext_if from $int_net to any nat-to ($ext_if)
pass # establish keep-state
# By default, do not permit remote connections to X11
block return in on ! lo0 proto tcp to port 6000:6010
pass quick on gre proto gre no state
ifconfig 輸出(IP 已編輯):
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 32768
priority: 0
groups: lo
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
inet 127.0.0.1 netmask 0xff000000
em0: flags=18843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,MPSAFE> mtu 1500
lladdr f2:3c:91:0a:5b:a9
priority: 0
groups: egress
media: Ethernet autoselect (1000baseT full-duplex)
status: active
inet E.F.G.H netmask 0xffffff00 broadcast E.F.G.255
enc0: flags=0<>
priority: 0
groups: enc
status: active
pflog0: flags=141<UP,RUNNING,PROMISC> mtu 33144
priority: 0
groups: pflog
gre0: flags=9011<UP,POINTOPOINT,LINK0,MULTICAST> mtu 1476
priority: 0
groups: gre
tunnel: inet A.B.C.D -> E.F.G.H
inet 172.16.56.1 --> 172.16.56.2 netmask 0xffffff00
答案1
我不清楚為什麼你的路由器上需要靜態路由,但是無論如何,你的 pf.conf 中沒有與 NAT 相關的規則。在 pf.conf 中的巨集之後嘗試如下操作:
match out on egress from ! ( egress ) nat-to ( egress )
或者:
match out on $int_if from ! ( $int_if ) nat-to ( $int_if )
如果這些不起作用,請發布 ifconfig 的輸出。
答案2
看起來:
pass out on $ext_if from $int_net to any nat-to $ext_if
……不起作用,它必須是這樣的:
match out on $ext_if from $int_net to any nat-to $ext_if
pass on $ext_if from $int_net to any
此外,它有助於確保 net.inet.ip.forwarding 設定為 1。