春风十里不如你 —— Taozi - 交换机 https://xiongan.host/index.php/tag/%E4%BA%A4%E6%8D%A2%E6%9C%BA/ zh-CN Sun, 27 Sep 2026 05:09:00 +0800 Sun, 27 Sep 2026 05:09:00 +0800 【OSPF】基础配置案例 https://xiongan.host/index.php/archives/266/ https://xiongan.host/index.php/archives/266/ Sun, 27 Sep 2026 05:09:00 +0800 admin OSPF基础配置实例

ScreenShot_2026-09-27_044241_340.png

配置简单基础案例如图 有R1、R2、R3 要求使用OSPF 使得R1的1.1.1.1与R3的3.3.3.3互通

配置接口

#配置R1接口
[R1]int GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]dis this
[V200R003C00]
#
interface GigabitEthernet0/0/0
 ip address 10.0.1.254 255.255.255.0 
#
return
[R1-GigabitEthernet0/0/0]q
[R1]int LoopBack 0
[R1-LoopBack0]dis this
[V200R003C00]
#
interface LoopBack0
 ip address 1.1.1.1 255.255.255.0 
#
return
[R1-LoopBack0]

#配置R2接口
[R2]int GigabitEthernet 0/0/0
[R2-GigabitEthernet0/0/0]dis this
[V200R003C00]
#
interface GigabitEthernet0/0/0
 ip address 10.0.1.1 255.255.255.0 
#
return
[R2-GigabitEthernet0/0/0]q  
[R2]int GigabitEthernet 0/0/1
[R2-GigabitEthernet0/0/1]dis this
[V200R003C00]
#
interface GigabitEthernet0/0/1
 ip address 10.0.2.1 255.255.255.0 
#
return
[R2-GigabitEthernet0/0/1]

#配置R3接口
[R3]int GigabitEthernet 0/0/0
[R3-GigabitEthernet0/0/0]dis this
[V200R003C00]
#
interface GigabitEthernet0/0/0
 ip address 10.0.2.254 255.255.255.0 
#
return
[R3-GigabitEthernet0/0/0]q
[R3]int LoopBack 0
[R3-LoopBack0]dis this
[V200R003C00]
#
interface LoopBack0
 ip address 3.3.3.3 255.255.255.0 
#
return
[R3-LoopBack0]

配置OSPF

#配置R1 OSPF协议
[R1]ospf 1
[R1-ospf-1]dis this
[V200R003C00]
#
ospf 1 router-id 1.1.1.1 
 area 0.0.0.0 
  network 1.1.1.1 0.0.0.0 
  network 10.0.1.0 0.0.0.255
#
return
[R1-ospf-1]

#配置R2 OSPF协议
[R2]ospf 1
[R2-ospf-1]dis this
[V200R003C00]
#
ospf 1 router-id 2.2.2.2 
 area 0.0.0.0 
  network 10.0.1.0 0.0.0.255 
 area 0.0.0.1 
  network 10.0.2.0 0.0.0.255 
#
return
[R2-ospf-1]

#配置R3 OSPF协议
[R3]ospf 1
[R3-ospf-1]dis this
[V200R003C00]
#
ospf 1 router-id 3.3.3.3 
 area 0.0.0.1 
  network 3.3.3.3 0.0.0.0 
  network 10.0.2.0 0.0.0.255 
#
return
[R3-ospf-1]

此时配置完成后 会有相关提示 最终有Full 代表邻居建立完成

image-20260927045410811.png

结果验证

在路由器R2上查看OSPF邻居表 最终状态为Full 代表成功

[R2]dis ospf peer brief 

     OSPF Process 1 with Router ID 2.2.2.2
          Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          GigabitEthernet0/0/0             1.1.1.1          Full        
 0.0.0.1          GigabitEthernet0/0/1             3.3.3.3          Full        
 ----------------------------------------------------------------------------

从R1测试是否正常通3.3.3.3 查看正常通信

