思科网络实训

网络拓扑

实验拓扑如下:

image-20210621155601466

简单介绍: 左边所有的主机的ip在走向出口路由器时ip会转变为10.208.2.1,中间汇聚层交换机进行链路聚合,右边使用单臂路由来连接三个vlan,服务器开启DHCP服务器,出口路由器的nat是静态的,外部访问额10.208.2.3会间接访问10.208.100.2这台www服务器,其他的主机的ip不会nat转换

所有设备的配置命令

保存配置命令:

设备在特权模式下执行:

copy running-config startup-config
或者
write

配置命令如下:

LSW1:

Switch>enable 
Switch#configure terminal 
Switch(config)#hostname LSW1
LSW1(config)#interface port-channel 1
LSW1(config-if)#exit
LSW1(config)#interface g3/1
LSW1(config-if)#channel-group 1 mode on
LSW1(config)#interface g4/1
LSW1(config-if)#channel-group 1 mode on

port group 是配置层面上的一个物理端口组,配置到port group里面的物理端口才可以参加链路汇聚,并成为port channel里的某个成员端口。在逻辑上,port group 并不是一个端口,而是一个端口序列。加入port group 中的物理端口满足某种条件时进行端口汇聚,形成一个port channel,这个port channel 具备了逻辑端口的属性,才真正成为一个独立的逻辑端口。
显示链路聚合状态

show etherchannel summary

image-20210621134041028

LSW2:

Switch>enable 
Switch#configure terminal 
Switch(config)#hostname LSW2
LSW2(config)#interface g3/1
LSW2(config-if)#channel-group 1 mode on
LSW2(config)#interface g4/1
LSW2(config-if)#channel-group 1 mode on

显示链路聚合状态

image-20210621133817169

LSW3

Switch>enable 
Switch#configure terminal 
Switch(config)#hostname LSW3

LSW4

Switch>enable 
Switch#configure terminal 
Switch(config)#hostname LSW4

AR1

Router>enable 
Router#config
Router#configure terminal 
Router(config)#hostname AR1
Router(config)#interface g1/0
AR1(config-if)#no shutdown 
AR1(config-if)#ip address 10.208.0.1 255.255.255.0
AR1(config)#interface g2/0
AR1(config-if)#no shutdown 
AR1(config-if)#ip address 10.208.1.1 255.255.255.0
AR1(config)#interface g0/0
AR1(config-if)#no shutdown 
AR1(config-if)#ip address 10.208.2.1 255.255.255.0
----------------配置ospf--------------
//在OSPF路由中会使用route id来标识路由器的序列号,竞选DR和BDR根据router-id的大小进行。
//loopback 口叫回环口,是一个虚拟的接口,如果路由器不关机,
//即使物理口全down了,loopback口还是会存在的,一般loopback口是用来检测和管理路由器用的,
//同时,我们也可以用它来模拟主机等,因为它在正常的情况下非常稳定。
AR1(config)#interface loopback 0
AR1(config-if)#ip address 1.1.1.1 255.255.255.255
AR1(config-if)#exit
AR1(config)#route ospf 1
AR1(config-router)#router-id 1.1.1.1
AR1(config-router)#network 10.208.0.0 0.0.0.255 area 0
AR1(config-router)#network 10.208.1.0 0.0.0.255 area 0
AR1(config-router)#network 10.208.2.0 0.0.0.255 area 0
AR1(config-router)#exit
-----------nat地址转换配置--------
AR1(config)#access-list 1 permit 10.208.0.0 0.0.0.255
AR1(config)#access-list 1 permit 10.208.1.0 0.0.0.255
AR1(config)#ip nat inside source list 1 int g0/0 overload 
AR1(config)#interface g0/0
AR1(config-if)#ip nat outside //nat的走向,这里是出口,也就是所有的流量在这ip都会转变
AR1(config)#interface g1/0
AR1(config-if)#ip nat inside  
AR1(config)#interface g2/0
AR1(config-if)#ip nat inside 
AR1(config-if)#exit

AR2

