hcia第三天 静态路由

本文介绍了如何配置路由器实现全网可达,包括静态路由和汇总路由,同时详细展示了如何在PC上设置DHCP服务,分配指定IP地址并排除特定范围。讨论了如何优化路由条目以减少PC间的路由数量,确保PC1访问PC3-5时的高效连接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.全网可达

分别给r1 r2 r3 r4 r5配置ip地址,通过ping检验直连是否通

[r1]interface g0/0/1
[r1-GigabitEthernet0/0/1]ip ad	
[r1-GigabitEthernet0/0/1]ip address 12.1.1.1 24
[r2]interface g0/0/0
[r2-GigabitEthernet0/0/0]ip ad	
[r2-GigabitEthernet0/0/0]ip address 12.1.1.2 24
[r2]interface g0/0/1
[r2-GigabitEthernet0/0/1]ip ad	
[r2-GigabitEthernet0/0/1]ip address 23.1.1.1 24
[r2]interface g0/0/2
[r2-GigabitEthernet0/0/2]ip ad	
[r2-GigabitEthernet0/0/2]ip address 32.1.1.1 24
[r3]interface g0/0/0 
[r3-GigabitEthernet0/0/0]ip ad	
[r3-GigabitEthernet0/0/0]ip address 23.1.1.2 24
[r3]interface g0/0/1
[r3-GigabitEthernet0/0/1]ip ad	
[r3-GigabitEthernet0/0/1]ip address 32.1.1.2 24
[r4]interface g0/0/0
[r4-GigabitEthernet0/0/0]ip ad	
[r4-GigabitEthernet0/0/0]ip address 34.1.1.2 24
[r4]interface g0/0/2
[r4-GigabitEthernet0/0/2]ip ad	
[r4-GigabitEthernet0/0/2]ip address 46.1.1.1 24

下一跳写法实现全网可达,并用display ip routing-table检验

[r1]ip route-static 23.1.1.0 24 12.1.1.2
[r1]ip route-static 34.1.1.0 24 12.1.1.2
[r1]ip route-static 46.1.1.0 24 12.1.1.2
[r1]ip route-static 32.1.1.0 24 12.1.1.2
[r1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 14       Routes : 14       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       12.1.1.0/24  Direct  0    0           D   12.1.1.1        GigabitEthernet
0/0/1
       12.1.1.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
     12.1.1.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
       23.1.1.0/24  Static  60   0          RD   12.1.1.2        GigabitEthernet
0/0/1
       32.1.1.0/24  Static  60   0          RD   12.1.1.2        GigabitEthernet
0/0/1
       34.1.1.0/24  Static  60   0          RD   12.1.1.2        GigabitEthernet
0/0/1
       46.1.1.0/24  Static  60   0          RD   12.1.1.2        GigabitEthernet
0/0/1
      127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0
      127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0
127.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
     172.16.1.0/24  Direct  0    0           D   172.16.1.1      GigabitEthernet
0/0/0
     172.16.1.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
   172.16.1.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
[r5]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 18       Routes : 18       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       12.1.1.0/24  Static  60   0          RD   46.1.1.1        GigabitEthernet
0/0/0
       23.1.1.0/24  Static  60   0          RD   46.1.1.1        GigabitEthernet
0/0/0
       32.1.1.0/24  Static  60   0          RD   46.1.1.1        GigabitEthernet
0/0/0
       34.1.1.0/24  Static  60   0          RD   46.1.1.1        GigabitEthernet
0/0/0
       46.1.1.0/24  Direct  0    0           D   46.1.1.2        GigabitEthernet
0/0/0
       46.1.1.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
     46.1.1.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
      127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0
      127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0
127.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

2.pc1和pc2获取指定ip地址

分别给pc1 pc2配置好指定地址后,在pc1,2上选dhcp应用,再在
命令行ipconfig进行检验

<Huawei>sy	
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]sy	
[Huawei]sysname dhcp
[dhcp]in	
[dhcp]info-center
[dhcp]interface g0/0/0
[dhcp-GigabitEthernet0/0/0]ip ad	
[dhcp-GigabitEthernet0/0/0]ip address 172.16.1.1 24
Nov 13 2022 23:28:06-08:00 dhcp %%01IFNET/4/LINK_STATE(l)[0]:The line protocol I
P on the interface GigabitEthernet0/0/0 has entered the UP state. 
[dhcp-GigabitEthernet0/0/0]qu	
[dhcp-GigabitEthernet0/0/0]quit 
[dhcp]dhcp en	
[dhcp]dhcp enable 
Info: The operation may take a few seconds. Please wait for a moment.done.
[dhcp]ip poo	
[dhcp]ip pool 1
Info: It's successful to create an IP address pool.
[dhcp-ip-pool-1]net	
[dhcp-ip-pool-1]netbios-type
[dhcp-ip-pool-1]network 172.16.1.0 m	
[dhcp-ip-pool-1]network 172.16.1.0 mask 24
[dhcp-ip-pool-1]ga	
[dhcp-ip-pool-1]gateway-list 172.16.1.1
[dhcp-ip-pool-1]dns	
[dhcp-ip-pool-1]dns-list 8.8.8.8 114.114.114.114
[dhcp-ip-pool-1]st	
[dhcp-ip-pool-1]static-bind ip	
[dhcp-ip-pool-1]static-bind ip-address 172.16.1.11 ma	
[dhcp-ip-pool-1]static-bind ip-address 172.16.1.11 mac-address 5489-9817-0CD5
[dhcp-ip-pool-1]st	
[dhcp-ip-pool-1]static-bind ip	
[dhcp-ip-pool-1]static-bind ip-address 172.16.1.13 ma	
[dhcp-ip-pool-1]static-bind ip-address 172.16.1.13 mac-address 5489-9877-178B
[dhcp-ip-pool-1]qui	
[dhcp-ip-pool-1]quit 
[dhcp]in	
[dhcp]info-center
[dhcp]interface g0/0/0
[dhcp-GigabitEthernet0/0/0]dhcp se	
[dhcp-GigabitEthernet0/0/0]dhcp select g	
[dhcp-GigabitEthernet0/0/0]dhcp select global 
[dhcp-GigabitEthernet0/0/0]
PC>ipconfig

