当前位置: 首页 > news >正文

网络学习-eNSP配置路由器

在这里插入图片描述

#PC1网关:192.168.1.254
#PC3网关:192.168.3.254
#PC4网关:192.168.4.254
# 注:路由器接口必须配置不同网段IP地址
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
#给路由器两个接口配置IP地址
[Huawei]interface gigabitethernet 0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 192.168.1.254 24
[Huawei-GigabitEthernet0/0/0]quit
[Huawei]interface gigabitethernet 0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 192.168.2.1 24
# 显示IP配置信息
[Huawei-GigabitEthernet0/0/1]display ip interface brief
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 3
The number of interface that is DOWN in Physical is 1
The number of interface that is UP in Protocol is 3
The number of interface that is DOWN in Protocol is 1Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              192.168.1.254/24     up         up        
GigabitEthernet0/0/1              192.168.2.1/24       up         up        
GigabitEthernet0/0/2              unassigned           down       down      
NULL0                             unassigned           up         up(s)
#取消IP地址配置
[Huawei-GigabitEthernet0/0/1]undo ip address
[Huawei-GigabitEthernet0/0/1]display ip interface brief
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 3
The number of interface that is DOWN in Physical is 1
The number of interface that is UP in Protocol is 2
The number of interface that is DOWN in Protocol is 2Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              192.168.1.254/24     up         up        
GigabitEthernet0/0/1              unassigned           up         down      
GigabitEthernet0/0/2              unassigned           down       down      
NULL0                             unassigned           up         up(s) 
# 网关:设备通往另外一个网段的途径,一般由路由器承担
# 路由器基于路由表转发数据
###
1.直连路由:由设备配置好IP并开启接口后自动产生
2.静态路由:由管理员手工配置,添加所需网段路由 ip route-static dest mask next-hop
3.动态路由:宣告
4.默认路由:特殊静态路由,通常用于访问外部网络  ip route-static 0.0.0.0 0 next-hop
###
# 查看路由表信息
[Huawei]display ip routing-table | include /24                  #过滤显示24位的路径表信息
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public         Destinations : 10       Routes : 10       
Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface
#去向1网段的数据从GigabitEthernet0/0/0传输
192.168.1.0/24  Direct  0    0           D   192.168.1.254   GigabitEthernet0/0/0
#去向2网段的数据从GigabitEthernet0/0/1传输
192.168.2.0/24  Direct  0    0           D   192.168.2.1     GigabitEthernet0/0/1
# 配置静态路由--192.168.1.0为要到达的网段地址,24为掩码,192.168.2.1为下一跳地址
[Huawei]ip route-static 192.168.1.0 24 192.168.2.1
[Huawei]display ip routing-table | include /24
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: PublicDestinations : 14       Routes : 14       
Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface
192.168.1.0/24  Static  60   0          RD   192.168.2.1     GigabitEthernet0/0/1
192.168.2.0/24  Direct  0    0           D   192.168.2.2     GigabitEthernet0/0/1
192.168.3.0/24  Direct  0    0           D   192.168.3.254   GigabitEthernet0/0/0
192.168.4.0/24  Direct  0    0           D   192.168.4.254   GigabitEthernet0/0/2

在这里插入图片描述

