ルートを変更する

以前に書いた通り、ルータを接続しているため、LANが少々複雑なトポロジとなっている。
Ciscoルータのルーティングテーブル

しかし、これではGbit化した意味が無いので、ストレージサーバにNICを複数挿し、ルートを分ける。
余っている100MのNICを追加すると、以下の通り。


# ifconfig -a
br0 Link encap:Ethernet HWaddr 00:25:22:6E:3A:51
inet addr:192.168.0.8 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::225:22ff:fe6e:3a51/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1382 errors:0 dropped:0 overruns:0 frame:0
TX packets:100 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:320861 (313.3 KiB) TX bytes:13176 (12.8 KiB)

eth0 Link encap:Ethernet HWaddr 00:25:22:6E:3A:51
inet6 addr: fe80::225:22ff:fe6e:3a51/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3755 errors:0 dropped:0 overruns:0 frame:0
TX packets:338 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:801523 (782.7 KiB) TX bytes:53185 (51.9 KiB)
Interrupt:106 Base address:0x8000

eth1 Link encap:Ethernet HWaddr 00:01:8E:B8:E9:77
inet addr:192.168.0.3 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::201:8eff:feb8:e977/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8066073 errors:1 dropped:0 overruns:0 frame:0
TX packets:4201239 errors:0 dropped:0 overruns:1 carrier:0
collisions:0 txqueuelen:1000
RX bytes:11945246089 (11.1 GiB) TX bytes:268622746 (256.1 MiB)
Interrupt:138 Base address:0xa800

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:291033 errors:0 dropped:0 overruns:0 frame:0
TX packets:291033 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:126457931 (120.5 MiB) TX bytes:126457931 (120.5 MiB)

sit0 Link encap:IPv6-in-IPv4
NOARP MTU:1480 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

virbr0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:305 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:25938 (25.3 KiB)

転送実験をしてみた後なので、eh1が優先してデータ転送に使用されていることがわかる。
(RX bytes:11945246089 (11.1 GiB) TX bytes:268622746 (256.1 MiB)より)

ルーティングテーブルを確認してみる。


# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 * 255.255.255.0 U 0 0 0 eth1
192.168.0.0 * 255.255.255.0 U 0 0 0 br0
192.168.122.0 * 255.255.255.0 U 0 0 0 virbr0
169.254.0.0 * 255.255.0.0 U 0 0 0 br0
default 192.168.0.1 0.0.0.0 UG 0 0 0 eth1

デフォルトで使用されるNICがeth1になっている。
Metricが全部0なのに速度で優先されないのが謎だが、これをどうにかする。
つまり

1)192.168.0.10以降のルータ宛のパケットはeth1を使用する
2)それ以外の全てのパケットは、eth0(br0)を使用する。

これを実現する。

参考自宅サーバを巡る冒険 | Linuxルーティング追加


1)
# vi /etc/sysconfig/network-scripts/route-eth1
192.168.0.10/32 via 192.168.0.10
192.168.1.0/16 via 192.168.0.10
192.168.2.0/16 via 192.168.0.10
192.168.3.0/16 via 192.168.0.10

2)
# vi /etc/sysconfig/network-scripts/route-eth0
0.0.0.0/0 via 192.168.0.1

ネットワーク再起動。


# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.10 192.168.0.10 255.255.255.255 UGH 0 0 0 eth1
192.168.3.0 192.168.0.10 255.255.255.0 UG 0 0 0 eth1
192.168.2.0 192.168.0.10 255.255.255.0 UG 0 0 0 eth1
192.168.1.0 192.168.0.10 255.255.255.0 UG 0 0 0 eth1
192.168.0.0 * 255.255.255.0 U 0 0 0 eth1
192.168.0.0 * 255.255.255.0 U 0 0 0 br0
192.168.122.0 * 255.255.255.0 U 0 0 0 virbr0
169.254.0.0 * 255.255.0.0 U 0 0 0 br0
default web.setup 0.0.0.0 UG 0 0 0 eth1
ルータへのルーティングは上手くいっているようだが、デフォルトが低速のNICになってしまう。
取り敢えず、暫定的にルーティングテーブルを書き換える。

# route add default gw 192.168.0.1 br0
# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.10 192.168.0.10 255.255.255.255 UGH 0 0 0 eth1
192.168.3.0 192.168.0.10 255.255.255.0 UG 0 0 0 eth1
192.168.2.0 192.168.0.10 255.255.255.0 UG 0 0 0 eth1
192.168.1.0 192.168.0.10 255.255.255.0 UG 0 0 0 eth1
192.168.0.0 * 255.255.255.0 U 0 0 0 eth1
192.168.0.0 * 255.255.255.0 U 0 0 0 br0
192.168.122.0 * 255.255.255.0 U 0 0 0 virbr0
169.254.0.0 * 255.255.0.0 U 0 0 0 br0
default web.setup 0.0.0.0 UG 0 0 0 br0
default web.setup 0.0.0.0 UG 0 0 0 eth1

# route del default gw 192.168.0.1 eth1
# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.10 192.168.0.10 255.255.255.255 UGH 0 0 0 eth1
192.168.3.0 192.168.0.10 255.255.255.0 UG 0 0 0 eth1
192.168.2.0 192.168.0.10 255.255.255.0 UG 0 0 0 eth1
192.168.1.0 192.168.0.10 255.255.255.0 UG 0 0 0 eth1
192.168.0.0 * 255.255.255.0 U 0 0 0 eth1
192.168.0.0 * 255.255.255.0 U 0 0 0 br0
192.168.122.0 * 255.255.255.0 U 0 0 0 virbr0
169.254.0.0 * 255.255.0.0 U 0 0 0 br0
default web.setup 0.0.0.0 UG 0 0 0 br0

これでGbitベースでやり取りできるはずだが、転送速度が10MB/s程しか出ない。
スイッチとサーバ間のケーブルはカテゴリ6だが、ゲートウェイ<->スイッチ間がカテゴリ5だ。
SMBはL3でやり取りする仕様なので、そのせいかもしれない。
それから、永続的にdefaultを設定する方法を見つけないとな。

このやり方だと、複数NICは無意味かもな。
まぁ、よしとするか。



追記

面倒なのと、スタティックルートでルートを排除する設定がわからないので、NIC一枚でルートを分ける。


# vi /etc/sysconfig/network-scripts/route-br0
192.168.0.10/32 via 192.168.0.10
192.168.1.0/24 via 192.168.0.10
192.168.2.0/24 via 192.168.0.10
192.168.3.0/24 via 192.168.0.10

# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.10 192.168.0.10 255.255.255.255 UGH 0 0 0 br0
192.168.3.0 192.168.0.10 255.255.255.0 UG 0 0 0 br0
192.168.2.0 192.168.0.10 255.255.255.0 UG 0 0 0 br0
192.168.1.0 192.168.0.10 255.255.255.0 UG 0 0 0 br0
192.168.0.0 * 255.255.255.0 U 0 0 0 br0
192.168.122.0 * 255.255.255.0 U 0 0 0 virbr0
169.254.0.0 * 255.255.0.0 U 0 0 0 br0
default web.setup 0.0.0.0 UG 0 0 0 br0

こちらの方が、手っ取り早い。
ちなみにNIC名がbr0なのは、仮想マシンの為にブリッジしているため。
普通はeth0とかeth1。