วันศุกร์ที่ 20 พฤษภาคม พ.ศ. 2554

Network, Linux : การทำ InterVLAN บน Ubuntu

บทความนี้จะเป็นการนำ Ubuntu Linux มาทำเป็น InterVLAN แทนที่จะใช้อุปกรณ์ Router หรือ Multilayer switch

ระบบทดสอบ
Switch ที่ใช้ในการแบ่ง VLAN
Cisco Catalyst 2900 XL
IOS Version 12.0(5)XU

Server Linux ที่ใช้มาทำ InterVLAN
Ubuntu 10.04.2 LTS amd64

กำหนดให้
- Interface FastEthernet0/24 ของ Switch เป็น Trunk และเชื่อมต่อเข้ากับ eth1 ของ Server
- สร้าง VLAN100 และ VLAN200 ที่ Switch
- กำหนด Interface FastEthernet0/1 ของ Switch ให้เป็นสมาชิก VLAN100

- กำหนด Interface FastEthernet0/2 ของ Switch ให้เป็นสมาชิก VLAN200
- กำหนด Subnet ของ VLAN100 คือ 192.168.100.0/24
- กำหนด Subnet ของ VLAN200 คือ 192.168.200.0/24


โดย Configuration บน Switch เป็นดังนี้
!
interface FastEthernet0/1
switchport access vlan 100
!
interface FastEthernet0/2
switchport access vlan 200
!
interface FastEthernet0/24
switchport trunk encapsulation dot1q
switchport mode trunk
!


ที่ Server ติดตั้ง Software เพิ่มดังนี้

root@Ubunutu# apt-get install vlan
root@Ubunutu# modprobe 8021q

แก้ไขไฟล์ /etc/network/interfaces โดยเพิ่ม

auto vlan100
iface vlan100 inet static
address 192.168.100.1
netmask 255.255.255.0
vlan_raw_device eth1

auto vlan200
iface vlan200 inet static
address 192.168.200.1
netmask 255.255.255.0
vlan_raw_device eth1

บันทึกไฟล์ จากนั้นทำการ restart network service
root@Ubuntu:~# /etc/init.d/networking restart
* Reconfiguring network
Set name-type for VLAN subsystem. Should be visible in /proc/net/vlan/config
Added VLAN with VID == 100 to IF -:eth1:-
Set name-type for VLAN subsystem. Should be visible in /proc/net/vlan/config
Added VLAN with VID == 200 to IF -:eth1:- [ OK ]



ตรวจสอบ Interface VLAN
root@Ubuntu:~# ifconfig
eth1 Link encap:Ethernet HWaddr 00:14:22:17:e7:b8
inet6 addr: fe80::214:22ff:fe17:e7b8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:13932 errors:0 dropped:0 overruns:0 frame:0
TX packets:13946 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:2242272 (2.2 MB) TX bytes:10921868 (10.9 MB)

vlan100 Link encap:Ethernet HWaddr 00:14:22:17:e7:b8
inet addr:192.168.100.1 Bcast:192.168.100.255 Mask:255.255.255.0
inet6 addr: fe80::214:22ff:fe17:e7b8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:468 (468.0 B)

vlan200 Link encap:Ethernet HWaddr 00:14:22:17:e7:b8
inet addr:192.168.200.1 Bcast:192.168.200.255 Mask:255.255.255.0
inet6 addr: fe80::214:22ff:fe17:e7b8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:713 errors:0 dropped:0 overruns:0 frame:0
TX packets:835 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:141274 (141.2 KB) TX bytes:685933 (685.9 KB)

Ref. http://www.mysidenotes.com/2007/08/17/vlan-configuration-on-ubuntu-debian/