接入交换机配置
#接入交换机配置
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
Info: Information center is disabled.
# 批量创建vlan
[Huawei]vlan batch 2 3
Info: This operation may take a few seconds. Please wait for a moment...done.
# 配置0/0/2和0/0/3口为接入链路,放行相应vlan数据
[Huawei]interface ethernet 0/0/2
[Huawei-Ethernet0/0/2]port link-type access
[Huawei-Ethernet0/0/2]port default vlan 2
[Huawei-Ethernet0/0/2]quit
[Huawei]interface ethernet 0/0/3
[Huawei-Ethernet0/0/3]port link-type access
[Huawei-Ethernet0/0/3]port default vlan 3
[Huawei-Ethernet0/0/3]quit
# 配置0/0/4口为中继链路,放行所有vlan数据                   
[Huawei]interface ethernet 0/0/4
[Huawei-Ethernet0/0/4]port link-type trunk
[Huawei-Ethernet0/0/4]port trunk allow-pass vlan all
[Huawei-Ethernet0/0/4]quit
[Huawei]display vlan
The total number of vlans is : 3
--------------------------------------------------------------------------------
U: Up;         D: Down;         TG: Tagged;         UT: Untagged;
MP: Vlan-mapping;               ST: Vlan-stacking;
#: ProtocolTransparent-vlan;    *: Management-vlan;
--------------------------------------------------------------------------------
VID  Type    Ports                                                          
--------------------------------------------------------------------------------
1    common  UT:Eth0/0/1(U)     Eth0/0/4(U)     Eth0/0/5(D)     Eth0/0/6(D)     Eth0/0/7(D)     Eth0/0/8(D)     Eth0/0/9(D)     Eth0/0/10(D)    Eth0/0/11(D)    Eth0/0/12(D)    Eth0/0/13(D)    Eth0/0/14(D)    Eth0/0/15(D)    Eth0/0/16(D)    Eth0/0/17(D)    Eth0/0/18(D)    Eth0/0/19(D)    Eth0/0/20(D)    Eth0/0/21(D)    Eth0/0/22(D)    GE0/0/1(D)      GE0/0/2(D)                                      
2    common  UT:Eth0/0/2(U)                                                     TG:Eth0/0/4(U)                                                     
3    common  UT:Eth0/0/3(U)                                                     TG:Eth0/0/4(U)                                                     
VID  Status  Property      MAC-LRN Statistics Description      
--------------------------------------------------------------------------------
1    enable  default       enable  disable    VLAN 0001                         
2    enable  default       enable  disable    VLAN 0002                         
3    enable  default       enable  disable    VLAN 0003 
核心交换机配置
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
Info: Information center is disabled.
# 批量创建vlan
[Huawei]vlan batch 2 to 4
Info: This operation may take a few seconds. Please wait for a moment...done.
#对虚拟端口vlan1-4设置ip地址
[Huawei]interface vlanif 1
[Huawei-Vlanif1]ip address 192.168.1.254 24
[Huawei-Vlanif1]quit
[Huawei]interface vlanif 2
[Huawei-Vlanif2]ip address 192.168.2.254 24
[Huawei-Vlanif2]quit
[Huawei]interface vlanif 3
[Huawei-Vlanif3]ip address 192.168.3.254 24
[Huawei-Vlanif3]quit
[Huawei]interface vlanif 4
[Huawei-Vlanif4]ip address 192.168.4.254 24
[Huawei-Vlanif4]quit
[Huawei]interface gigabitethernet 0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type trunk
[Huawei-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[Huawei]interface gigabitethernet 0/0/2
[Huawei-GigabitEthernet0/0/2]port link-type access
[Huawei-GigabitEthernet0/0/2]port default vlan 4
[Huawei]display ip routing-table | include /24
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public         Destinations : 10       Routes : 10       Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface192.168.1.0/24  Direct  0    0           D   192.168.1.254   Vlanif1192.168.2.0/24  Direct  0    0           D   192.168.2.254   Vlanif2192.168.3.0/24  Direct  0    0           D   192.168.3.254   Vlanif3192.168.4.0/24  Direct  0    0           D   192.168.4.254   Vlanif4
[Huawei]display ip interface brief
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 5
The number of interface that is DOWN in Physical is 1
The number of interface that is UP in Protocol is 5
The number of interface that is DOWN in Protocol is 1Interface                         IP Address/Mask      Physical   Protocol  
MEth0/0/1                         unassigned           down       down      
NULL0                             unassigned           up         up(s)     
Vlanif1                           192.168.1.254/24     up         up        
Vlanif2                           192.168.2.254/24     up         up        
Vlanif3                           192.168.3.254/24     up         up        
Vlanif4                           192.168.4.254/24     up         up        
#配置动态路由
[Huawei]ospf
#定义一个区域
[Huawei-ospf-1]area 0
#宣告自身直连的网段,配置时使用反掩码
[Huawei-ospf-1-area-0.0.0.0]network 192.168.4.0 0.0.0.255            
[Huawei-ospf-1-area-0.0.0.0]network 192.168.3.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]network 192.168.2.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
路由器配置
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
Info: Information center is disabled.
[Huawei]interface gigabitethernet 0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 192.168.4.1 24
[Huawei-GigabitEthernet0/0/0]quit
[Huawei]interface gigabitethernet 0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 192.168.5.254 24
[Huawei-GigabitEthernet0/0/1]quit
[Huawei]display ip routing-table | include /24
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public         Destinations : 10       Routes : 10       
Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface
192.168.4.0/24  Direct  0    0           D   192.168.4.1     GigabitEthernet0/0/0
192.168.5.0/24  Direct  0    0           D   192.168.5.254   GigabitEthernet0/0/1
#配置动态路由
[Huawei]ospf
[Huawei-ospf-1]area 0
#宣告自身直连的网段,配置时使用反掩码
[Huawei-ospf-1-area-0.0.0.0]network 192.168.4.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]network 192.168.5.0 0.0.0.255
#查看当前配置信息
[Huawei-ospf-1]display this
[V200R003C00]
#
ospf 1 area 0.0.0.0 network 192.168.4.0 0.0.0.255 network 192.168.5.0 0.0.0.255 
#

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • 再遇“类和对象”
  • 杰发科技Bootloader(3)—— 基于7801的APP切到Boot
  • java设计模式day03--(结构型模式:代理模式、适配器模式、装饰者模式、桥接模式、外观模式、组合模式、享元模式)
  • 常用 Excel 笔记
  • shell的使用sed处理数据
  • 链表专题(Golang)
  • SpringBoot集成MyBatis-Plus
  • 如何在多台电脑上同步 VSCode配置和插件
  • N-152基于java贪吃蛇游戏5
  • 【论文阅读】视觉分割新SOTA: Segment Anything(SAM)
  • 【ABAP】ole2 excel多sheet导入导出
  • MySQL 解决时区相关问题
  • Map(HashMap)
  • SpringBoot开发——整合Logbook进行HTTP API请求响应日志输出
  • 卫生间装修防滑石用瓷砖还是大理石好呢?
  • [笔记] php常见简单功能及函数
  • 【140天】尚学堂高淇Java300集视频精华笔记(86-87)
  • 2017前端实习生面试总结
  • create-react-app做的留言板
  • HTTP请求重发
  • JavaScript DOM 10 - 滚动
  • JavaScript实现分页效果
  • Linux gpio口使用方法
  • Vue组件定义
  • Zepto.js源码学习之二
  • 测试开发系类之接口自动化测试
  • 纯 javascript 半自动式下滑一定高度,导航栏固定
  • 基于web的全景—— Pannellum小试
  • 微信小程序开发问题汇总
  • MyCAT水平分库
  • 阿里云移动端播放器高级功能介绍
  • 分布式关系型数据库服务 DRDS 支持显示的 Prepare 及逻辑库锁功能等多项能力 ...
  • 回归生活:清理微信公众号
  • 智能情侣枕Pillow Talk,倾听彼此的心跳
  • ​​​​​​​开发面试“八股文”:助力还是阻力?
  • ​ssh-keyscan命令--Linux命令应用大词典729个命令解读
  • ​必胜客礼品卡回收多少钱,回收平台哪家好
  • ​第20课 在Android Native开发中加入新的C++类
  • # 学号 2017-2018-20172309 《程序设计与数据结构》实验三报告
  • #define MODIFY_REG(REG, CLEARMASK, SETMASK)
  • (14)Hive调优——合并小文件
  • (3) cmake编译多个cpp文件
  • (function(){})()的分步解析
  • (汇总)os模块以及shutil模块对文件的操作
  • (十六)串口UART
  • (万字长文)Spring的核心知识尽揽其中
  • (文章复现)基于主从博弈的售电商多元零售套餐设计与多级市场购电策略
  • (原創) 如何優化ThinkPad X61開機速度? (NB) (ThinkPad) (X61) (OS) (Windows)
  • (转)iOS字体
  • (转)mysql使用Navicat 导出和导入数据库
  • ***通过什么方式***网吧
  • .NET 5.0正式发布,有什么功能特性(翻译)
  • .NET BackgroundWorker
  • .NET C# 使用GDAL读取FileGDB要素类
  • .NET MVC 验证码