Configuring VLANs on Red Hat 5 servers and a Catalyst 2950
Updated on 2011-11-10 by David Gómez
Created on 2011-11-04 by Nicolas Bondier
Switzernet
VLAN creation on a Red Hat 5 distribution
Configuring the console connection
The goal of this document is describe how to configure VLANs over a Red Hat 5 distribution and also over a Cisco Catalyst 2950-24.
Starting point: we have a server with a network adapter installed and we want to create 2 VLANs (e.g. VLAN5 and VLAN6).
In this situation, first of all we need to configure our network adapter. To do this, we need to modify (or create in case it doesn’t exist) with a text editor (e.g. vi editor) the following archive:
/etc/sysconfig/network-scripts/ifcfg-eth0
The content of the file should have the following lines:
DEVICE=eth0
BOOTPROTO=static
BROADCAST=192.xxx.xxx.255
IPADDR=192.xxx.xxx.xxx
HWADDR=xx:xx:xx:xx:xx:xx
NETMASK=255.255.255.0
NETWORK=192.xxx.xxx.0
ONBOOT=yes
TYPE=Ethernet
We the fields: IPADDR, HWADDR, NETMASK and NETWORK, will depend on the network scheme that you have.
Now we can create our VLANs. As well as we have done to configure the network adaptor, we create two file (one per VLAN):
/etc/sysconfig/network-scripts/ifcfg-vlan5
/etc/sysconfig/network-scripts/ifcfg-vlan6
The files should contains:
(VLAN 5)
VLAN=yes
VLAN_NAME_TYPE=VLAN_PLUS_VID_NO_PAD
DEVICE=vlan5
PHYSDEV=eth0
BOOTPROTO=static
ONBOOT=yes
TYPE=Ethernet
IPADDR=212.xxx.xxx.101
NETMASK=255.255.255.240
(VLAN 6)
VLAN=yes
VLAN_NAME_TYPE=VLAN_PLUS_VID_NO_PAD
DEVICE=vlan6
PHYSDEV=eth0
BOOTPROTO=static
ONBOOT=yes
TYPE=Ethernet
IPADDR=192.xxx.xxx.11
NETMASK=255.255.255.0
Also we need to add a gateway in the configuration file:
/etc/sysconfig/network-scripts/route-vlan5
like:
0.0.0.0/0 via 212.xxx.xxx.98
After that, we need to modify with a text editor the following configuration file:
/etc/resolv.conf
This file contains information that determines the operational parameters of the DNS resolver. We should add the following lines:
nameserver 212.xxx.xxx.98
search fix.access.vtx.ch
With these steps, we have configured our VLANs.
First connection to a Cisco switch should be done through it console port with the Cisco console cable. The Catalyst 2950-24 has the console port at the rear.
Notice that our PC must have a serial port, but if it hasn’t one we should use a serial port-to-usb adapter.
In order to connect we should configure a HyperTerminal connection as shows in the figure:
This configuration is needed to be applied in the COM port where we have connected the Cisco console cable (or the serial port-to-usb adapter). If we have problems to establish which port we are using, follow these steps:
In the above figure, we can see that we are using the serial port-to-usb adapter in the COM3.
So now, we have determined our serial port and we can configure the HyperTerminal connection.
Once we have configured the HyperTerminal, we start the connection:
And after that, we turn on the switch. At this point we see the Catalyst load process:
Switch con0 is now available
Press RETURN to get started.
C2950 Boot Loader (C2950-HBOOT-M) Version 12.1(11r)EA1, RELEASE SOFTWARE (fc1)
Compiled Mon 22-Jul-02 17:18 by xxxxxxx
WS-C2950-24 starting...
Base ethernet MAC Address: xx:xx:xx:xx:xx:xx
Xmodem file system is available.
Initializing Flash...
flashfs[0]: 90 files, 3 directories
flashfs[0]: 0 orphaned files, 0 orphaned directories
flashfs[0]: Total bytes: 7741440
flashfs[0]: Bytes used: 6475264
flashfs[0]: Bytes available: 1266176
flashfs[0]: flashfs fsck took 10 seconds.
...done initializing flash.
Boot Sector Filesystem (bs:) installed, fsid: 3
Parameter Block Filesystem (pb:) installed, fsid: 4
Loading "flash:/c2950-i6q4l2-mz.121-20.EA2.bin"...##############################
################################################################################
################################################################################
###
File "flash:/c2950-i6q4l2-mz.121-20.EA2.bin" uncompressed and installed, entry p
oint: 0x80010000
executing...
Restricted Rights Legend
Use, duplication, or disclosure by the Government is
subject to restrictions as set forth in subparagraph
(c) of the Commercial Computer Software - Restricted
Rights clause at FAR sec. 52.227-19 and subparagraph
(c) (1) (ii) of the Rights in Technical Data and Computer
Software clause at DFARS sec. 252.227-7013.
cisco Systems, Inc.
170 West Tasman Drive
San Jose, California 95134-1706
Cisco Internetwork Operating System Software
IOS (tm) C2950 Software (C2950-I6Q4L2-M), Version 12.1(20)EA2, RELEASE SOFTWARE
(fc1)
Copyright (c) 1986-2004 by cisco Systems, Inc.
Compiled Wed 19-May-04 03:07 by xxxxxxx
Image text-base: 0x80010000, data-base: 0x80550000
Initializing flashfs...
flashfs[1]: 90 files, 3 directories
flashfs[1]: 0 orphaned files, 0 orphaned directories
flashfs[1]: Total bytes: 7741440
flashfs[1]: Bytes used: 6475264
flashfs[1]: Bytes available: 1266176
flashfs[1]: flashfs fsck took 10 seconds.
flashfs[1]: Initialization complete.
Done initializing flashfs.
POST: System Board Test : Passed
POST: Ethernet Controller Test : Passed
ASIC Initialization Passed
POST: FRONT-END LOOPBACK TEST : Passed
cisco WS-C2950-24 (RC32300) processor (revision H0) with 20913K bytes of memory.
Processor board ID FOC0713W14R
Last reset from system-reset
Running Standard Image
24 FastEthernet/IEEE 802.3 interface(s)
32K bytes of flash-simulated non-volatile configuration memory.
Base ethernet MAC Address: xx:xx:xx:xx:xx:xx
Motherboard assembly number: xx-xxxx-xx
Power supply part number: xx-xxxx-xx
Motherboard serial number: xxxxxxxxxxx
Power supply serial number: xxxxxxxxxxx
Model revision number: H0
Motherboard revision number: A0
Model number: WS-C2950-24
System serial number: xxxxxxxxxxx
Press RETURN to get started!
Ok, the switch has finished the load and now it’s waiting us for a new configuration. If it’s a new device, it should ask us for basic parameters configuration, but if not (or if it doesn’t ask us for basic parameters configuration) that means that we need to clean up the previous configuration that it has.
We proceed typing the following commands:
dir flash:
This command show all the folders and files that have been loaded in the switch’s flash memory.
It should be a config.text file. It contains an old configuration. We can delete it but it’s safer if we rename it:
rename flash:config.text flash:config.backup
Now, we reset the switch:
reload
When the switch is rebooting, we can see the entire load’s dialog again, and when it finish, we will be asked if we want to do an initial configuration. We answer yes.
The following link is a guide to configure our switch:
http://www.cisco.com/en/US/docs/switches/lan/catalyst2950/software/release/12.1_22ea/SCG/2950SCG.pdf
The commands that we need in this case are showed below:
Switch# vlan database
Switch(vlan)# vlan 5 name Vlan5
Switch(vlan)# vlan 6 name Vlan6
Switch(vlan)# exit
Switch# configure terminal
Switch(config)# interface range f0/1 - 3
Switch(config-if)# switchport access vlan 2
Switch(config-if)# no shutdown
Switch(config-if)# exit
Switch(config)# interface range f0/9 - 15
Switch(config-if)# switchport mode trunk
Switch(config-if)# switchport trunk allowed vlan 1, 5, 6
Switch(config-if)# no shutdown
Switch(config-if)# exit
Switch(config)# interface f0/16
Switch(config-if)# switchport mode trunk
Switch(config-if)# no shutdown
Switch(config-if)# exit
Switch(config)# interface f0/24
Switch(config-if)# switchport access vlan 6
Switch(config-if)# no shutdown
Switch(config-if)# exit
Switch(config)# interface Vlan5
Switch(config-if)# ip address 212.xxx.xxx.100 255.255.255.240
Switch(config-if)# exit
Switch(config)# ip default-gateway 212.xxx.xxx.98
At the end we will have the following configuration:
!
version 12.1
no service pad
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname Switch
!
no logging console
enable secret 5 $1$fTmk$wDTR4Z4XYsoqtN2k/U/3Z.
enable password xxxxxxxxx
!
ip subnet-zero
!
!
spanning-tree mode pvst
no spanning-tree optimize bpdu transmission
spanning-tree extend system-id
!
!
!
!
interface FastEthernet0/1
switchport access vlan 5
!
interface FastEthernet0/2
switchport access vlan 5
!
interface FastEthernet0/3
switchport access vlan 5
!
interface FastEthernet0/4
!
interface FastEthernet0/5
!
interface FastEthernet0/6
!
interface FastEthernet0/7
!
interface FastEthernet0/8
!
interface FastEthernet0/9
switchport trunk allowed vlan 1,5,6
switchport mode trunk
!
interface FastEthernet0/10
switchport trunk allowed vlan 1,5,6
switchport mode trunk
!
interface FastEthernet0/11
switchport trunk allowed vlan 1,5,6
switchport mode trunk
!
interface FastEthernet0/12
switchport trunk allowed vlan 1,5,6
switchport mode trunk
!
interface FastEthernet0/13
switchport trunk allowed vlan 1,5,6
switchport mode trunk
!
interface FastEthernet0/14
switchport trunk allowed vlan 1,5,6
switchport mode trunk
!
interface FastEthernet0/15
switchport trunk allowed vlan 1,5,6
switchport mode trunk
!
interface FastEthernet0/16
switchport mode trunk
!
interface FastEthernet0/17
!
interface FastEthernet0/18
!
interface FastEthernet0/19
!
interface FastEthernet0/20
!
interface FastEthernet0/21
!
interface FastEthernet0/22
!
interface FastEthernet0/23
!
interface FastEthernet0/24
switchport access vlan 6
!
interface Vlan1
no ip address
no ip route-cache
shutdown
!
interface Vlan5
ip address 212.xxx.xxx.100 255.255.255.240
no ip route-cache
!
ip default-gateway 212.xxx.xxx.98
ip http server
!
line con 0
line vty 0 4
password xxxxxxxxx
login
line vty 5 15
password xxxxxxxxx
login
!
!
end
VLANs configuration with OVH: http://switzernet.com/3/public/111011-vlans-conf/