Virtual Local Area Network (バーチャル・ローカル・エリア・ネットワーク、仮想LAN、バーチャルLAN)・VLAN (ブイラン)は、物理的な接続形態とは別に、仮想的に分割されたLAN接続のこと。レイヤ2スイッチの機能の1つで、通信帯域の有効利用や情報セキュリティの向上などを目的とする。
記事の引用元としてWikipediaを使用するのはどうなのかという話はありますが、どの記事もVLANについては上記引用部分のような説明をしているのではないかと思います。
VLANはLANを仮想的に分割するため、VLANについて理解していれば以下はおかしいことを言っていると理解できるかと思います。
- interface VLAN100に192.168.1.100/24を設定
- interface VLAN101に192.168.1.101/24を設定
- interface VLAN102に192.168.1.102/24を設定
セグメント分割しとらんやないかい、という話です。
ルールを破ってみる
ダメと言われたらやりたくなるのが人間です。
なので、SRXに以下のような設定を入れてみます。
尚、vSRXのバージョンは19.2R1.8です。古いですね。
set vlans vlan100 vlan-id 100
set vlans vlan101 vlan-id 101
set vlans vlan102 vlan-id 102
set interfaces ge-0/0/0 vlan-tagging
set interfaces ge-0/0/0 unit 100 vlan-id 100
set interfaces ge-0/0/0 unit 100 family inet address 192.168.1.100/24
set interfaces ge-0/0/0 unit 101 vlan-id 101
set interfaces ge-0/0/0 unit 101 family inet address 192.168.1.101/24
set interfaces ge-0/0/0 unit 102 vlan-id 102
set interfaces ge-0/0/0 unit 102 family inet address 192.168.1.102/24
[edit]
root@vSRX# commit
commit complete
なんでcommitできるんだよ、教えはどうなってるんだ教えは
ちゃんとインターフェースも up してます。マジで何?
root@vSRX> show interfaces terse
Interface Admin Link Proto Local Remote
ge-0/0/0 up up
ge-0/0/0.100 up up inet 192.168.1.100/24
ge-0/0/0.101 up up inet 192.168.1.101/24
ge-0/0/0.102 up up inet 192.168.1.102/24
ge-0/0/0.32767 up up
ちなみにIOSではちゃんと怒られました。
vIOS(config)#do sh ip int br
Interface IP-Address OK? Method Status Protocol
GigabitEthernet0/0 unassigned YES unset up up
GigabitEthernet0/1 unassigned YES unset up up
GigabitEthernet0/2 unassigned YES unset up up
GigabitEthernet0/3 unassigned YES unset up up
Vlan100 192.168.1.100 YES manual administratively down down
Vlan101 192.168.1.101 YES manual administratively down down
vIOS(config)#int vlan 100
vIOS(config-if)#no shu
vIOS(config-if)#
*Sep 11 05:39:23.168: %LINK-3-UPDOWN: Interface Vlan100, changed state to up
*Sep 11 05:39:24.168: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan100, changed state to up
vIOS(config-if)#int vlan 101
vIOS(config-if)#no shu
% 192.168.1.0 overlaps with Vlan100
Vlan101: incorrect IP address assignment
vIOS(config-if)#
挙動はどうなるねん
取り敢えず以下のように結線し、L2SW の G0/0 を Trunk に設定し、全VLANが通れるように設定をしました。
上記の通り、同一セグメントに属する異なるSVIを作成できないので、以下手順で疎通確認しました。
- int VLAN100 を作成し、IPを 192.168.1.155/24 に設定
- ge-0/0/0.100 (vSRX) と int vlan 100 (IOSVL2) で疎通確認
- int vlan100 を削除し、int vlan101 を作成し、IPを 192.168.1.155/24 に設定
- ge-0/0/0.101 (vSRX) と int vlan 101 (IOSVL2) で疎通確認
- int vlan101 を削除し、int vlan102 を作成し、IPを 192.168.1.155/24 に設定
- ge-0/0/0.102 (vSRX) と int vlan 102 (IOSVL2) で疎通確認
ge-0/0/0.100 (vSRX) ↔ int vlan 100 (IOSVL2)
IOSVL2(config)#do ping 192.168.1.100 source vlan 100
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.100, timeout is 2 seconds:
Packet sent with a source address of 192.168.1.155
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
IOSL2(config)#
root@vSRX> ping 192.168.1.155
PING 192.168.1.155 (192.168.1.155): 56 data bytes
64 bytes from 192.168.1.155: icmp_seq=0 ttl=255 time=4.199 ms
64 bytes from 192.168.1.155: icmp_seq=1 ttl=255 time=2.525 ms
64 bytes from 192.168.1.155: icmp_seq=2 ttl=255 time=2.917 ms
64 bytes from 192.168.1.155: icmp_seq=3 ttl=255 time=2.449 ms
^C
--- 192.168.1.155 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max/stddev = 2.449/3.022/4.199/0.702 ms
root@vSRX>
通信できてますね。
問題はこの後です。
ge-0/0/0.101 (vSRX) ↔ int vlan 101 (IOSVL2)
IOSVL2(config)#do ping 192.168.1.101
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.101, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
IOSVL2(config)#
root@vSRX> ping 192.168.1.155
PING 192.168.1.155 (192.168.1.155): 56 data bytes
^C
--- 192.168.1.155 ping statistics ---
7 packets transmitted, 0 packets received, 100% packet loss
root@vSRX>
疎通がないですね。
どうやらvSRXは戻りパケットを VLAN 100 でカプセル化して送信しているようです。
既に int vlan 100 は削除していますから、疎通がないのは納得ですね。
実際、vSRXの ARP テーブルには 192.168.1.155 のエントリが2つあります。
root@vSRX> show arp
MAC Address Address Name Interface Flags
52:54:00:ab:80:64 192.168.1.155 192.168.1.155 ge-0/0/0.100 none
52:54:00:ab:80:65 192.168.1.155 192.168.1.155 ge-0/0/0.101 none
Total entries: 2
root@vSRX>
……とか書いている間に ARP テーブルから古い方が消えました。
消えたら疎通が取れました。
root@vSRX> show arp
MAC Address Address Name Interface Flags
52:54:00:ab:80:65 192.168.1.155 192.168.1.155 ge-0/0/0.101 none
root@vSRX>
root@vSRX> ping 192.168.1.155
PING 192.168.1.155 (192.168.1.155): 56 data bytes
64 bytes from 192.168.1.155: icmp_seq=0 ttl=255 time=4.994 ms
64 bytes from 192.168.1.155: icmp_seq=1 ttl=255 time=2.270 ms
64 bytes from 192.168.1.155: icmp_seq=2 ttl=255 time=2.359 ms
^C
--- 192.168.1.155 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max/stddev = 2.270/3.208/4.994/1.264 ms
IOSVL2#ping 192.168.1.101 source vlan 101
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.101, timeout is 2 seconds:
Packet sent with a source address of 192.168.1.155
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms
IOSVL2#
ge-0/0/0.102 (vSRX) ↔ int vlan 102 (IOSVL2)
どうせ同じ挙動をしますが、こちらも見てみます。
IOSVL2(config)#do ping 192.168.1.102
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.102, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
IOSVL2(config)#
やはり疎通が取れませんでした。 そして、vSRXの ARP テーブルに 192.168.1.155 が2エントリ存在しました。
root@vSRX> show arp
MAC Address Address Name Interface Flags
52:54:00:ab:80:65 192.168.1.155 192.168.1.155 ge-0/0/0.101 none
52:54:00:ab:80:66 192.168.1.155 192.168.1.155 ge-0/0/0.102 none
Total entries: 2
root@vSRX>
やはり、ARPテーブルをクリアしたら疎通が取れるようになりました。
root@vSRX> clear arp
192.168.1.155 deleted
root@vSRX> ping 192.168.1.155
PING 192.168.1.155 (192.168.1.155): 56 data bytes
64 bytes from 192.168.1.155: icmp_seq=0 ttl=255 time=3.433 ms
64 bytes from 192.168.1.155: icmp_seq=1 ttl=255 time=2.489 ms
64 bytes from 192.168.1.155: icmp_seq=2 ttl=255 time=2.565 ms
64 bytes from 192.168.1.155: icmp_seq=3 ttl=255 time=2.650 ms
^C
--- 192.168.1.155 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max/stddev = 2.489/2.784/3.433/0.379 ms
IOSVL2(config)#do ping 192.168.1.102 source vlan 102
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.102, timeout is 2 seconds:
Packet sent with a source address of 192.168.1.155
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 2/3/8 ms
IOSVL2(config)#
ルータを追加してみる
ルータを3台追加しました。ルータ、スイッチ間はアクセスポートです。
それぞれのルータからvSRXのインターフェースに疎通が取れました。
CSR1000v-0(config)#do ping 192.168.1.100
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.100, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 2/2/3 ms
CSR1000v-0(config)#
CSR1000v-1(config)#do ping 192.168.1.101
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.101, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 2/2/4 ms
CSR1000v-1(config)#
CSR1000v-2(config)#do ping 192.168.1.102
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.102, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 2/2/4 ms
CSR1000v-2(config)#
では、ルータ間での疎通はあるのでしょうか? 5台のネットワーク機器のいずれにもルーティングの設定はしていません。
CSR1000v-0(config)#do ping 192.168.1.201
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.201, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
CSR1000v-0(config)#
CSR1000v-0(config)#
CSR1000v-0(config)#do ping 192.168.1.202
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.202, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
CSR1000v-0(config)#
…疎通はありませんでした。他のルータからも同様に疎通が取れませんでした。
ちなみに、これは ARP が IP パケットではないからです。ARP はVLAN内にブロードキャストしますが、IP パケットではないのでL3レベルで同一セグメントであってもL2レベルで異なるセグメントであれば、そこに ARP をフラッディングしません。
では、それぞれのルータのデフォルトゲートウェイをSRXのインターフェースに設定したらどうでしょうか?
CSR1000v-0(config)#do sh ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, m - OMP
n - NAT, Ni - NAT inside, No - NAT outside, Nd - NAT DIA
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
H - NHRP, G - NHRP registered, g - NHRP registration summary
o - ODR, P - periodic downloaded static route, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
& - replicated local route overrides by connected
Gateway of last resort is 192.168.1.100 to network 0.0.0.0
S* 0.0.0.0/0 [1/0] via 192.168.1.100 <-vSRXのインターフェース
192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, GigabitEthernet1
L 192.168.1.200/32 is directly connected, GigabitEthernet1
CSR1000v-0(config)#
CSR1000v-0(config)#
CSR1000v-0(config)#do ping 192.168.1.101
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.101, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
CSR1000v-0(config)#
やはり疎通は取れませんでした。
これは各ルータがL3レベルで同一セグメントであり、そもそもルータはデフォルトゲートウェイ宛てのパケットを発信せず、vSRXはルーティングを行わないためです。
つまり、このようにIPを採番した場合、正常にVLAN間ルーティングができないということになります。
では、この経路をダイナミックルーティングで広報したらどうなるのでしょうか?
それはご自身の目で確かめてください!私は疲れました。(主に文字を書くのが)
結論
複数の VLAN を作成する際はネットワークを分けましょう。(当たり前)