Lab Environment:
- Router: Cisco 2951
- Switch: Cisco C3750G PoE
- 2 VLANs
Method 1: router-on-a-stick
Topology: C3750G (GigabitEthernet3/0/1) -- CISCO2951(GigabitEthernet0/1) -- INTERNET(GigabitEthernet0/0)
On CISCO2951:
CISCO2951(config)#interface GigabitEthernet 0/0
CISCO2951(config-if)#no shutdown
CISCO2951(config-if)#speed 1000
CISCO2951(config-if)#duplex full
CISCO2951(config-if)#exit
CISCO2951(config)#interface GigabitEthernet 0/0.10
CISCO2951(config-subif)#encapsulation dot1Q 10
CISCO2951(config-subif)#ip address 192.168.10.1 255.255.255.0
CISCO2951(config-subif)#exit
CISCO2951(config)#interface GigabitEthernet 0/0.20
CISCO2951(config-subif)#encapsulation dot1Q 20
CISCO2951(config-subif)#ip address 192.168.20.1 255.255.255.0
On C3750G:
C3750G(config)#interface GigabitEthernet 3/0/1
C3750G(config-if)#switchport mode trunk
C3750G(config-if)#switchport trunk encapsulation dot1q
C3750G(config-if)#no shutdown
C3750G(config-if)#speed 1000
C3750G(config-if)#duplex full
C3750G(config-if)#exit
C3750G(config)#vlan 10
C3750G(config-vlan)#name VLAN10
C3750G(config-vlan)#exit
C3750G(config)#vlan 20
C3750G(config-vlan)#name VLAN20
C3750G(config-vlan)#exit
# Assign ports to the VLANs as needed:
C3750G(config)#interface GigabitEthernet 3/0/2
C3750G(config-if)#switchport mode access
C3750G(config-if)#switchport access vlan 10
C3750G(config-if)#no shutdown
C3750G(config-if)#speed 1000
C3750G(config-if)#duplex full
C3750G(config-if)#exit
C3750G(config)#interface GigabitEthernet 3/0/3
C3750G(config-if)#switchport mode access
C3750G(config-if)#switchport access vlan 20
C3750G(config-if)#no shutdown
C3750G(config-if)#speed 1000
C3750G(config-if)#duplex full
C3750G(config-if)#exit
Method 2: SVI (Switch Virtual Interface) and InterVLAN routing on C3750G switch.
Topology: C3750G (GigabitEthernet3/0/1) -- CISCO2951(GigabitEthernet0/1) -- INTERNET(GigabitEthernet0/0)
CISCO2951 Configs:
# Configure GigabitEthernet 0/0 (connected to ISP's device for internet access) to use DHCP.
CISCO2951(config)#interface GigabitEthernet 0/0
CISCO2951(config-if)#ip address dhcp
CISCO2951(config-if)#ip nat outside
CISCO2951(config-if)#ip virtual-reassembly in
CISCO2951(config-if)#no shutdown
CISCO2951(config-if)#speed 1000
CISCO2951(config-if)#duplex full
CISCO2951(config-if)#exit
# Configure GigabitEthernet0/1 (connected to C3750G).
CISCO2951(config)#interface GigabitEthernet 0/1
CISCO2951(config-if)#ip address 192.168.0.1 255.255.255.0
CISCO2951(config-if)#ip access-group NAT_ACL in
CISCO2951(config-if)#ip nat inside
CISCO2951(config-if)#ip virtual-reassembly in
CISCO2951(config-if)#no shutdown
CISCO2951(config-if)#speed 1000
CISCO2951(config-if)#duplex full
CISCO2951(config-if)#exit
# Configure ACL and NAT.
CISCO2951(config)#ip dns server
CISCO2951(config)#ip name-server 1.1.1.1
CISCO2951(config)#ip access-list extended NAT_ACL
CISCO2951-K9(config-ext-nacl)#permit ip 192.168.0.0 0.0.0.255 any
CISCO2951-K9(config-ext-nacl)#exit
CISCO2951(config)#ip nat inside source list NAT_ACL interface GigabitEthernet0/0 overload
# Enable routing and configure EIGRP (optional, depending on your configs)
CISCO2951(config)#ip routing
CISCO2951(config)#router eigrp 100
CISCO2951(config-router)#network 192.168.0.0 0.0.0.255
C3750G Configs:
# Enable routing:
C3750G(config)#ip routing
# Configure cef (Cisco Express Forwarding
) for better performance:
C3750G(config)#ip cef distributed
C3750G(config)#ip cef optimize neighbor resolution
#Configure DNS
C3750G(config)#ip domain-lookup
C3750G(config)#ip name-server 192.168.0.1
# Enable spanning-tree protocol.
C3750G(config)#spanning-tree mode rapid-pvst
# Configure VLANs
C3750G(config)#vlan 10
C3750G(config-vlan)#name VLAN10
C3750G(config-vlan)#exit
C3750G(config)#vlan 20
C3750G(config-vlan)#name VLAN20
C3750G(config-vlan)#exit
C3750G(config)#interface vlan 10
C3750G(config-if)#ip address 192.168.10.1 255.255.255.0
C3750G(config-if)#ip helper-address 192.168.0.1
C3750G(config)#interface vlan 20
C3750G(config-if)#ip address 192.168.20.1 255.255.255.0
C3750G(config-if)#ip helper-address 192.168.0.1
# Configure trunk port
C3750G(config)#interface GigabitEthernet 3/0/1
C3750G(config-if)#no switchport
C3750G(config-if)#ip address 192.168.0.2 255.255.255.0
C3750G(config-if)#no shutdown
C3750G(config-if)#speed 1000
C3750G(config-if)#duplex full
# Configure default route.
C3750G(config)#ip route 0.0.0.0 0.0.0.0 GigabitEthernet 3/0/1
# Assign ports to VLANs
C3750G(config)#interface range GigabitEthernet 3/0/2 - 5
C3750G(config-if-range)#switchport access vlan 10
C3750G(config-if-range)#switchport mode access
C3750G(config-if-range)#speed 1000
C3750G(config-if-range)#duplex full
C3750G(config-if-range)#no shut
C3750G(config)#interface range GigabitEthernet 3/0/6 - 12
C3750G(config-if-range)#switchport access vlan 20
C3750G(config-if-range)#switchport mode access
C3750G(config-if-range)#speed 1000
C3750G(config-if-range)#duplex full
C3750G(config-if-range)#no shut