ScreenShot_2026-09-27_045757_366.png

如果不成功 可以从R2路由器的出接口抓包查看

ScreenShot_2026-09-27_045959_396.png

扩展

如果在R1新增10.10.10.10地址 R3新增30.30.30.30地址 让他们两个互通

只需要将新网段宣告进 OSPF

#在 R1 上操作:
<R1> system-view
[R1] ospf 1
[R1-ospf-1] area 0.0.0.0
[R1-ospf-1-area-0.0.0.0] network 10.10.10.0 0.0.0.255   <-- 宣告新网段
[R1-ospf-1-area-0.0.0.0] quit
[R1-ospf-1] quit

在 R3 上操作:
<R3> system-view
[R3] ospf 1
[R3-ospf-1] area 0.0.0.1   <-- 注意:R3 之前配置的是 Area 1
[R3-ospf-1-area-0.0.0.1] network 30.30.30.0 0.0.0.255   <-- 宣告新网段
[R3-ospf-1-area-0.0.0.1] quit
[R3-ospf-1] quit

注意:R2 不需要宣告 10.10.10.0 或 30.30.30.0,它只负责中转
测试结果:
<R1>ping -a 10.10.10.10 30.30.30.30
  PING 30.30.30.30: 56  data bytes, press CTRL_C to break
    Reply from 30.30.30.30: bytes=56 Sequence=1 ttl=254 time=40 ms
    Reply from 30.30.30.30: bytes=56 Sequence=2 ttl=254 time=30 ms
    Reply from 30.30.30.30: bytes=56 Sequence=3 ttl=254 time=30 ms
    Reply from 30.30.30.30: bytes=56 Sequence=4 ttl=254 time=40 ms
    Reply from 30.30.30.30: bytes=56 Sequence=5 ttl=254 time=30 ms

  --- 30.30.30.30 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 30/34/40 ms

在实际交换机或者路由器内如何使用抓包工具 抓取接口处数据

ScreenShot_2026-09-27_051626_778.png

]]>
0 https://xiongan.host/index.php/archives/266/#comments https://xiongan.host/index.php/feed/tag/%E4%BA%A4%E6%8D%A2%E6%9C%BA/
华为交换机的学习文档(持续更新) https://xiongan.host/index.php/archives/231/ https://xiongan.host/index.php/archives/231/ Tue, 21 May 2024 04:44:59 +0800 admin 基础配置

如何配置端口镜像

//将交换机连接监控设备的端口配置观察端口
//例如,将监控设备的端口GE0/0/20配置成观察端口
[SWA]observe-port 1 int g0/0/20
//将待镜像的报文流经的端口设置镜像端口,将这个端口需要镜像的方向,即接受或发送报文的方向绑定到观察端口
//将连接下游主机的端口GE0/0/7配置成镜像端口
[SWA]int g0/0/7
[SWA]port-mirroring to observe-port 1 inbound

配置如上后,就可以在监控设备上启用监控软件,获取镜像报文

]]>
0 https://xiongan.host/index.php/archives/231/#comments https://xiongan.host/index.php/feed/tag/%E4%BA%A4%E6%8D%A2%E6%9C%BA/
华为S系列的交换机Telnet登录 https://xiongan.host/index.php/archives/230/ https://xiongan.host/index.php/archives/230/ Sat, 06 Apr 2024 07:47:35 +0800 admin telnet01.png

通过telent登录交换机

应用场景:两台物理交换机(同段)之间的telnet访问 SW2 可以 以AAA验证方式登录到SW1的VRP系统

已经配置好了交换机的vlanif 2端口ip (两台都在同段)

具体配置

  1. 配置Telnet登录所用的VTY用户界面的终端属性,指定VTY 0\~4这5条VTY虚拟通道可以用于登录

    [SW1]user-interface vty 0 4
    [SW1-ui-vty0-4]idle-timeout 20  //设置超时间为20分钟
    [SW1-ui-vty0-4]history-command max-size 20   //设置历史命令缓冲区的大小为20
  2. 配置Telnet登录VTY用户界面的AAA验证方式和用户类别

    [SW1-ui-vty0-4]authentication-mode aaa
    [SW1-ui-vty0-4]user privilege level 15
    [SW1-ui-vty0-4]q
  3. 配置控制通过Telnet访问交换机的用户ACL策略

    [SW1]user-interface maximum-vty 5  //设置VTY用户界面的最大个数
    [SW1]acl 2001
    [SW1-acl-basic-2001]rule permit source xxx  //配置仅允许IP地址xx的主机访问
    [SW1-acl-basic-2001]q
    [SW1]user-interface vty 0 4
    [SW1-ui-vty0-4]acl 2001 inbound //在VTY 0-4这5个用户界面中应用上面的ACL
  4. 创建用于Telnet登录AAA验证的用户名和密码

    [SW1]aaa
    [SW1-aaa]local-user huawei password cipher hello@123 //设置用户密码
    [SW1-aaa]local-user huawei service-type telnet //设置该用户的服务类型为telnet
    [SW1-aaa]local-user huawei privilege level 15 //生效级别设置的15
  5. 开启Telnet服务器功能,并设置端口

    [SW1]telnet server enable
    [SW1]telnet server port 1028

测试结果查看,在SW2测试telnet交换机SW1

image-20240406074230226.png

]]>
0 https://xiongan.host/index.php/archives/230/#comments https://xiongan.host/index.php/feed/tag/%E4%BA%A4%E6%8D%A2%E6%9C%BA/
【OpenDaylight】及Postman实现流表下发 https://xiongan.host/index.php/archives/198/ https://xiongan.host/index.php/archives/198/ Fri, 14 Apr 2023 00:25:00 +0800 admin 安装OVS
主机名ip角色
ovs192.168.123.10ovs

首先连接SSH

用finalshell连接,需要提前配置好ip和网卡

上传ovs源文件,并解压

68120158273

进入目录,执行./configure,生成Makefile文件

68120164422

然后进入编译安装

make
make install

68120167841

实验六-OpenDaylight及Postman实现流表下发

使用Opendaylight虚拟机

安装jdk1.8,并启动opendaylight

68120286124

安装组件:

68120391184

首先清理旧数据

DELETE http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/

image-20230413235336190

然后CLI命令行里再次清理

sudo mn -c

生成拓扑并连接 OpenDaylight

sudo mn --topo=single,3 --controller=remote,ip=本机ip,port=6633 --switch ovsk,protocols=OpenFlow13

68120401669

68120403714

使用 Postman 填入 JSON 格式的 http 请求

image-20230413235939496

image-20230413235900248

//以下内容是Body中需要填写的
{
    "flow": [
         {
             "id": "1",
             "match": {
                 "in-port": "1",
                 "ethernet-match": {
                     "ethernet-type": {
                         "type": "0x0800"
                     }
                 },
                 "ipv4-destination": "10.0.0.3/32"
             },
             "instructions": {
                 "instruction": [
                     {
                         "order": "0",
                         "apply-actions": {
                             "action": [
                                 {
                                     "order": "0",
                                     "drop-action": {}
                                 }
                             ]
                         }
                     }
                 ]
             },
             "flow-name": "flow1",
             "priority": "65535",
             "hard-timeout": "5", //此处需要修改间隔,意味着h1 ping h3 有5秒时间是中断的
             "cookie": "2",
             "table_id": "0"
         }
     ]
 }

现在CLI中h1 ping h3,再去PUT数据链接

测试成功,结果符合预期

image-20230414000211597

鸣谢:小桂哥,King

]]>
0 https://xiongan.host/index.php/archives/198/#comments https://xiongan.host/index.php/feed/tag/%E4%BA%A4%E6%8D%A2%E6%9C%BA/