全て
私は Cisco 877 ルーターと OpenBSD 5.9 を実行する Linode VPS を所有しており、その間に GRE トンネルが稼働しています。これはうまく機能しており、どちらの側からも ping を実行できます。Cisco ルーターに静的ルートを設定してトラフィックを WhatsMyIP.org にルーティングしています (動作しているかどうかを確認できます)。しかし、どんなに試しても、OpenBSD の PF で GRE トンネルからのトラフィックに NAT を適用できません。構成は解析され、トラフィックはルーティングされますが、状態は生成されません。
私が達成しようとしていることは可能でしょうか? 私のトポロジーは/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 に設定されていることを確認することも役立ちます。