11
新春ハッタリ企画The Art of Network Protocols
- RIP編 -
2012年1月28日東京OpenSolaris勉強会
きりんぐみ
秋山 尚之The Art of Network Protocols, RIP Edition by AKIYAMA, Takayuki
33
前回の発表
•新春大ボラ企画耐故障性状態可視化ツールの試作
•2011年1月29日•東京OpenSolaris勉強会•http://kirin-gumi.net/doc/20110129/
Last presentation in January 29, 2011
44
略歴
•某ISPで15年ほどお手伝い。•立ち上げからその後の運用、構築まで•サーバ•ネットワーク•ツール作り
Career: an ISP engineer
55
サーバ(1)
•必須•DNS•Mail
•少なくとも当初はおまけ扱い•ユーザ用Web•News
Servers
66
サーバ(2)
•認証、課金•radius•DB
•AP用•管理用
•機器の状態管理•運用支援ツール
Servers (continued)
77
ネットワーク機器
•HUB、L2SW•L3SW、ルータ•ATM SW•ダイヤルアップルータ
Networking devices
88
ネットワークプロトコル
•可視化で教育的効果が得られそうなもの•STP•VRRP•RIP•OSPF•BGP
Network protocols
99
今回のテーマ
•RIP•Routing Information Protocol (RFC 1058)•RIP Version 2 (RFC 2453)•RIPng for IPv6 (RFC 2080)
RIP is the theme of this presentation.
1010
ルーティングの必要性
Sample network diagram
Client Server1
Server2
Server3
Router1
Router2
Network1
Network2
Network0Network3
1111
同一ネットワーク内の通信
Communication in a network
Client Server1
Server2
Server3
Router1
Router2
Network1
Network2
Network0Network3
1212
デフォルトルートを指定
Adding a default route
Client Server1
Server2
Server3
Router1
Router2
Network1
Network2
Network0Network3
デフォルトルート
1313
ルータに経路があれば
Routing on the routers
Client Server1
Server2
Server3
Router1
Router2
Network1
Network2
Network0Network3
デフォルトルート
1414
スタティックルーティング
Static routing
Router1
Router2
Network1
Network2
Network0Network3
Network3はあちら
Network1とNetwork2はあちら
1515
ダイナミックルーティング
Dynamic routing
Router1
Router2
Network1
Network2
Network0Network3
Network1とNetwork2はこちら
Network3はこちら
1616
RIP(1)
RIP
•ディスタンスベクタアルゴリズム•宛先へのディスタンス(メトリック)を隣接ルータ間で交換
•メトリックはホップ数(ルータを経由すると+1)
•各ルータはメトリックが最小のものを採用•メトリックは1〜16
•16は「無限大」
1717
RIP(2)
RIP (continued)
•520/udp•ブロードキャスト•タイマー
•30秒ごとに更新応答•180秒間更新がこないと有効期限切れ•その後120秒で抹消
1818
RIP-2
RIP-2
•マルチキャスト•サブネットマスク、ネクストホップをエントリに含む•認証機能
1919
RIPng
RIPng
•IPv6対応
2020
Solaris 11のRIP
Routing daemon on Solaris 11
•in.routed(1M)•RIPv2•デフォルトで起動される。
•/etc/defaultrouterがあると起動されない。•routeadm(1M)で制御可能
2121
routingとforwarding
•routingとforwardingは別•IPv4とIPv6でも別•デフォルトでipv4-forwardingはdisabled
Routing and forwarding
2222
Solarisをルータとして使う
Solaris server as a router
Router1
Solaris
Network1
Network2
Network0Network3
forwarding
2323
ルータとして使うには
•Router1がRIPをしゃべってくれればよい。•20世紀にはよく見られた構成?
•今でも残っているため、ルータのRIPを止められないところがあるらしい。
•ただしforwardingを有効にしないと、経路はあっても転送はできない。
Using a Solaris server as a router
2424
今回やりたいこと
•ルータを多数用意し、相互接続•RIPを設定し、経路の伝達を観察
Now I will show you ...
2525
10x10 RIPグリッド
10x10 RIP grid
2626
使用する機器
•HP ProLiant ML110 G6•CPUはCeleronで十分•NICは4つ必要(4ポートものを増設)•400W•Solaris 11 11/11をインストール•これを100台用意します。
Running 100 servers
2727
ラックの様子(一部)
Rack view
2828
実際の構成
•1台のサーバにゾーンを100個作成•ML110 G6
•Core i3-530•16GB
•ノートPC(メモリ4GB)でも動いた。•ただしSolaris 11 Express
100 zones on a server indeed
2929
ゾーン作成方針
Cloning a template zone, non-interactive install
•まずテンプレートゾーンを作成。•それを100個複製する。•ゾーンの初回起動時の対話式設定は、一切行わない。
•100回もやっていられない。
3030
ネットワーク構成要素(例)
Network configuration
ゾーンz305
v3_4
V3_5
h2_5 h3_5e3_5
192.168.135.1
w3_5
192.168.125.2
n3_5
s3_5
192.168.43.2
192.168.53.1
z304
z405
etherstub
vnic
X
Y
3131
命名規則
Naming convention
•記号 + 「”%02d%02d”, x, y」としたかったが、etherstub、vnicでは使えない。
•英字で始まり、数字で終わること。•最後の数字を0で始めてはいけない。
•e304はよいが、e0304は不可。
•最終的に前図のとおりとなった。
3232
テンプレートゾーン(1)ネットワークの構成
Template zone
ゾーンz0
d0
d0
d0 d0e0
10.0.2.2/24
w0
10.0.4.4/24
n0
s0
10.0.1.1/24
10.0.3.3/24
etherstub(全vnic共用)
vnic
3333
テンプレートゾーン(2)etherstub、vnicの作成
Creating an etherstub and vnics
# dladm create-etherstub d0
# dladm create-vnic -l d0 n0# dladm create-vnic -l d0 e0# dladm create-vnic -l d0 s0# dladm create-vnic -l d0 w0
3434
テンプレートゾーン(3)プロファイルの作成
従来のJumpStartのsysidcfgに相当するもの。
# sysconfig create-profile -o z0.xml
対話式に設定していく。
Making a profile
3535
テンプレートゾーン(4)sysconfig 最初の画面
System Configuration Tool
System Configuration Tool enables you to specify the following configuration parameters for your newly-installed Oracle Solaris 11 system: - network, time zone, date and time, user and root accounts, name services
System Configuration Tool produces an SMF profile file in ./z0.xml.
How to navigate through this tool: - Use the function keys listed at the bottom of each screen to move from screen to screen and to perform other operations. - Use the up/down arrow keys to change the selection or to move between input fields. - If your keyboard does not have function keys, or they do not respond, press ESC; the legend at the bottom of the screen will change to show the ESC keys for navigation and other functions.
F2_Continue F6_Help F9_Quit
sysconfig create-profile: the first screen
3636
テンプレートゾーン(5)sysconfigの設定内容
•コンピュータ名: z0、
ネットワーク設定: None (今回はしない)•タイムゾーン: Japan•日時•rootのパスワードを設定、ユーザは不要
sysconfig components
3737
テンプレートゾーン(6)sysconfig 最終確認画面
System Configuration Summary
Review the settings below before continuing. Go back (F3) to make changes.
Time Zone: Japan
Language: *The following can be changed when logging in. Default language: C/POSIX
Keyboard layout: *The following can be changed when logging in. Default keyboard layout: US-English
Terminal type: sun-color
Users: No user account
Network: Computer name: z0 Network Configuration: None
F2_Apply F3_Back F6_Help F9_Quit
sysconfig create-profile: the last screen
3838
テンプレートゾーン(7)zonecfg コマンドファイル
# cat z0.cfgcreate -bset zonepath=/zones/z0set brand=solarisset autoboot=falseset ip-type=exclusiveadd netset allowed-address=10.0.1.1/24set configure-allowed-address=trueset physical=n0endadd netset allowed-address=10.0.2.2/24set configure-allowed-address=trueset physical=e0end(つづく)
zonecfg command file
3939
テンプレートゾーン(8)(つづき)
(つづき)add netset allowed-address=10.0.3.3/24set configure-allowed-address=trueset physical=s0endadd netset allowed-address=10.0.4.4/24set configure-allowed-address=trueset physical=w0end
zonecfg command file (continued)
4040
テンプレートゾーン(9)ゾーンのインストール
# zonecfg -z z0 -f z0.cfg
# zoneadm -z z0 install -c $PWD/z0.xml # -cで指定するプロファイルは、絶対パスでないと動かなかった。
# zoneadm -z z0 boot -s # ここではシングルユーザモードで起動。
# zlogin -C z0 # プロファイルで指定したパスワードを使い、rootでコンソールからログイン。 # 事後設定が不要なことを確認。
# ^D # ここでゾーンを停止してもよいが、不要なサービスを止めることとする。
Installing a template zone
4141
テンプレートゾーン(10)不要なサービスの停止
メモリの使用量を減らすため、サービスを極力停止する。
# svcadm disable svc:/network/smtp:sendmail# svcadm disable svc:/network/sendmail-client:default# svcadm disable svc:/network/ssh:default# svcadm disable svc:/network/ipmp:default# svcadm disable svc:/system/filesystem/autofs:default# svcadm disable svc:/network/security/ktkt_warn:default# svcadm disable svc:/network/rpc/gss:default# svcadm disable svc:/network/inetd:default# svcadm disable svc:/system/fmd:default# svcadm disable svc:/network/rpc/bind:default# svcadm disable svc:/system/fm/smtp-notify:default# svcadm disable svc:/system/system-log:default# svcadm disable svc:/system/cron:default
Disabling unnecessary services
4242
テンプレートゾーン(11)サービスを停止した効果
prstat -Z の出力の比較
ZONEID NPROC SWAP RSS MEMORY TIME CPU ZONE 8 29 163M 85M 0.5% 0:00:22 0.0% z0
ZONEID NPROC SWAP RSS MEMORY TIME CPU ZONE 9 17 81M 47M 0.3% 0:00:06 0.3% z0
停止前
停止後
Reported memory size is reduced.
4343
RIP用ゾーンの作成(1)zonecfgコマンドファイル
z0.cfgをゾーンごとに変更...set zonepath=/zones/z0...set allowed-address=10.0.1.1/24set physical=n0...set allowed-address=10.0.2.2/24set physical=e0...set allowed-address=10.0.3.3/24set physical=s0...set allowed-address=10.0.4.4/24set physical=w0 ...
zonecfg command file for new zones
4444
RIP用ゾーンの作成(2)プロファイル
z0.xmlをゾーンごとに変更... <service version="1" type="service" name="system/identity"> <instance enabled="true" name="node"> <property_group type="application" name="config"> <propval type="astring" name="nodename" value="z0"/> </property_group> </instance> </service>...
profile for new zones
4545
RIP用ゾーンの作成(3)ゾーンの起動
シェルスクリプトでループを回し、ゾーンを100個つくる。
# zoneadm -z z0 shutdown
# ゾーンごとのループ# コマンドファイル生成# プロファイル生成# zonecfg -z zone -f command_file# zoneadm -z zone clone -c profile z0# zoneadm -z zone boot# zoneadm -z zone shutdown -r# # 再起動しないとNICのアドレスが有効にならなかった。
Making new zones
4646
RIP用ゾーンの作成(4)フォワーディングの設定
シェルスクリプトでループを回し、各ゾーンで設定する。
# zlogin -z zone routeadm -u -e ipv4-forwarding
これだけでは各IFは、forwardingになっていない。
# ipadm show-ifpropIFNAME PROPERTY PROTO PERM CURRENT PERSISTENT DEFAULT POSSIBLE…w0 forwarding ipv4 rw off -- off on,off
リブートして対処した。
# zlogin -z zone shutdown -r
Enabling ipv4-forwarding
4747
デモの内容
•任意のゾーンにスタティックルートを設定•172.16.0.0/16
•グローバルゾーンからrtquery(1M)で取得•netstat -r でもよいが、•rtqueryだとメトリックも得られる。
Demonstration: adding route 172.16.0.0/16 on some zone
4848
netstat -r の出力例
z505# netstat -rn
Routing Table: IPv4 Destination Gateway Flags Ref Use Interface -------------------- -------------------- ----- ----- ---------- --------- 10.5.5.0 10.5.5.1 U 2 0 t5_5 127.0.0.1 127.0.0.1 UH 3 30556 lo0 172.16.0.0 10.5.5.2 UG 1 0 192.168.1.0 192.168.145.1 UG 1 0 w5_5 192.168.1.0 192.168.45.1 UG 1 0 n5_5 192.168.2.0 192.168.145.1 UG 1 0 w5_5 192.168.2.0 192.168.45.1 UG 1 0 n5_5 192.168.3.0 192.168.45.1 UG 1 0 n5_5 192.168.4.0 192.168.45.1 UG 1 0 n5_5 192.168.4.0 192.168.145.1 UG 1 0 w5_5 ...
Sample output of netstat -r
4949
rtqueryの出力例
z505# rtquery -n127.0.0.1 received on interface lo0 (1): RIPv2 504 bytes 10.5.5.0/24 metric 1 192.168.1.0/24 metric 9 nhop=192.168.45.1 192.168.3.0/24 metric 7 nhop=192.168.45.1 192.168.2.0/24 metric 8 nhop=192.168.45.1 192.168.5.0/24 metric 5 nhop=192.168.45.1 192.168.6.0/24 metric 6 nhop=192.168.45.1 192.168.4.0/24 metric 6 nhop=192.168.145.1 192.168.8.0/24 metric 8 nhop=192.168.45.1 ...
Sample output of rtquery
5050
デモ用データ取得スクリプト
A shell script on the global zone gathers routes in non-global zones.
•シェルスクリプト•グローバルゾーンから各ゾーンのデータを取得
•zlogin ゾーン rtquery -n•nhopを矢印(↑→↓←)に変換•メトリックを表示
5151
データ表示例
Sample output of the script: next hops and metrics
→↓→↓↓↓↓↓↓← 9 8 7 6 5 6 7 8 910↓↓→↓↓←↓↓↓↓ 8 7 6 5 4 5 6 7 8 9→↓↓→↓←↓←←← 7 6 5 4 3 4 5 6 7 8→→↓↓↓←↓←←← 6 5 4 3 2 3 4 5 6 7→→→→○←←←←← 5 4 3 2 1 2 3 4 5 6→→↑↑↑←←←↑↑ 6 5 4 3 2 3 4 5 6 7↑↑↑↑↑↑←←←← 7 6 5 4 3 4 5 6 7 8→→→↑↑↑↑↑↑↑ 8 7 6 5 4 5 6 7 8 9→→↑↑↑←↑↑←↑ 9 8 7 6 5 6 7 8 910→→↑↑↑↑↑↑↑↑ 10 9 8 7 6 7 8 91011
5252
スクリプトの実行速度
The script is slow; should it be multi-threaded?
•遅い•各ゾーンを順番に読みにいくので、待ちが多い。
•マルチスレッド化すればよい?•めんどうくさい。
5353
Node.jsなら簡単?
Is Node.js suitable?
•http://nodejs.org/•Node.js uses an event-driven, non-blocking I/O model ...
•サーバサイドJavaScript•非同期処理
5454
Node.jsをインストール
Installing Node.js
# pkg install gcc-3 # gcc-45でもよさそう。# pkg install system/header
ソースを入手し、展開。以下は今回使ったもの。http://nodejs.org/dist/v0.6.7/node-v0.6.7.tar.gz
$ ./configure$ gmake # makeではダメだった。# gmake install
5555
node-canvasも入れてみる
Installing node-canvas
OSのlibjpegをリンクすると、実行時にエラーが発生するので、別途インストールする。
以下を入手し、展開http://www.ijg.org/files/jpegsrc.v8c.tar.gz
$ ./configure$ make$ make test# make install
$ PATH=${PATH}:/usr/local/bin \ LD_OPTIONS='-L/usr/local/lib -R/usr/local/lib' \ CXXFLAGS='-I/usr/local/include' npm install canvas npmは/usr/local/binに入っている。
5656
Node.js版を実行
Node.js script is much faster than the shell script.
•こちらの方が断然速い。
5757
canvasでお絵かき
Drawing with canvas
5858
観賞方法
Wear 3D glasses!
5959
ご注意
Red is left, blue is right.
•左が赤、右が青です。•見え方には個人差があります。•気持ち悪くなった場合は即座に中止してください。•プロジェクタの大スクリーンの場合は、左右逆にしてください。
6060
ルートの観察例
中央付近のゾーンでルートを設定
# zlogin z505 route add 172.16.0.0 10.5.5.2
# zlogin z505 route delete 172.16.0.0 10.5.5.2
隅でルートを設定 - メトリックの上限を超えたゾーンには経路がない
# zlogin z1010 route add 172.16.0.0 10.10.10.2
# zlogin z1010 route delete 172.16.0.0 10.10.10.2
※ここではルート設定用のvnicを使用しています(今までの説明には入っていません)。
Adding and deleting routes on some zones
6161
IPv6の設定(1)アドレスを追加
select net physical=n10_10set allowed-address=192.168.100.2/24,fe80::8:20ff:fefb:fefb/10,2001:db8:0:100::2/64set configure-allowed-address=trueendselect net physical=e10_10set allowed-address=192.168.210.1/24,fe80::8:20ff:feaf:d694/10,2001:db8:0:210::1/64set configure-allowed-address=trueendselect net physical=s10_10set allowed-address=192.168.110.1/24,fe80::8:20ff:fec5:21b1/10,2001:db8:0:110::1/64set configure-allowed-address=trueendselect net physical=w10_10set allowed-address=192.168.200.2/24,fe80::8:20ff:fe04:7e67/10,2001:db8:0:200::2/64set configure-allowed-address=trueend
zonecfgのコマンド - リンクローカルアドレスの指定が必須
Adding IPv6 addresses; link-local addresses are required.
6262
IPv6の設定(2)リンクローカルアドレス
MACアドレスの取得
$ dladm show-vnic n10_10 -p -o macaddress2:8:20:fb:fe:fb
set allowed-address=192.168.100.2/24,\fe80::8:20ff:fefb:fefb/10,\2001:db8:0:100::2/64
これに対応するアドレス EUI-64アドレスにもとづくもの。 ただし最上位オクテットの下から2番目のビットは反転する。
How to generate a link-local address
6363
IPv6の設定(3)ルーティング等
# zlogin zone routeadm -u -e ipv6-forwarding -e ipv6-routing
Enabling IPv6 routing and forwarding
IPv6のルーティングとフォワーディングを有効にする。
ルーティングデーモン
in.ripngd
6464
in.ripngdの挙動の観察
Use netstat to get the IPv6 routing table; metrics cannot be obtained.
•rtqueryは使えない。•かわりにnetstat -r [-f inet6]
•メトリックは得られない。
6565
IPv6での表示例
Sample output for IPv6 routing
・・・・↓→↓↓↓↓ ・・・↓↓→↓↓↓↓ ・・↓↓↓→↓→→↓ ・→↓↓↓↓↓↓↓↓ →→→↓↓→→→→↓ ↓→→→↓↓→↓→↓ →→→→↓↓→↓↓↓ ↓↓→→→→→↓↓↓ →→→→→→→→→↓ →→→→→→→→→○
メトリック16のとき、IPv4では表示されていたが、IPv6では出てこない。
6666
実際にルータとして使うときの注意
•dladm show-linkprop•protectionとallowed-ipsに注意•今回のゾーン作成方法では、実際にはフォワーディングできない。
If you use a Solaris router in practice, data link protection prevents forwarding.
6767
protectionを変更する例
うまくいかない例z101# ping 192.168.102.2no answer from 192.168.102.2
設定変更# dladm show-linkprop -p protection n1_2LINK PROPERTY PERM VALUE DEFAULT POSSIBLEn1_2 protection rw ip-nospoof -- mac-nospoof, restricted, ip-nospoof, dhcp-nospoof# dladm reset-linkprop -p protection n1_2
この後z101# ping 192.168.102.2192.168.102.2 is alive
Reset protection to forward packets
6868
おしまい
That's all. Thank you!
ありがとうございました。