openbsdのポート転送/Natの問題

openbsdのポート転送/Natの問題

WAN でポート 80 を無効にすることはできません。理由はわかりません。

私の設定は、WANとして機能するホームネットワークとLANとして機能する「実験室」です。 WAN 192.168.0.0/24、LAN 192.168.5.0/24。ルータ wan インターフェイスは 192.168.0.113、LAN インターフェイスは 192.168.5.1 です。 Webサーバーは192.168.5.17にあり、ポート80を192.168.0.133に転送しようとしています。 WANで使用できるように設定してください。以下に現在のバージョンのルールとpfログを入れました。私の考えではトラフィックをリダイレクトしないようですが、その理由はわかりません。助けてくれてありがとう。追加情報が必要な場合は、喜んでご提供いたします。ありがとうございます!

ああ、sshルールはうまくいきます。おそらく、wanインターフェイスを使用し、他のシステムにリダイレクトしないようです。

また、ポート80 rdr-to 192.168.5.17を使用または使用せずに最後のルールを試しましたが、同じエラーが発生しました。

pflogメッセージを含めようとしましたが、スタック交換でスパムと呼ばれていました...

#no need to run rules on the loop back int
set skip on lo

#macro to set the external int to em0
ext_if = "em0"

#macro to set the internal int to the other eth int
int_if = "re0"

#macro for the webserver
web_server = "192.168.5.17"

#making table for people that we want to block
table <badguys> persist file "/etc/badguys"
block quick from <badguys>

#naming specific trusted IPs
trusted = "{ 192.168.0.155 }"

#blocking all inbound and outbound ip6 traffic
block inet6

#default policy, remember pf is a last match application unless you use quick
block all

#this is for passing and taging all internal traffic
pass in on $int_if tag ALLOWED

#perform NAT
match out on $ext_if inet from ($int_if:network) to any nat-to ($ext_if)

#pass out all of the packets that were tagged
pass out on $ext_if tagged ALLOWED

#allows traffic out from the host
pass out from { ($ext_if),$int_if }

#rule to let in ssh
pass in on $ext_if proto tcp from {192.168.0.0/24 $trusted} to {192.168.0.113} port 22 flags S/SA keep state \
                       (max-src-conn 5, max-src-conn-rate 5/5, \
                                  overload <badguys> flush global)

#trying to forward http

pass log on $int_if from 192.168.5.17 to any binat-to 192.168.0.113
pass in log on $ext_if proto tcp from any to 192.168.0.113 port 80 rdr-to 192.168.5.17

ベストアンサー1

ルールは必要ありませんbinat

pass in on $ext_if proto tcp to $(ext_if) port 80 rdr-to 192.168.5.17
pass out on $int_if proto tcp to 192.168.5.17 port 80

それだけで十分です。最後のルールは含まれません。

pass out from { ($ext_if),$int_if }

リダイレクトされたパケットは$ext_ifIPアドレスまたは$int_if

ホストで何が起こるのかを制御できるため、pass outWANとLANからの着信トラフィックのみをフィルタリングする単純なルールを追加し、他のすべてのルールを削除するpass out ...と作業が簡単になる可能性があります。

tcpdumpパケット(および対応する応答)が実際に転送され、リダイレクト/ NATされていることを確認するために外部および内部インターフェイスで使用することが役立ちます。また、Webサーバーでも同じことをお勧めします。

また、ルーティングの問題にも注意してください。 Web サーバーが応答を送信する場所を知っていることを確認します。あなたの例では、192.168.5.1が192.168.0.0/24に向かうパケットのゲートウェイ(またはデフォルトゲートウェイ)であることがわかっています。

おすすめ記事