アドバンスドIPルーティングを試してみる

ISPを切り替えるのでこれをチャンスと思いアドバンスドIPルーティングを
試してみました。

二つのルーター(Unnumbered)にISPを設定し、サーバを接続しました。
ISP1側をeth0としてインターフェイスにIPを割り当てます。

# ifconfig eth0 202.61.XXX.74 netmask 255.255.255.248

ISP2側のIPをeth0のエイリアスIPとして割り当てます。

# ifconfig eth0 add 27.96.XXX.146 netmask 255.255.255.240

以下のように割り当てられました。

[root@test ~]# ifconfig eth0
eth0 ???? Link encap:Ethernet? HWaddr 54:52:00:XX:XX:XX
inet addr:202.61.XXX.74? Bcast:202.61.XXX.79? Mask:255.255.255.240
UP BROADCAST RUNNING MULTICAST? MTU:1500? Metric:1
RX packets:20 errors:0 dropped:0 overruns:0 frame:0
TX packets:17 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1851 (1.8 KiB)? TX bytes:1308 (1.2 KiB)

[root@test ~]# ifconfig eth0:0
eth0:0??? Link encap:Ethernet? HWaddr 54:52:00:XX:XX:XX
inet addr:27.96.XXX.146? Bcast:202.61.XXX.79? Mask:255.255.255.248
UP BROADCAST RUNNING MULTICAST? MTU:1500? Metric:1

デフォルトゲートウェイを設定します。
デフォルトゲートウェイはISP1側とします。

# route add default gw 202.61.XXX.73

続き、ISP1からの通信はISP1経由で返す、ISP2からの通信はISP2経由で返すよう設定
していきます。

アドバンスドIPルーティング用に、各ISPのテーブルを定義します。

# vi /etc/iproute2/rt_tables
100 isp1
101 isp2

各ISP向けにルーティング設定を行います。
テーブルごとにデフォルトゲートウェイを設定します。

# ip route add default via 202.61.XXX.73 table isp1
# ip route add default via 27.96.XXX.145 table isp2

出口IPによって使うテーブルを使い分けるように設定します。

# ip rule add from 202.61.XXX.74 table isp1 priority 100
# ip rule add from 27.96.XXX.146 table isp2 priority 101

あとは、同一ネットワーク向けのルーティングも行っておきます。

# ip route add 202.61.XXX.72/29 dev eth1 table isp1
# ip route add 27.96.XXX.144/28 dev eth1 table isp2

これで、両ISP経由の応答ができるようになりました。

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <img localsrc="" alt="">