Ubuntu で VLAN 設定をするときのメモ。
■ (前準備) vlan パッケージをインストールする。
# apt-get install vlan
■ eth0 に VID=2 の VLAN を設定する場合。
WARNING が出るけど、これは気にしなくていい。
eth0.2 というインターフェイスが作成される。
# vconfig add eth0 2 WARNING: Could not open /proc/net/vlan/config. Maybe you need to load the 8021q module, or maybe you are not using PROCFS?? Added VLAN with VID == 2 to IF -:eth0:-
■ eth0.2 に IP アドレス 192.168.22.10/24 を付ける場合。
# ifconfig eth0.2 192.168.22.10 up
# ifconfig eth0.2
eth0.2 Link encap:Ethernet HWaddr XX:XX:XX:XX:XX:XX
inet addr:192.168.22.10 Bcast:192.168.22.255 Mask:255.255.255.0
inet6 addr: fe80::xxxx:xxxx:xxxx:xxxx/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:25 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:3996 (3.9 KB)
■ リオーダー設定をする場合。
デフォルトの 0 でも、大抵の場合は大丈夫なはず (未確認)。
パケットがうまくキャプチャできないときは設定してみる。
# vconfig set_flag eth0.2 1 Set flag on device -:eth0.2:- Should be visible in /proc/net/vlan/eth0.2
■ 設定を確認する場合。
# cat /proc/net/vlan/eth0.2
eth0.2 VID: 2 REORDER_HDR: 1 dev->priv_flags: 1
total frames received 0
total bytes received 0
Broadcast/Multicast Rcvd 0
total frames transmitted 25
total bytes transmitted 3996
total headroom inc 0
total encap on xmit 0
Device: eth0
INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0
EGRESS priority mappings:
■ eth0.2 を削除する場合。
# vconfig rem eth0.2 Removed VLAN -:eth0.2:-
■ その他メモ。
動作確認は、試しに ping を打ってみる (同じネットワーク内の存在しない IP アドレスでいい)。
wireshark とかで、ARP パケットをキャプチャして、802.1Q Virtual LAN が見えると OK。
NIC によっては、802.1Q ヘッダが付かないやつがあるので注意。
● VLAN, 802.1Q, VID, vconfig,

0 件のコメント:
コメントを投稿