配置简单的ospf命令和排错思路命令如下:

命令如下:

条件
PC1:
192.168.1.1/24
192.168.1.254

PC2:
192.168.2.1/24
192.168.2.254

三台路由器型号为AR2220路由
===============================================

三台路由配置命令如下
AR-1配置:
<Huawei>system-view     //进系统视图
[Huawei]sysname AR-1    //修改主机名为AR-1
[AR-1]int g0/0/2        //进g0/0/2接口
[AR-1-GigabitEthernet0/0/2]ip address 192.168.1.254 24            //配置IP地址和子网掩码
[AR-1-GigabitEthernet0/0/2]int g0/0/0        //切换接口
[AR-1-GigabitEthernet0/0/0]ip address 192.168.12.1 24            //配置IP地址和子网掩码
在AR-1上配置ospf命令如下:
[AR-1]ospf 1 router-id 1.1.1.1        //给ospf 1 设置名称为1.1.1.1
[AR-1-ospf-1]area 0            //进入骨干区域 0
[AR-1-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255            //在骨干区域内设置IP地址和反掩码地址
[AR-1-ospf-1-area-0.0.0.0]network 192.168.12.0 0.0.0.255        //在骨干区域内设置IP地址和反掩码地址

===========================================================================================
AR-2配置:
<Huawei>system-view     //进系统视图
[Huawei]sysname AR-2    //修改主机名为AR-2
[AR-2]int g0/0/0        //进g0/0/0接口
[AR-2-GigabitEthernet0/0/0]ip address 192.168.23.2 24            //配置IP地址和子网掩码
[AR-2-GigabitEthernet0/0/0]int g0/0/1        //切换接口
[AR-2-GigabitEthernet0/0/1]ip address 192.168.12.2 24            //配置IP地址和子网掩码
在AR-2上配置ospf命令如下
[AR-2]ospf 1 router-id 2.2.2.2        //给ospf 1 配置个名字为2.2.2.2
[AR-2-ospf-1]area 0            //进入骨干区域
[AR-2-ospf-1-area-0.0.0.0]network 192.168.12.0 0.0.0.255        //配置IP地址和反掩码地址
[AR-2-ospf-1-area-0.0.0.0]network 192.168.23.0 0.0.0.255        //配置IP地址和反掩码地址

============================================================================================
AR-3配置:
<Huawei>system-view        //进系统视图
[Huawei]sysname AR-3    //修改主机名为AR-3
[AR-3]int g0/0/2        //进g0/0/2接口
[AR-3-GigabitEthernet0/0/2]ip address 192.168.2.254 24            //配置IP地址和子网掩码
[AR-3-GigabitEthernet0/0/2]int g0/0/1        //切换接口
[AR-3-GigabitEthernet0/0/1]ip address 192.168.23.2 24            //配置IP地址和子网掩码
在AR-3上配置ospf命令如下
[AR-3]ospf 1 router-id 3.3.3.3        //给ospf 1 配置个名字为3.3.3.3
[AR-3-ospf-1]area 0            //进入骨干区域
[AR-3-ospf-1-area-0.0.0.0]network 192.168.23.0 0.0.0.255        //配置IP地址和反掩码地址
[AR-3-ospf-1-area-0.0.0.0]network 192.168.2.0 0.0.0.255            //配置IP地址和反掩码地址
[AR-3-ospf-1-area-0.0.0.0]q            //退到上一层
[AR-3-ospf-1]q        //继续退,退到上一层系统视图
修改cost值命令如下:
[AR-3]int g0/0/1            //进入g0/0/1接口
[AR-3-GigabitEthernet0/0/1]ospf cost 9        //将g0/0/1接口的cost修改为9 默认为1
检查出错误:
IP地址配置错误
[AR-3]dis ip int bri
*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              unassigned           down       down      
GigabitEthernet0/0/1              192.168.23.2/24      up         up          //找到的错误,IP地址配置错误      
GigabitEthernet0/0/2              192.168.2.254/24     up         up        
NULL0                             unassigned           up         up(s)     
[AR-3]int g0/0/1
修改方法:
[AR-3]int g0/0/1            //进接口
[AR-3-GigabitEthernet0/0/1]ip address 192.168.23.3 24    //修改IP地址和子网掩码    
========================================================================================

  验证和测试
[AR-3]dis ospf peer brief     //查看ospf邻居关系表

     OSPF Process 1 with Router ID 3.3.3.3
          Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          GigabitEthernet0/0/1             2.2.2.2          Full        
 ----------------------------------------------------------------------------
如果出现这个,就没有问题,如果没有出现上面的信息,那么你要进行检查或排查错误,排查命令如下:
1、在系统视图中查看IP地址和子网掩码看看有没有配置错误 命令查看如下:
[AR-3]dis ip int bri        //查看IP地址和子网掩码详细信息
*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              unassigned           down       down      
GigabitEthernet0/0/1              192.168.23.3/24      up         up        
GigabitEthernet0/0/2              192.168.2.254/24     up         up        
NULL0                             unassigned           up         up(s)     
2、就是进入查看ospf查看区域内的IP地址和反掩码,命令如下:
[AR-3]ospf 1             //进入ospf
[AR-3-ospf-1]dis th        //查看ospf内的配置命令
[V200R003C00]
#
ospf 1 router-id 3.3.3.3 
 area 0.0.0.0 
  network 192.168.2.0 0.0.0.255 
  network 192.168.23.0 0.0.0.255 
#
return
=============================================================================
[AR-3]dis ip routing-table protocol ospf         //查看ospf路由表
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 2        Routes : 2        

OSPF routing table status : <Active>
         Destinations : 2        Routes : 2

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

    192.168.1.0/24  OSPF    10   11          D   192.168.23.2    GigabitEthernet
0/0/1
   192.168.12.0/24  OSPF    10   10          D   192.168.23.2    GigabitEthernet
0/0/1

OSPF routing table status : <Inactive>
         Destinations : 0        Routes : 0
===================================================================================
如果输入没有查看到ospf路由表,查看思路如下:
1、检查ospf区域内的IP地址
    进入ospf内的详细信息
    [AR-3]ospf 1         //进入ospf 1
    [AR-3-ospf-1]dis this         //查看ospf内的命令信息
2、在此查看IP地址和子网掩码
在系统视图下查看IP地址和子网掩码命令如下
[AR-3]dis ip int bri    //查看IP地址和子网掩码详细信息

===================================================================================

测试pc和pc之间可以互通如图所示:

我是那pc1区pingpc2的IP地址,可以ping通即可完成实验

发布了37 篇原创文章 · 获赞 22 · 访问量 3986

猜你喜欢

转载自blog.csdn.net/qq_38936227/article/details/104671862