A-A+
单臂路由和DHCP集成实验的拓扑图和配置命令行
网络拓扑图比较简单,所以通过文字描述一下就行了:一台交换机连接一台路由器之后,再连接4台PC客户端(PC0到PC3):
下面是路由器配置的全部命令行:
- Current configuration : 1351 bytes
- !
- version 12.2
- no service timestamps log datetime msec
- no service timestamps debug datetime msec
- no service password-encryption
- !
- hostname Router
- !
- ip dhcp excluded-address 192.168.20.1
- ip dhcp excluded-address 192.168.20.2
- ip dhcp excluded-address 192.168.20.4
- ip dhcp excluded-address 192.168.20.3
- ip dhcp excluded-address 192.168.30.1
- ip dhcp excluded-address 192.168.30.2
- ip dhcp excluded-address 192.168.30.3
- ip dhcp excluded-address 192.168.30.4
- !
- ip dhcp pool vlan20
- network 192.168.20.0 255.255.255.0
- default-router 192.168.20.1
- dns-server 202.96.134.133
- ip dhcp pool vlan30
- network 192.168.30.0 255.255.255.0
- default-router 192.168.30.1
- dns-server 202.96.134.133
- !
- interface FastEthernet0/0
- no ip address
- duplex auto
- speed auto
- !
- interface FastEthernet0/0.1
- encapsulation dot1Q 20
- ip address 192.168.30.1 255.255.255.0
- !
- interface FastEthernet0/0.2
- encapsulation dot1Q 30
- ip address 192.168.20.1 255.255.255.0
- !
- interface FastEthernet1/0
- no ip address
- duplex auto
- speed auto
- shutdown
- !
- interface Serial2/0
- no ip address
- clock rate 2000000
- shutdown
- !
- interface Serial3/0
- no ip address
- clock rate 2000000
- shutdown
- !
- interface FastEthernet4/0
- no ip address
- shutdown
- !
- interface FastEthernet5/0
- no ip address
- shutdown
- !
- ip classless
- !
- line con 0
- line vty 0 4
- login
- !
- end
交换机配置:
- Current configuration : 1260 bytes
- !
- version 12.2
- no service timestamps log datetime msec
- no service timestamps debug datetime msec
- no service password-encryption
- !
- hostname Switch
- !
- !
- spanning-tree mode pvst
- !
- interface FastEthernet0/1
- switchport mode trunk
- !
- interface FastEthernet0/2
- switchport access vlan 20
- switchport mode access
- !
- interface FastEthernet0/3
- switchport access vlan 20
- switchport mode access
- !
- interface FastEthernet0/4
- switchport access vlan 30
- switchport mode access
- !
- interface FastEthernet0/5
- switchport access vlan 30
- switchport mode access
- !
- line con 0
- !
- line vty 0 4
- login
- line vty 5 15
- login
- !
- end
实现效果:PC0和PC1自动从路由器获得VLAN 30网段的IP地址;PC2,PC3自动从路由器获得VLAN 20网段的IP地址。