オープンVPNルーティング

オープンVPNルーティング

これまで、暗号化されていない openvpn トンネルを使用して、サーバー A とサーバー B 間の仮想リンクを正常に作成しました。サーバーBからのトラフィックの一部をサーバーAを介してルーティングしようとしています。サーバーBには5つの外部IPがあり、5つのローカルVPN IPを追加してサーバーAの5つのIPにトラフィックをリダイレクトしようとしています。これにより、サーバーBに世界中の10の異なる発信IPが提供されます。明らかに、両方のサーバーでいくつかのルーティングを実行する必要がありますが、一日中検索して読み取った後も結果は表示されません。

私がやった

ip route add default via 10.0.0.2 dev tun0 table vpn_table
ip rule add from 10.0.0.1/32 table vpn_table
ip rule add to 10.0.0.2/32 table vpn_table
ip route flush cache

サーバーBでは、サーバーAと同じ状況ですが、IPが交換されました。ただし、サーバーBでこれを行うと機能wget --bind-address=10.0.0.1 somewebsiteしません。サーバーAがリクエストを処理する方法がわからないためです。

誰もが正しい方向に私を指すことができますか?

編集する

誰かがサーバーAがIPルールを必要としないことを提案したので、現在の状況は次のとおりです。

  1. openvpnリンク設定
  2. サーバーBIで上記の4つのipコマンドを実行します。

サーバーAの一部のルーティング情報がまだ欠落しているようです。wget --bind-address=10.0.0.1 http://www.cnn.comサーバーBで実行したときにサーバーAのtcpdumpが出力する内容は次のとおりです。

tcpdump: WARNING: arptype 65534 not supported by libpcap - falling back to cooked socket
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on tun0, link-type LINUX_SLL (Linux cooked), capture size 96 bytes
07:11:58.787908 IP 10.0.0.1.42802 > 157.166.248.10.80: S 2416144580:2416144580(0) win 14600 <mss 1410,sackOK,timestamp 858359606 0,nop,wscale 7>
07:11:59.786129 IP 10.0.0.1.42802 > 157.166.248.10.80: S 2416144580:2416144580(0) win 14600 <mss 1410,sackOK,timestamp 858359856 0,nop,wscale 7>
07:12:01.788535 IP 10.0.0.2 > 10.0.0.1: ICMP host 157.166.248.10 unreachable, length 68
07:12:01.788545 IP 10.0.0.2 > 10.0.0.1: ICMP host 157.166.248.10 unreachable, length 68

サーバーBのWgetは次のように言います。

Connecting to www.cnn.com (www.cnn.com)|157.166.248.11|:80... failed: No route to host.

2014年5月19日に編集

サーバーAにSNATを追加し、サーバーAのtcpdumpが私に提供します(93.184.216.119 = www.example.com、1.2.3.4 =サーバーAの外部IP、10.0.0.1ソースからのパケット)

09:29:44.114475 IP 10.0.0.1.54691 > 93.184.216.119.80: S 717252699:717252699(0) win 14600 <mss 1410,sackOK,timestamp 903625938 0,nop,wscale 7>
09:29:45.113546 IP 10.0.0.1.54691 > 93.184.216.119.80: S 717252699:717252699(0) win 14600 <mss 1410,sackOK,timestamp 903626188 0,nop,wscale 7>
09:29:47.116587 IP 1.2.3.4 > 10.0.0.1: ICMP host 93.184.216.119 unreachable, length 68
09:29:47.116668 IP 1.2.3.4 > 10.0.0.1: ICMP host 93.184.216.119 unreachable, length 68
09:29:47.119289 IP 10.0.0.1.54691 > 93.184.216.119.80: S 717252699:717252699(0) win 14600 <mss 1410,sackOK,timestamp 903626689 0,nop,wscale 7>
09:29:50.120591 IP 1.2.3.4 > 10.0.0.1: ICMP host 93.184.216.119 unreachable, length 68

したがって、サーバーAのSNATが機能しているように見えますが、要求されたWebサイトに接続できません。サーバーA iptablesリスト:

SNAT       all  --  10.0.0.1             anywhere            to:1.2.3.4

サーバーA IPルールのリスト:

0:      from all lookup local
32766:  from all lookup main
32767:  from all lookup default

サーバー 'route -n' の一部:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.0.1        0.0.0.0         255.255.255.255 UH    0      0        0 tun0

ゲートウェイは0.0.0.0です。これは関連することができますか?

ベストアンサー1

いくつかの質問があります:

  1. パケットを元の場所にルーティングすることは意味がありません。今すぐ

    ip rule add from 10.0.0.1/32 table vpn_table
    

    サーバーAでは省略する必要があります(ip rule add to...必要ありません)。サーバーAには「通常の」ルーティングがあります。ただし、サーバーB(BのIPアドレス用)にこれらのルールを設定する必要があります。

  2. サーバーAでSNATを実行する必要があります。似ている

    iptables -t nat -A POSTROUTING -s 10.0.0.1 -j SNAT --to-source 1.2.3.4
    

おすすめ記事