实验拓扑及要求如上图所示
按照从左往右、自下而上的顺序,我们先来配置B公司网关及其以下的部分。
B-GW:
//划分vlan及端口封装
B-GW(config)#vlan 10
B-GW(config-vlan)#vlan 20
B-GW(config-vlan)#exit
B-GW(config)#interface g0/0
B-GW(config-if)#switchport mode access
B-GW(config-if)#switchport access vlan 10
B-GW(config-if)#exit
B-GW(config)#interface g0/1
B-GW(config-if)#switchport mode access
B-GW(config-if)#switchport access vlan 20
B-GW(config-if)#exit
B-GW(config)#interface g0/2
B-GW(config-if)#switchport mode access
B-GW(config-if)#switchport access vlan 10
B-GW(config-if)#exit
//配置SVI
B-GW(config)#interface vlan 10
B-GW(config-if)#ip address 192.168.1.1 255.255.255.0
B-GW(config-if)#no shutdown
B-GW(config-if)#exit
B-GW(config)#interface vlan 20
B-GW(config-if)#ip address 192.168.2.1 255.255.255.0
B-GW(config-if)#no shutdown
B-GW(config-if)#exit
//创建DHCP地址池及排除不能分配的IP地址
B-GW(config)#ip dhcp pool vlan10
B-GW(dhcp-config)#network 192.168.1.0 /24
B-GW(dhcp-config)#default-router 192.168.1.1
B-GW(dhcp-config)#dns-server 114.114.114.114
B-GW(dhcp-config)#exit
B-GW(config)#ip dhcp pool vlan20
B-GW(dhcp-config)#network 192.168.2.0 /24
B-GW(dhcp-config)#default-router 192.168.2.1
B-GW(dhcp-config)#dns-server 114.114.114.114
B-GW(dhcp-config)#exit
B-GW(config)#ip dhcp excluded-address 192.168.1.1
B-GW(config)#ip dhcp excluded-address 192.168.2.1
B-GW(config)#ip dhcp excluded-address 192.168.1.15
SERVER5:
SERVER5(config)#no ip routing
SERVER5(config)#interface g0/0
SERVER5(config-if)#ip address 192.168.1.15 255.255.255.0
SERVER5(config-if)#no shutdown
SERVER5(config-if)#exit
//设置telnet密码并打开telnet服务
SERVER5(config)#line vty 0 4
SERVER5(config-line)#password cisco1234
SERVER5(config-line)#login
SERVER5(config-line)#transport input telnet
打开PC进行配置,以PC3为例:
PC3(config)#no ip routing
PC3(config)#interface g0/1
PC3(config-if)#ip address dhcp
PC3(config-if)#no shutdown
配置完成后PC端会提示已获取到IP地址
<