bridge+epairで仮想HUBを作ってみる=>できた
もっといい方法が必ずあるはずなので、とりあえずメモとして。
以下の様なネットワークを作ってみます。
まずはスイッチ部分を作成し、Jail hostまでつなげるところから。
# ifconfig bridge create bridge0 # ifconfig bridge0 vnet switch # ifconfig epair create epair0a # ifconfig epair0a 192.168.20.1/24 up # ifconfig epair0b vnet switch # jexec switch ifconfig bridge0 192.168.20.254/24 up # jexec switch ifconfig epair0b up # jexec switch ifconfig bridge0 addm epair0b # ping 192.168.20.254 PING 192.168.20.254 (192.168.20.254): 56 data bytes 64 bytes from 192.168.20.254: icmp_seq=0 ttl=64 time=0.269 ms 64 bytes from 192.168.20.254: icmp_seq=1 ttl=64 time=0.120 ms
これでJail hostとSwitch部分のネットワークが作成できました。
次はserver01とswitchをつなげるところ。
# ifconfig epair create epair1a # ifconfig epair1a vnet server01 # ifconfig epair1b vnet switch # jexec server01 ifconfig epair1a 192.168.20.11/24 up # jexec switch ifconfig epair1b up # jexec switch ifconfig bridge0 addm epair1b # # jexec server01 ping 192.168.20.1 PING 192.168.20.1 (192.168.20.1): 56 data bytes 64 bytes from 192.168.20.1: icmp_seq=0 ttl=64 time=0.181 ms 64 bytes from 192.168.20.1: icmp_seq=1 ttl=64 time=0.135 ms
最後にserver01とswitchをつなげるところ。server01とやっていることはほぼ同じ。
# ifconfig epair create epair2a # ifconfig epair2a vnet server02 # ifconfig epair2b vnet switch # jexec server02 ifconfig epair2a 192.168.20.12/24 up # jexec switch ifconfig epair2b up # jexec switch ifconfig bridge0 addm epair2b # # jexec server02 ping 192.168.20.1 PING 192.168.20.1 (192.168.20.1): 56 data bytes 64 bytes from 192.168.20.1: icmp_seq=0 ttl=64 time=0.181 ms 64 bytes from 192.168.20.1: icmp_seq=1 ttl=64 time=0.126 ms
これで全てつなぎ終えました。
server01とserver02の疎通も確認してみます。
# jexec server01 ping 192.168.20.12 PING 192.168.20.12 (192.168.20.12): 56 data bytes ping: sendto: Host is down ping: sendto: Host is down
・・・疎通できない・・・・・・。
何か間違っている点、やっていない点があれば@Shutingrz宛に助言お願いします。
追記
server01から192.168.20.12(server02)にpingを飛ばした時のserver02のepair2aのtcpdumpです
server01のping
# jexec server01 ping 192.168.20.12 PING 192.168.20.12 (192.168.20.12): 56 data bytes ping: sendto: Host is down
server02のtcpdump
# jexec server02 tcpdump -i epair2a tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on epair2a, link-type EN10MB (Ethernet), capture size 65535 bytes 22:28:18.952300 ARP, Request who-has 192.168.20.12 tell 192.168.20.11, length 28 22:28:20.003368 ARP, Request who-has 192.168.20.12 tell 192.168.20.11, length 28 22:28:21.053505 ARP, Request who-has 192.168.20.12 tell 192.168.20.11, length 28
追記
できなかった理由が判明しました。
jailer設定 [DEMON-LORD]
ifconfig epair[n] create
epair[n]aとepair[n]bが作成される。epairを一つ作成してjailerからprisonerに割り当ててから次のepairを作成するとMACアドレスが重複する場合がある。この場合、それぞれのepairを同じbridgeに接続するとMACアドレスが重複して通信が行えなくなる。問題を回避する為、epairの作成は同時期に行う。
まさかと思いjexec switch ifconfig。
epair1b: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500 options=8<VLAN_MTU> ether 02:ff:50:00:06:0b inet6 fe80::ff:50ff:fe00:60b%epair1b prefixlen 64 scopeid 0x4 nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL> media: Ethernet 10Gbase-T (10Gbase-T <full-duplex>) status: active epair2b: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 options=8<VLAN_MTU> ether 02:ff:50:00:06:0b inet6 fe80::ff:50ff:fe00:60b%epair2b prefixlen 64 scopeid 0x5 nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL> media: Ethernet 10Gbase-T (10Gbase-T <full-duplex>) status: active
案の定macaddrが被ってました・・・。
@tss_ontap さんも昔この事言ってたのを今になって思い出しました。
修正として、まずifconfig epair createを3連続で行うようにしました。
結果。
# jexec server01 ping 192.168.20.12 PING 192.168.20.12 (192.168.20.12): 56 data bytes 64 bytes from 192.168.20.12: icmp_seq=0 ttl=64 time=0.219 ms 64 bytes from 192.168.20.12: icmp_seq=1 ttl=64 time=0.076 ms
バッチリです。
原因はわかったものの、今やってる卒論はリアルタイムにepairを作成、jailに割り当てる方式を採用しているので、この問題はどうやって解決すべきか・・・。
以上。