■squeezeにvconfigを導入する
細かいことは後で考えるものとして、
vmplayerのゲスト側NICをVLANでpingを通すまで。
ホストvmnet8 -> ゲストeth0 -> ゲスト eth0.2
参考:LinuxでのタグVLANの利用 〜 vconfigの使い方
http://dsas.blog.klab.org/archives/50408097.html
参考:LinuxとVLANで作る、シンプル&スケーラブルネットワークの極意
http://www.irori.org/doc/infra/wd41.html
■kernelのコンパイルオプションの確認
以下でもやってますので、もうおなじみですね。
VMwarePlayerで、Lenny on Lenny シリアルコンソール接続
http://d.hatena.ne.jp/labunix/20120214
$ sudo apt-get install kernel-package
$ dpkg -L kernel-package | grep `uname -r | sed s/".*-"//g`"\$"
/usr/share/kernel-package/Config/config.amd64
■モジュールなので、
$ grep VLAN /usr/share/kernel-package/Config/config.amd64
CONFIG_BRIDGE_EBT_VLAN=m
$ grep "CONFIG_BRIDGE" /usr/share/kernel-package/Config/config.amd64
CONFIG_BRIDGE_NETFILTER=y
CONFIG_BRIDGE_NF_EBTABLES=m
CONFIG_BRIDGE_EBT_BROUTE=m
CONFIG_BRIDGE_EBT_T_FILTER=m
CONFIG_BRIDGE_EBT_T_NAT=m
CONFIG_BRIDGE_EBT_802_3=m
CONFIG_BRIDGE_EBT_AMONG=m
CONFIG_BRIDGE_EBT_ARP=m
CONFIG_BRIDGE_EBT_IP=m
CONFIG_BRIDGE_EBT_LIMIT=m
CONFIG_BRIDGE_EBT_MARK=m
CONFIG_BRIDGE_EBT_PKTTYPE=m
CONFIG_BRIDGE_EBT_STP=m
CONFIG_BRIDGE_EBT_VLAN=m
CONFIG_BRIDGE_EBT_ARPREPLY=m
CONFIG_BRIDGE_EBT_DNAT=m
CONFIG_BRIDGE_EBT_MARK_T=m
CONFIG_BRIDGE_EBT_REDIRECT=m
CONFIG_BRIDGE_EBT_SNAT=m
CONFIG_BRIDGE_EBT_LOG=m
CONFIG_BRIDGE_EBT_ULOG=m
CONFIG_BRIDGE=m
■vlanの導入
$ sudo apt-get install -y vlan
$ sudo 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:-
■手動で「8021q」モジュールの読み込み、VLAN追加と削除
$ sudo modprobe 8021q
$ find /proc/net/vlan/ -type f -print
/proc/net/vlan/eth0.2
/proc/net/vlan/config
$ find /proc/net/vlan/ -type f -print | sudo grep . `xargs`
/proc/net/vlan/eth0.2:eth0.2 VID: 2 REORDER_HDR: 1 dev->priv_flags: 1
/proc/net/vlan/eth0.2: total frames received 0
/proc/net/vlan/eth0.2: total bytes received 0
/proc/net/vlan/eth0.2: Broadcast/Multicast Rcvd 0
/proc/net/vlan/eth0.2: total frames transmitted 0
/proc/net/vlan/eth0.2: total bytes transmitted 0
/proc/net/vlan/eth0.2: total headroom inc 0
/proc/net/vlan/eth0.2: total encap on xmit 0
/proc/net/vlan/eth0.2:Device: eth0
/proc/net/vlan/eth0.2:INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0
/proc/net/vlan/eth0.2: EGRESS priority mappings:
/proc/net/vlan/config:VLAN Dev name | VLAN ID
/proc/net/vlan/config:Name-Type: VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD
/proc/net/vlan/config:eth0.2 | 2 | eth0
$ /sbin/ifconfig eth0.2
eth0.2 Link encap:イーサネット ハードウェアアドレス 00:XX:XX:XX:XX:XX
BROADCAST MULTICAST MTU:1500 メトリック:1
RXパケット:0 エラー:0 損失:0 オーバラン:0 フレーム:0
TXパケット:0 エラー:0 損失:0 オーバラン:0 キャリア:0
衝突(Collisions):0 TXキュー長:0
RXバイト:0 (0.0 B) TXバイト:0 (0.0 B)
$ sudo vconfig rem eth0.2
Removed VLAN -:eth0.2:-
$ /sbin/ifconfig eth0.2
eth0.2: インタフェース情報を取得中にエラーが発生しました: デバイスが見つかりません
$ find /proc/net/vlan/ -type f -print | sudo grep . `xargs`
VLAN Dev name | VLAN ID
Name-Type: VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD
■再起動時に有効になるよう設定
$ echo "8021q" | sudo tee -a /etc/modules
8021q
$ cat /etc/modules
loop
8021q
$ sudo modprobe 8021q
$ lsmod | grep 8021q
8021q 17158 0
garp 5050 1 8021q
$ sudo modprobe -c | grep 8021q
alias rtnl_link_vlan 8021q
$ sudo modprobe -l | grep 8021q
kernel/net/8021q/8021q.ko
■ネットワークインターフェイスの設定
※down行は必須。
$ echo '
auto eth0.2
allow-hotplug eth0.2
iface eth0.2 inet static
address 192.168.0.88
netmask 255.255.255.0
down /sbin/vconfig rem eth0.2
' | sudo tee -a /etc/network/interfaces
$ sudo /etc/init.d/networking restart
Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces ... (warning).
Reconfiguring network interfaces...Set name-type for VLAN subsystem. Should be visible in /proc/net/vlan/config
Added VLAN with VID == 2 to IF -:eth0:-
done.
■以下のようにpingも通る。
$ ip addr show dev eth0.2 | grep -v "ether\|inet6"
4: eth0.2@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
inet 192.168.0.188/24 brd 192.168.0.255 scope global eth0.2
valid_lft forever preferred_lft forever
$ ping -c 1 192.168.0.188
PING 192.168.0.188 (192.168.0.188) 56(84) bytes of data.
64 bytes from 192.168.0.188: icmp_req=1 ttl=64 time=0.094 ms
--- 192.168.0.188 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.094/0.094/0.094/0.000 ms
■ルーティングの設定の確認
$ env LANG=C netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.188.0 * 255.255.255.0 U 0 0 0 eth0
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0.2
■ホストOS側にルーティングを設定
$ sudo route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.188.188
$ ping -c 1 192.168.0.188
PING 192.168.0.188 (192.168.0.188) 56(84) bytes of data.
64 bytes from 192.168.0.188: icmp_req=1 ttl=64 time=0.588 ms
--- 192.168.0.188 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.588/0.588/0.588/0.000 ms
■「sshd_config」でリッスンポートの制限を緩めてあげると、普通に繋がる。
VLANぽく無いけど、まあとりあえず。。。
$ ssh 192.168.0.188