Link local IPv6 address...........: fe80::5689:98ff:fe17:cd5
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 172.16.1.11
Subnet mask.......................: 255.255.255.0
Gateway...........................: 172.16.1.1
Physical address..................: 54-89-98-17-0C-D5
DNS server........................: 8.8.8.8
                                    114.114.114.114
PC>ipconfig

Link local IPv6 address...........: fe80::5689:98ff:fe77:178b
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 172.16.1.13
Subnet mask.......................: 255.255.255.0
Gateway...........................: 172.16.1.1
Physical address..................: 54-89-98-77-17-8B
DNS server........................: 8.8.8.8
                                    114.114.114.114

3.pc3和pc4不能获取250-254的地址

给pc3 pc4分配好地址后,用excluded-ip-address+不能获取的地址排除250-254,dhcp应用,再在
命令行ipconfig进行检验

[dhcp]dhcp en	
[dhcp]dhcp enable 
[dhcp]ip po	
[dhcp]ip policy-based-route
[dhcp]ip pool 1
[dhcp-ip-pool-1]excluded-ip-address 192.168.1.250 192.168.1.254
[dhcp-ip-pool-1]excluded-ip
[dhcp-ip-pool-1]qu	
[dhcp-ip-pool-1]quit 
[dhcp]in	
[dhcp]info-center 	
[dhcp]interface g0/0/1
[dhcp-GigabitEthernet0/0/1]dhcp se	
[dhcp-GigabitEthernet0/0/1]dhcp select g	
[dhcp-GigabitEthernet0/0/1]dhcp select global 

PC>ipconfig

Link local IPv6 address...........: fe80::5689:98ff:fe31:6527
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.1.248
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.1.1
Physical address..................: 54-89-98-31-65-27
DNS server........................: 8.8.8.8
                                    114.114.114.114
PC>ipconfig

Link local IPv6 address...........: fe80::5689:98ff:fe38:6474
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.1.249
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.1.1
Physical address..................: 54-89-98-38-64-74
DNS server........................: 8.8.8.8
                                    114.114.114.114

4.32.1.1.0/24为备份路径

浮动静态路由,值越小越优
[r2]ip r	
[r2]ip rd-filter
[r2]ip relay
[r2]ip route
[r2]ip route-static 34.1.1.0 24 23.1.1.2 pr	
[r2]ip route-static 34.1.1.0 24 23.1.1.2 preference 61
Info: Succeeded in modifying route.
[r2]dis	
[r2]display ip r	
[r2]display ip rd-filter
[r2]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 14       Routes : 14       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       12.1.1.0/24  Direct  0    0           D   12.1.1.2        GigabitEthernet
0/0/0
       12.1.1.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
     12.1.1.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
       23.1.1.0/24  Direct  0    0           D   23.1.1.1        GigabitEthernet
0/0/1
       23.1.1.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
     23.1.1.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
       32.1.1.0/24  Direct  0    0           D   32.1.1.1        GigabitEthernet
0/0/2
       32.1.1.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/2
     32.1.1.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/2
       34.1.1.0/24  Static  60   0          RD   32.1.1.2        GigabitEthernet
