OpenBSD PF에서 GRE 터널의 트래픽에 NAT 적용

OpenBSD PF에서 GRE 터널의 트래픽에 NAT 적용

모두

Cisco 877 라우터와 OpenBSD 5.9를 실행하는 Linode VPS가 있고 그 사이에 GRE 터널이 실행되고 있는데 훌륭하게 작동하고 양쪽에서 핑할 수 있습니다. 트래픽을 WhatsMyIP.org로 라우팅하기 위해 Cisco 라우터에 고정 경로를 설정했지만(작동하는지 확인하기 위해), 최선을 다해 시도하지만 GRE 터널의 트래픽에 NAT를 적용하기 위해 OpenBSD의 PF를 얻을 수 없습니다. . 구성은 트래픽 경로를 분석하지만 어떤 상태도 생성되지 않습니다.

내가 달성하려는 것이 가능합니까? 내 토폴로지는 /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

토폴로지: GRE 터널 토폴로지

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로 설정되어 있는지 확인하는 데 도움이 됩니다.

관련 정보