Router>enable 
Router#configure terminal 
Router(config)#hostname AR2
AR2(config)#interface g0/0
AR2(config-if)#no shutdown 
AR2(config-if)#ip address 10.208.2.2 255.255.255.0
AR2(config)#interface g0/1
AR2(config)#no shutdown
AR2(config)#interface g1/0
AR2(config-if)#no shutdown 
AR2(config-if)#exit
AR2(config)#interface g1/0.10   //这里使用单臂路由
AR2(config-subif)#encapsulation dot1Q 10
AR2(config-subif)#ip address 10.208.10.1 255.255.255.0
AR2(config-subif)#exit
AR2(config)#interface g1/0.20
AR2(config-subif)#encapsulation dot1Q 20
AR2(config-subif)#ip address 10.208.20.1 255.255.255.0
AR2(config)#interface g1/0.100
AR2(config-subif)#encapsulation dot1Q 100   //端口中继链路封装协议是802.11q,路由器上配置trunk的封装协议
AR2(config-subif)#ip address 10.208.100.1 255.255.255.0
------------配置ospf----------
AR2(config)#interface loopback 0
AR2(config-if)#ip address 2.2.2.2 255.255.255.255
AR2(config-if)#exit
AR2(config)#route ospf 1
AR2(config-router)#router-id 2.2.2.2  //设置route-id
AR2(config-router)#network 10.208.2.0 0.0.0.255 area 0  //宣告ospf的网段
AR2(config-router)#network 10.208.10.0 0.0.0.255 area 0
AR2(config-router)#network 10.208.20.0 0.0.0.255 area 0
AR2(config-router)#network 10.208.100.0 0.0.0.255 area 0
----------nat地址转换---------   //将多个私网IP转换为同一公有(路由器出口)IP地址,依赖数据包中的端口号来进行区分。
AR2(config)#ip nat inside source static 10.208.100.2 10.208.2.3   //静态nat  访问10.208.2.3就是访问10.208.100.2(注意左侧网络直接访问服务器时不能通的,必须访问10.208.2.3来间接访问10.208.100.2)
AR2(config)#int g0/0
AR2(config-if)#ip nat outside 
AR2(config-if)#int g1/0.100
AR2(config-subif)#ip nat inside 
AR2(config-subif)#exit
------配置acl禁止vlan20访问www服务器-----  //一共配置了两条acl  acl1是用于nat转换的,acl2是用于vlan20禁止访问www服务器的
AR2(config)#access-list 100 deny tcp 10.208.20.0 0.0.0.255 host 10.208.100.2
AR2(config)#access-list 100 permit ip any any   //必须加这一条,不然其他网段也访问不了,思科匹配的规则是匹配不到则拒绝
AR2(config)#int g1/0.100
AR2(config-subif)#ip access-group 100 out
AR2(config-subif)#exit
-------dhcp中继--------
AR2(config)#interface g1/0.10
AR2(config-subif)#ip helper-address 10.208.100.2  //设置中继代理,真正的DHCP服务器的ip是10.208.100.2
AR2(config-subif)#exit
AR2(config)#interface g1/0.20
AR2(config-subif)#ip helper-address 10.208.100.2

在服务器上的DHCP配置(注意这里的ip的起始地址应该是10.208.x.2不是x.0,应该要去掉网关的10.208.x.1,图片有误,我不想再截图了)

image-20210622083215084

LSW5

Switch>enable 
Switch#configure terminal 
Switch(config)#hostname LSW5
LWS5(config)#vlan 10  //创建vlan 10,20,100
LWS5(config-vlan)#exit
LWS5(config)#vlan 20
LWS5(config-vlan)#exit
LWS5(config)#vlan 100
LWS5(config-vlan)#exit
LWS5(config)#interface g1/1
LWS5(config-if)#switchport mode access  
LWS5(config-if)#switch access vlan 100
LWS5(config-if)#exit
LWS5(config)#interface g2/1
LWS5(config-if)#switchport mode access 
LWS5(config-if)#switch access vlan 10
LWS5(config-if)#exit
LWS5(config)#interface g3/1
LWS5(config-if)#switchport mode access
LWS5(config-if)#switch access vlan 20
LWS5(config-if)#exit
LWS5(config)#interface g0/1
LWS5(config-if)#switchport mode trunk   //路由器和交换机之间设置为trunk
LWS5(config-if)#switchport trunk allowed vlan all

分析网络

右侧DHCP获取ip,服务器配置

image-20210621170706231

配置完AR1和AR2的ospf后全网互通

nat地址转换成功 pc0 ping pc10 , 该ping包在经过AR1路由器时,ip地址由10.208.0.2转换为10.208.2.1,转化为路由器出口的ip地址

image-20210621151553229

如果没有加ACL限制时,vlan20的PC机是可以访问WWW服务的

image-20210621141859988

在配置了acl之后,vlan20 里面的pc20访问www服务器,发现访问不了

image-20210621154244777

pc20 ping www服务器 AR2根据ACL表拒绝传递vlan20的数据包

image-20210621155114667

AR1 ospf邻居

image-20210621164240717

AR2 ospf邻居

image-20210621164452106

补充与优化

如果你只是想完成此次实训,那么接下来的内容无需再看

ospf优化

路由器的ospf数据包是向路由器的各个端口发送的,但是连接终端的设备不需要接收ospf报文,可以在连接终端的接口禁止ospf报文的发送

AR1,AR2,在连接终端的端口执行此命令

ip ospf database-filter all out  

链路聚合优化

由于交换机的stp协议收敛可能导致聚合的链路阻塞,所以在交换机上设置stp的优先级高一些,使stp在收敛的时候不会阻塞聚合的链路

spanning-tree vlan 1 priority 4096

清空配置

在enable模式下使用write erase命令

终端的设备不需要接收ospf报文,可以在连接终端的接口禁止ospf报文的发送

AR1,AR2,在连接终端的端口执行此命令

ip ospf database-filter all out  

链路聚合优化

由于交换机的stp协议收敛可能导致聚合的链路阻塞,所以在交换机上设置stp的优先级高一些,使stp在收敛的时候不会阻塞聚合的链路

spanning-tree vlan 1 priority 4096

清空配置

在enable模式下使用write erase命令
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值