网络学习-eNSP配置路由器

bash 复制代码
#PC1网关:192.168.1.254
#PC3网关:192.168.3.254
#PC4网关:192.168.4.254
bash 复制代码
# 注:路由器接口必须配置不同网段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 1

Interface                         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 2

Interface                         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: Public
         Destinations : 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
接入交换机配置
bash 复制代码
#接入交换机配置
<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 
核心交换机配置
bash 复制代码
<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         Interface
    192.168.1.0/24  Direct  0    0           D   192.168.1.254   Vlanif1
    192.168.2.0/24  Direct  0    0           D   192.168.2.254   Vlanif2
    192.168.3.0/24  Direct  0    0           D   192.168.3.254   Vlanif3
    192.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 1

Interface                         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
路由器配置
bash 复制代码
<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 
#
相关推荐
我要吐泡泡了哦29 分钟前
GAMES104:15 游戏引擎的玩法系统基础-学习笔记
笔记·学习·游戏引擎
骑鱼过海的猫12329 分钟前
【tomcat】tomcat学习笔记
笔记·学习·tomcat
贾saisai3 小时前
Xilinx系FPGA学习笔记(九)DDR3学习
笔记·学习·fpga开发
suifen_3 小时前
RK3229_Android9.0_Box 4G模块EC200A调试
网络
北岛寒沫3 小时前
JavaScript(JS)学习笔记 1(简单介绍 注释和输入输出语句 变量 数据类型 运算符 流程控制 数组)
javascript·笔记·学习
铁松溜达py3 小时前
编译器/工具链环境:GCC vs LLVM/Clang,MSVCRT vs UCRT
开发语言·网络
铁匠匠匠4 小时前
从零开始学数据结构系列之第六章《排序简介》
c语言·数据结构·经验分享·笔记·学习·开源·课程设计
架构文摘JGWZ6 小时前
Java 23 的12 个新特性!!
java·开发语言·学习
小齿轮lsl6 小时前
PFC理论基础与Matlab仿真模型学习笔记(1)--PFC电路概述
笔记·学习·matlab
Aic山鱼6 小时前
【如何高效学习数据结构:构建编程的坚实基石】
数据结构·学习·算法