Monday, May 14, 2012

GNS3 - Switch Configuration

This post is about how to work with switching in GNS3.

Configuration on how to create VLAN:

     SW4#vlan database
     SW4(vlan)#vlan 10 name Data_VLAN
      VLAN 10 added:
         Name: Data_VLAN
     SW4(vlan)#vlan 20 name Voice_VLAN
      VLAN 20 added:
        Name: Voice_VLAN
     SW4(vlan)#vlan 100 name MGMT_VLAN
      VLAN 100 added:
       Name: MGMT_VLAN

     SW4(vlan)#apply
     APPLY completed.
     SW4(vlan)#exit


To join interfaces to VLAN

     SW4(config)#int range fa 0/3 - 5
     SW4(config-if-range)#switchport access vlan 10
     SW4(config-if-range)#switchport voice vlan 20
     SW4(config-if-range)#spanning-tree portfast
     SW4(config-if-range)#exit

To show the VLAN status

     SW4#show vlan-switch brief
     VLAN Name                                   Status    Ports
     ----       -------------------------------- --------- -------------------------------
     1          default                                 active    Fa0/6, Fa0/7, Fa0/8, Fa0/9
                                                                           Fa0/10, Fa0/11, Fa0/12, Fa0/13
                                                                           Fa0/14
     10        Data_VLAN                       active     Fa0/1, Fa0/2, Fa0/3, Fa0/4
                                                                           Fa0/5
     20        Voice_VLAN                     active
     100      MGMT_VLAN                  active    Fa0/15
     1002    fddi-default                         active
     1003    token-ring-default               active
     1004    fddinet-default                    active
     1005    trnet-default                        active
     SW4#


To save vlan configuration to vlan.dat and to make sure router retains vlan database after restarting GNS3

     SW4#dir nvram:
     Directory of nvram:/

       123  -rw-        1536                    <no date>  startup-config
       124  ----           0                    <no date>  private-config

     129016 bytes total (127428 bytes free)
     SW4#config t
     Enter configuration commands, one per line.  End with CNTL/Z.
     SW4(config)#vtp file nvram:vlan.dat
     Setting device to store VLAN database at filename nvram:vlan.dat.
     SW4(config)#do dir nvram:
     Directory of nvram:/

       123  -rw-        1536                    <no date>  startup-config
       124  ----           0                    <no date>  private-config
         1  -rw-         780                    <no date>  vlan.dat

     129016 bytes total (126404 bytes free)
     SW4(config)#do wr mem
     Building configuration...
     [OK]
     SW4(config)#