思科实验基础代码

路由器的基本设置

configure terminal
hostname R1
enable secret class//设置加密口令,以进入特权执行模式
line console 0//进入控制台线路的线路配置模式
passwork cisco//设置密码
login//要求口令
exit
line vty 0 4//进入五条虚拟终端线路的线路配置模式
password cisco//设置vty口令
login//要求指令
exit
service password-encryption//提升加密等级
banner motd #This is a secure system.# //在用户连接路由器时显示标语
copy running-config startup-config//拷贝初始配置

实验四:配置vlan和中继

//端口分配vlan
interface f0/6
switchport mode access//进入交换模式
switchport access vlan 10
移动交换机 IP 地址 VLAN 99
S1(config)# interface vlan 1
S1(config-if)# no ip address
S1(config-if)# interface vlan 99
S1(config-if)# ip address 192.168.1.11 255.255.255.0
S1(config-if)# end

no switchport access vlan//将vlan默认分配给vlan1
S1(config)# interface f0/1
S1(config-if)# switchport mode dynamic desirable//配置中继接口
show interfaces trunk//查看中继接口

S1(config)# interface f0/1
S1(config-if)# switchport mode trunk//手动配置trunk

show flash//查看闪存中的数据库
delete vlan.dat//删除闪存中的文件

实验五:配置 802.1Q 基于 TRUNK 的 VLAN 间路由

//配置vlan子接口
a.在 R1 的 G0/1 上为 VLAN 1 创建子接口,使用 1 作为子接口 ID。在下面空白处写下您使用的命令。
R1(config)#int g0/1.1
b.配置子接口,使其在 VLAN 1 上运行。在下面空白处写下您使用的命令。
R1(config-subif)#encapsulation dot1q 
c.使用地址表中的 IP 地址配置子接口。在下面空白处写下您使用的命令。
R1(config-subif)#ip address 192.168.1.1 255.255.255.0

实验六:配置并检验标准 ACL

//配置ACL
R3(config)# access-list 1 remark Allow R1 LANs Access//注释
R3(config)# access-list 1 permit 192.168.10.0 0.0.0.255
R3(config)# access-list 1 permit 192.168.20.0 0.0.0.255
R3(config)# access-list 1 deny any
//将ACL分配到相应的接口上
R3(config)# interface g0/1
R3(config-if)# ip access-group 1 out
//查看ACL信息
show access-lists 1
show ip interface g0/1

实验七:在路由器上配置基本 DHCPv4

//配置EIGRP
R1(config)# router eigrp 1
R1(config-router)# network 192.168.0.0 0.0.0.255
R1(config-router)# network 192.168.1.0 0.0.0.255
R1(config-router)# network 192.168.2.252 0.0.0.3
R1(config-router)# no auto-summary
    
 
R2(config)# router eigrp 1
R2(config-router)# network 192.168.2.252 0.0.0.3
R2(config-router)# redistribute static//重发布静态路由 将静态路由注入路由协议里面
R2(config-router)# exit
R2(config)# ip route 0.0.0.0 0.0.0.0 209.165.200.225
//配置基本dhcp
R2(config)# ip dhcp excluded-address 192.168.0.1 192.168.0.9
R2(config)# ip dhcp excluded-address 192.168.1.1 192.168.1.9
R2(config)# ip dhcp pool R1G1
R2(dhcp-config)# network 192.168.1.0 255.255.255.0
R2(dhcp-config)# default-router 192.168.1.1
R2(dhcp-config)# dns-server 209.165.200.225
R2(dhcp-config)# domain-name ccna-lab.com
R2(dhcp-config)# lease 2
R2(dhcp-config)# exit
R2(config)# ip dhcp pool R1G0//创建地址池
R2(dhcp-config)# network 192.168.0.0 255.255.255.0//地址池
R2(dhcp-config)# default-router 192.168.0.1//默认网关
R2(dhcp-config)# dns-server 209.165.200.225//服务器名
R2(dhcp-config)# domain-name ccna-lab.com//定义域名
R2(dhcp-config)# lease 2//租期

//配置中继dhcp
interface g0/0
ip helper-address 192.168.2.254
    
show ip dhcp binding//全部IPv4地址和MAC地址绑定的列表
show ip dhcp server statistics//检验路由器正在接受或者发送信息

实验八:配置 NAT 地址池过载和 PAT

Gateway(config)# **access-list 1 permit 192.168.1.0 0.0.0.255**

Gateway(config)# **ip nat pool public_access 209.165.200.225**  **209.165.200.230 netmask 255.255.255.248**

Gateway(config)# **ip nat inside source list 1 pool public_access**

Gateway(config)# **interface g0/1**

Gateway(config-if)# **ip nat inside**

Gateway(config-if)# **interface s0/0/1**

Gateway(config-if)# **ip nat outside**
//配置单个地址pat
access-list 1 permit 192.168.0.0 0.0.255.255
ip nat inside source list 1 interface Serial0/1/0 overload
interface Serial0/0/0
ip nat inside
exit
interface Serial0/1/0
ip nat outside

实验九:配置快速 PVST+、PortFast 和 BPDU 防护

//交换机的生成树状态
show spanning-tree
//配置主根网桥
spanning-tree vlan 1,10,99 root primary
//配置次根网桥
spanning-tree vlan 1,10,99 root secondary
//监控生成树事件
debug spanning-tree events
//配置快速PVST+
spanning-tree mode rapid-pvst
//配置PortFast防护
spanning-tree portfast
//配置BPDU防护
spanning-tree bpduguard enable

实验十:构建包含冗余链路的交换网络

//修改根端口的开销
S1(config)# interface f0/2
S1(config-if)# spanning-tree cost 18
//观察生成树情况
S1# show spanning-tree
//删除端口开销更改
S1(config)# interface f0/2
S1(config-if)# no spanning-tree cost 18

实验十一:配置基本的单区域 OSPFv2

//启用ospf
R1(config)# router ospf 1
//配置ospf接管的网络区域
R1(config-router)# network 192.168.1.0 0.0.0.255 area 0
R1(config-router)# network 192.168.12.0 0.0.0.3 area 0
R1(config-router)# network 192.168.13.0 0.0.0.3 area 0
//检查路由器的邻居信息
R1# show ip ospf neighbor
//查看路由表中的ospf路由
Show ip route ospf
//ospf接口的摘要信息
R1# show ip ospf interface brief
//ospf接口的详细信息
R1# show ip ospf interface
//修改接口名
R1(config)# router ospf 1
R1(config-router)# router-id 11.11.11.11
Reload or use "clear ip ospf process" command, for this to take effect
R1(config)# end
//配置被动接口
R1(config)# router ospf 1
R1(config-router)# passive-interface g0/0
//配置默认被动接口
R2(config)# router ospf 1
R2(config-router)# passive-interface default
//取消某个被动接口
R2(config)# router ospf 1
R2(config-router)# no passive-interface s0/0/0
//更改默认带宽
R1(config)# router ospf 1
R1(config-router)# auto-cost reference-bandwidth 10000
//更改带宽设置
R1(config)# interface s0/0/0
R1(config-if)# bandwidth 128
//更改路由开销
R1(config)# interface s0/0/1
R1(config-if)# ip ospf cost 1565
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值