Tuesday, August 16, 2011

Ubuntu 11.04 as a VLAN

how to configure ubuntu 11.04 as a VLAN

this step by step instruction
apt-get install vlan

sudo modprobe 8021q

vconfig add eth0 100

nano /etc/network/interface

auto eth0.100
iface eth0.100 inet static
address 172.10.10.21
netmask 255.255.255.240

sudo ifup eth0.100

check configuration

ifconfig

the result is
root@kodok:/etc# ifconfig
eth0 Link encap:Ethernet HWaddr 00:1c:23:fa:a2:87
inet addr:172.20.20.162 Bcast:172.20.20.163 Mask:255.255.255.252
inet6 addr: fe80::21c:23ff:fefa:a287/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:87 errors:0 dropped:0 overruns:0 frame:0
TX packets:190 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:9331 (9.3 KB) TX bytes:27504 (27.5 KB)
Interrupt:17

eth0.100 Link encap:Ethernet HWaddr 00:1c:23:fa:a2:87
inet addr:172.10.10.21 Bcast:172.10.10.31 Mask:255.255.255.240
inet6 addr: fe80::21c:23ff:fefa:a287/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:88 errors:0 dropped:0 overruns:0 frame:0
TX packets:136 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:7463 (7.4 KB) TX bytes:13686 (13.6 KB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:228 errors:0 dropped:0 overruns:0 frame:0
TX packets:228 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:17960 (17.9 KB) TX bytes:17960 (17.9 KB)

test connection

ping from pc to device
ping 172.10.10.23

root@kodok:/etc# ping 172.10.10.23
PING 172.10.10.23 (172.10.10.23) 56(84) bytes of data.
64 bytes from 172.10.10.23: icmp_req=2 ttl=255 time=1.57 ms
64 bytes from 172.10.10.23: icmp_req=3 ttl=255 time=1.52 ms
64 bytes from 172.10.10.23: icmp_req=4 ttl=255 time=1.47 ms
64 bytes from 172.10.10.23: icmp_req=5 ttl=255 time=1.62 ms
64 bytes from 172.10.10.23: icmp_req=6 ttl=255 time=1.58 ms
64 bytes from 172.10.10.23: icmp_req=7 ttl=255 time=1.61 ms
64 bytes from 172.10.10.23: icmp_req=8 ttl=255 time=1.50 ms
64 bytes from 172.10.10.23: icmp_req=9 ttl=255 time=1.52 ms
64 bytes from 172.10.10.23: icmp_req=10 ttl=255 time=1.56 ms