Wireguardを使ってiptablesを正しく設定するには?

Wireguardを使ってiptablesを正しく設定するには?

2つの仮想マシン(サーバー、クライアント)がネットワーク10.0.0.0/24に接続されており、wireguardを実行しています。サーバーの構成は次のとおりです。

[Interface]
PrivateKey = <server_private_key>
Address = 172.0.0.1/24 
ListenPort = 10001

[Peer]
PublicKey = <client_public_key>
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 10

サーバー iptables ルール

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere  

クライアントの構成は次のとおりです。

[Interface]
PrivateKey = <client_private_key>
Address = 172.0.0.2/24 

[Peer]
PublicKey = <server_public_key>
AllowedIPs = 172.0.0.0/24
Endpoint = 172.0.0.1:10001 
PersistentKeepalive = 10

とクライアントiptablesルール

target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere 

クライアントにpingを実行すると、172.0.0.2次の結果が表示されます。

PING 172.0.0.2 (172.0.0.2) 56(84) bytes of data.
From 172.0.0.1 icmp_seq=1 Destination Host Unreachable
ping: sendmsg: Destination address required
From 172.0.0.1 icmp_seq=2 Destination Host Unreachable
ping: sendmsg: Destination address required
From 172.0.0.1 icmp_seq=3 Destination Host Unreachable
ping: sendmsg: Destination address required
^C
--- 172.0.0.2 ping statistics ---
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 2045ms

サーバーにpingを送信すると、172.0.0.1すべてのパケットが破棄されます。

PING 172.0.0.1 (172.0.0.1) 56(84) bytes of data.
^C
--- 172.0.0.1 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2053ms

ベストアンサー1

おすすめ記事