0/0/2
      127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0
      127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0
127.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

5.尽量减少路由条目pc1访问pc3456时使用汇总路由

​
[r5]ip r	
[r5]ip rd-filter
[r5]ip relay
[r5]ip route
[r5]ip route-static 192.168.0.0 22 192.168.1.2
[r5]dis	
[r5]display ip r	
[r5]display ip rd-filter
[r5]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 18       Routes : 18       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       12.1.1.0/24  Static  60   0          RD   46.1.1.1        GigabitEthernet
0/0/0
       23.1.1.0/24  Static  60   0          RD   46.1.1.1        GigabitEthernet
0/0/0
       32.1.1.0/24  Static  60   0          RD   46.1.1.1        GigabitEthernet
0/0/0
       34.1.1.0/24  Static  60   0          RD   46.1.1.1        GigabitEthernet
0/0/0
       46.1.1.0/24  Direct  0    0           D   46.1.1.2        GigabitEthernet
0/0/0
       46.1.1.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
     46.1.1.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
      127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0
      127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0
127.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
    192.168.0.0/22  Static  60   0          RD   192.168.1.2     GigabitEthernet
0/0/1
    192.168.1.0/24  Direct  0    0           D   192.168.1.1     GigabitEthernet
0/0/1
    192.168.1.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
  192.168.1.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
    192.168.2.0/24  Direct  0    0           D   192.168.2.1     GigabitEthernet
0/0/2
    192.168.2.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/2
  192.168.2.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/2
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

​
[r5]ip r	
[r5]ip rd-filter
[r5]ip relay
[r5]ip route
[r5]ip route-static 192.168.0.0 22 192.168.1.2
[r5]dis	
[r5]display ip r	
[r5]display ip rd-filter
[r5]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 18       Routes : 18       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       12.1.1.0/24  Static  60   0          RD   46.1.1.1        GigabitEthernet
0/0/0
       23.1.1.0/24  Static  60   0          RD   46.1.1.1        GigabitEthernet
0/0/0
       32.1.1.0/24  Static  60   0          RD   46.1.1.1        GigabitEthernet
0/0/0
       34.1.1.0/24  Static  60   0          RD   46.1.1.1        GigabitEthernet
0/0/0
       46.1.1.0/24  Direct  0    0           D   46.1.1.2        GigabitEthernet
0/0/0
       46.1.1.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
     46.1.1.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
      127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0
      127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0
127.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
    192.168.0.0/22  Static  60   0          RD   192.168.1.2     GigabitEthernet
0/0/1
    192.168.1.0/24  Direct  0    0           D   192.168.1.1     GigabitEthernet
0/0/1
    192.168.1.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
  192.168.1.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
    192.168.2.0/24  Direct  0    0           D   192.168.2.1     GigabitEthernet
0/0/2
    192.168.2.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/2
  192.168.2.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/2
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

### IntelliJ IDEA 中通义 AI 功能介绍 IntelliJ IDEA 提供了一系列强大的工具来增强开发体验,其中包括与通义 AI 相关的功能。这些功能可以帮助开发者更高效地编写代并提高生产力。 #### 安装通义插件 为了使用通义的相关特性,在 IntelliJ IDEA 中需要先安装对应的插件: 1. 打开 **Settings/Preferences** 对话框 (Ctrl+Alt+S 或 Cmd+, on macOS)。 2. 导航到 `Plugins` 页面[^1]。 3. 在 Marketplace 中搜索 "通义" 并点击安装按钮。 4. 完成安装后重启 IDE 使更改生效。 #### 配置通义服务 成功安装插件之后,还需要配置通义的服务连接信息以便正常使用其提供的各项能力: - 进入设置中的 `Tools | Qwen Coding Assistant` 菜单项[^2]。 - 填写 API Key 和其他必要的认证参数。 - 测试连接以确认配置无误。 #### 使用通义辅助编程 一旦完成上述准备工作,就可以利用通义来进行智能编支持了。具体操作如下所示: ##### 自动补全代片段 当输入部分语句时,IDE 将自动提示可能的后续逻辑,并允许一键插入完整的实现方案[^3]。 ```java // 输入 while 循环条件前半部分... while (!list.isEmpty()) { // 激活建议列表选择合适的循环体内容 } ``` ##### 解释现有代含义 选中某段复杂的表达式或函数调用,右键菜单里会有选项可以请求通义解析这段代的作用以及优化意见。 ##### 生产测试案例 对于已有的业务逻辑模块,借助于通义能够快速生成单元测试框架及初始断言集,减少手动构建的成本。 ```python def test_addition(): result = add(2, 3) assert result == 5, f"Expected 5 but got {result}" ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值