InterVLAN Routing using Ubuntu with 1 Interface

Scenario:
  • Router: Ubuntu Server with 1 network card.
  • Clients: 2 WindowsXP in VLAN10,1 Ubuntu and 1 CentOS in VLAN20.
  • Switch: Cisco 2960
Cisco 2960 Switch Configuration:
interface FastEthernet0/1
description CONNECTED TO UBUNTU ROUTER
switchport mode trunk
!
!
!
interface FastEthernet0/5
description WINXP-1
switchport access vlan 10
switchport mode access
!
interface FastEthernet0/6
description WINXP-2
switchport access vlan 10
switchport mode access
!
!
!
interface FastEthernet0/15
description UBUNTU CLIENT
switchport access vlan 20
switchport mode access
!
interface FastEthernet0/16
description CentOS CLIENT
switchport access vlan 20
switchport mode access
 Ubuntu Router Configuration:

To install the vlan support on ubuntu, use this command:

sudo apt-get install vlan

Now we shall configure the vlans on Ubuntu router by editing the /etc/network/interfaces:

sudo nano /etc/network/interfaces

To enable ip forwarding, edit /etc/sysctl.conf file:

sudo nano /etc/sysctl.conf

Change net.ipv4.ip_forward from 0 to 1:

Load “8021q” kernel module:

(Optional): If the Ubuntu router didn’t load the 8021q kernel module at boot time, then use this command to add  the module to the kernel on boot:

sudo su -c 'echo "8021q" >> /etc/modules'

Restart the Networking service:

sudo /etc/init.d/networking restart

Use the ifconfig command to check the newly created vlan interfaces:

ifconfig

Verify the vlan configuration:

sudo cat /proc/net/vlan/config

Test from WinXP-1:

Test from WinXP-2:

Test from Ubuntu Client:

Test from CentOS Client:

Hope this will help you!

Please Remember me in your prayers!

One response to “InterVLAN Routing using Ubuntu with 1 Interface

  1. A.Jesin March 17, 2013 at 1:38 pm

    Superb tutorial Arbab. I’m configuring a Ubuntu machine with GNS3 to connect emulated routers with real switches as mentioned on GNS3 website http://www.gns3.net/switching-usb-to-ethernet-network-adapters-option/ In this case is a similar configuration required on the ubuntu machine ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: