Cisco dhcp router on a stick
Description:
Pc4 pc5 is located at vlan 10, the IP segment 192.168.10.0max 24 obtained from router dhcp
Pc6 pc7 is located in the IP segment 192.168.20.0 obtained from router dhcp in vlan 20.
The gateway for all machines in vlan 10 is 192.168.10.254
The gateway for all machines in vlan 20 is 192.168.20.254
Different vlan can communicate.
1. Configure the switch.
The interface is divided into the corresponding vlan
Switch#show vlan briefVLAN Name Status Ports-----1 default active Fa0/6, Fa0/7, Fa0/8 Fa0/9Fa0/10, Fa0/11, Fa0/12, Fa0/13Fa0/14, Fa0/15, Fa0/16, Fa0/17Fa0/18, Fa0/19, Fa0/20, Fa0/21Fa0/22, Fa0/23, Fa0/2410 v10 active Fa0/2, Fa0/320 v20 active Fa0/4 Fa0/51002 fddi-default active1003 token-ring-default active1004 fddinet-default active1005 trnet-default activeSwitch#
two。 Configure vlan's
SW1 (config) # interface vlan10 SW1 (config-if) # ip helper-address 192.168.10.254 # SW1 (config) # interface vlan20 SW1 (config-if) # ip helper-address 192.168.20.254 # subinterface vlan20 of single-arm routing
3. Configure the uplink interface of the switch to trunk
Switch (config) # interface fastEthernet 0/1Switch (config-if) # swSwitch (config-if) # switchport mode trunk
4. Configure router-on-a-stick routing (the port linked between the router and the switch is the fa0/0 port)
Router (config) # interface fastEthernet 0/0.10Router (config-subif) # encapsulation dot1Q 10Router (config-subif) # ip addRouter (config-subif) # ip address 192.168.10.254 255.255.255.0Router (config) # interface fastEthernet 0/0.20Router (config-subif) # encapsulation dot1Q 20Router (config-subif) # ip addRouter (config-subif) # ip address 192.168.20.254 255.255.255.0
5. Configure dhcp
Router (config) # ip dhcp pool vlan10 # vlan10 is just the name Router (dhcp-config) # network 192.168.10.0 255.255.255.0Router (dhcp-config) # dns-server 223.5.5.5Router (dhcp-config) # default-router 192.168.10.254Router (dhcp-config) # exitRouter (config) # ip dhcp excluded-address 192.168.10.254Router (config) # ip dhcp pool vlan20 # vlan20 is just the name Router (dhcp-config) # network 192.168. 20.0 255.255.255.0Router (dhcp-config) # dns-server 223.5.5.5Router (dhcp-config) # default-router 192.168.20.254Router (dhcp-config) # exitRouter (config) # ip dhcp excluded-address 192.168.20.254
Final test: different vlan gets different Ip, different vlan can communicate OK.