openvpn:iptablesが渡さない

openvpn:iptablesが渡さない

次のトポロジがあります。 ここに画像の説明を入力してください。

上記のiptablesルールに従います。https://community.openvpn.net/openvpn/wiki/BridgingAndRouting

これが出力ですiptables -L -v

Chain INPUT (policy ACCEPT 1236 packets, 145K bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain FORWARD (policy ACCEPT 407 packets, 25288 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 ACCEPT     all  --  any    any     anywhere             anywhere             ctstate RELATED,ESTABLISHED
    0     0 ACCEPT     all  --  eth0   eth1    192.168.0.0/24       anywhere             ctstate NEW
    0     0 ACCEPT     all  --  tun0   eth1    10.8.0.0/24          anywhere             ctstate NEW
    0     0 ACCEPT     all  --  tun0   eth0    10.8.0.0/24          192.168.0.0/24       ctstate NEW

Chain OUTPUT (policy ACCEPT 1691 packets, 230K bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain LOGGING (0 references)
 pkts bytes target     prot opt in     out     source               destination

これはの出力です設定されている場合:

eth0      Link encap:Ethernet  HWaddr 00:90:e8:45:96:79
          inet addr:192.168.0.10  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::290:e8ff:fe45:9679/64 Scope:Link
          UP BROADCAST RUNNING ALLMULTI MULTICAST  MTU:1500  Metric:1
          RX packets:47251 errors:0 dropped:341 overruns:0 frame:0
          TX packets:35463 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:6700218 (6.3 MiB)  TX bytes:6348389 (6.0 MiB)

eth1      Link encap:Ethernet  HWaddr 00:90:e8:45:96:7a
          inet addr:213.179.150.110  Bcast:213.179.150.111  Mask:255.255.255.248
          inet6 addr: fe80::290:e8ff:fe45:967a/64 Scope:Link
          UP BROADCAST RUNNING ALLMULTI MULTICAST  MTU:1500  Metric:1
          RX packets:431735 errors:0 dropped:1629 overruns:0 frame:0
          TX packets:515499 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:55214512 (52.6 MiB)  TX bytes:93401691 (89.0 MiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:124 errors:0 dropped:0 overruns:0 frame:0
          TX packets:124 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:12872 (12.5 KiB)  TX bytes:12872 (12.5 KiB)

tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          inet addr:10.8.0.1  P-t-P:10.8.0.1  Mask:255.255.255.0
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:105 errors:0 dropped:0 overruns:0 frame:0
          TX packets:239 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:8100 (7.9 KiB)  TX bytes:18522 (18.0 KiB)

パス-n

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         213.179.150.105 0.0.0.0         UG    0      0        0 eth1
10.8.0.0        0.0.0.0         255.255.255.0   U     0      0        0 tun0
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
213.179.150.104 0.0.0.0         255.255.255.248 U     0      0        0 eth1

クライアントが実行中で、クライアントのトンインターフェイスをpingできるため、トンネルが確立されているようです。

PING 10.8.0.2 (10.8.0.2) 56(84) bytes of data.
64 bytes from 10.8.0.2: icmp_req=8 ttl=64 time=704 ms
64 bytes from 10.8.0.2: icmp_req=9 ttl=64 time=824 ms
64 bytes from 10.8.0.2: icmp_req=10 ttl=64 time=704 ms
64 bytes from 10.8.0.2: icmp_req=11 ttl=64 time=723 ms
64 bytes from 10.8.0.2: icmp_req=12 ttl=64 time=725 ms
64 bytes from 10.8.0.2: icmp_req=13 ttl=64 time=665 ms

ただし、eth0(192.168.0.10)で「10.8.0.2」をpingできません。

PING 10.8.0.2 (10.8.0.2) from 192.168.0.10 eth0: 56(84) bytes of data.
From 192.168.0.10 icmp_seq=1 Destination Host Unreachable
From 192.168.0.10 icmp_seq=2 Destination Host Unreachable
From 192.168.0.10 icmp_seq=3 Destination Host Unreachable

私の考えでは、デフォルトゲートウェイがeth0と同じサブネットにないため、pingが失敗するようです。しかし、eth0のトラフィックをtun0に転送することはできませんか?私がここで何を見逃しているのでしょうか?

eth0からtun0への転送ルールを追加してみました。 Chain FORWARD(ポリシーACCEPT 0パケット、0バイト)

 pkts bytes target     prot opt in     out     source               destination
    0     0            all  --  eth0   tun0    anywhere             anywhere

しかし、役に立たない!

私は以下を言及することを忘れました。

sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1

これは私のNATテーブルです。

Chain PREROUTING (policy ACCEPT 1 packets, 28 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain INPUT (policy ACCEPT 1 packets, 28 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 MASQUERADE  all  --  any    tun0    anywhere             10.8.0.0/24
    0     0 MASQUERADE  all  --  any    eth1    10.8.0.0/24          anywhere
    0     0 MASQUERADE  all  --  any    tun0    192.168.0.0/24       anywhere

ベストアンサー1

おすすめ記事