网络工程师网络配置经典例题(九)--路由策略

目录

组网需求

配置思路

操作步骤

配置各VLANIF接口的IP地址

配置OSPF基本功能

在SwitchA配置5条静态路由,并在将这些静态路由引入到OSPF协议中

配置路由发布策略

配置路由接收策略


组网需求

如图所示,运行OSPF协议的网络中,SwitchA从Internet网络接收路由,并为OSPF网络提供了Internet路由。用户希望OSPF网络中只能访问172.16.17.0/24、172.16.18.0/24和172.16.19.0/24三个网段的网络,其中SwitchC连接的网络只能访问172.16.18.0/24网段的网络。

配置思路

采用如下的思路配置对路由进行过滤:

  1. 在SwitchA上配置路由策略,在路由发布时运用路由策略,使SwitchA仅提供路由172.16.17.0/24、172.16.18.0/24、172.16.19.0/24给SwitchB,实现OSPF网络中只能访问172.16.17.0/24、172.16.18.0/24和172.16.19.0/24三个网段的网络。

  2. 在SwitchC上配置路由策略,在路由引入时运用路由策略,使SwitchC仅接收路由172.16.18.0/24,实现SwitchC连接的网络只能访问172.16.18.0/24网段的网络。

操作步骤

  1. 配置各接口所属的VLAN

    # 配置SwitchA。SwitchB和SwitchC的配置与SwitchA类似。

    <HUAWEI> system-view
    [HUAWEI] sysname SwitchA
    [SwitchA] vlan batch 10
    [SwitchA] interface gigabitethernet 0/0/1
    [SwitchA-GigabitEthernet0/0/1] port link-type trunk
    [SwitchA-GigabitEthernet0/0/1] port trunk allow-pass vlan 10
    [SwitchA-GigabitEthernet0/0/1] quit
    

  2. 配置各VLANIF接口的IP地址

    # 配置SwitchA。SwitchB和SwitchC的配置与SwitchA类似。

    [SwitchA] interface vlanif 10
    [SwitchA-Vlanif10] ip address 192.168.1.1 24
    [SwitchA-Vlanif10] quit

  3. 配置OSPF基本功能

    # SwitchA的配置。

    [SwitchA] ospf
    [SwitchA-ospf-1] area 0
    [SwitchA-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255
    [SwitchA-ospf-1-area-0.0.0.0] quit
    [SwitchA-ospf-1] quit

    # SwitchB的配置。

    [SwitchB] ospf
    [SwitchB-ospf-1] area 0
    [SwitchB-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255
    [SwitchB-ospf-1-area-0.0.0.0] network 192.168.2.0 0.0.0.255
    [SwitchB-ospf-1-area-0.0.0.0] quit
    [SwitchB-ospf-1] quit

    # SwitchC的配置。

    [SwitchC] ospf
    [SwitchC-ospf-1] area 0
    [SwitchC-ospf-1-area-0.0.0.0] network 192.168.2.0 0.0.0.255
    [SwitchC-ospf-1-area-0.0.0.0] quit
    [SwitchC-ospf-1] quit

  4. 在SwitchA配置5条静态路由,并在将这些静态路由引入到OSPF协议中

    [SwitchA] ip route-static 172.16.16.0 24 NULL 0
    [SwitchA] ip route-static 172.16.17.0 24 NULL 0
    [SwitchA] ip route-static 172.16.18.0 24 NULL 0
    [SwitchA] ip route-static 172.16.19.0 24 NULL 0
    [SwitchA] ip route-static 172.16.20.0 24 NULL 0
    [SwitchA] ospf
    [SwitchA-ospf-1] import-route static
    [SwitchA-ospf-1] quit

    # 在SwitchB查看IP路由表,可以看到OSPF引入的5条静态路由。

    [SwitchB] display ip routing-table
    Route Flags: R - relay, D - download to fib, T - to vpn-instance
    ------------------------------------------------------------------------------
    Routing Tables: Public
             Destinations : 11       Routes : 11
    
     Destination/Mask    Proto  Pre  Cost     Flags NextHop         Interface 
    
          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
        172.16.16.0/24   O_ASE  150  1           D  192.168.1.1     Vlanif10
        172.16.17.0/24   O_ASE  150  1           D  192.168.1.1     Vlanif10
        172.16.18.0/24   O_ASE  150  1           D  192.168.1.1     Vlanif10
        172.16.19.0/24   O_ASE  150  1           D  192.168.1.1     Vlanif10
        172.16.20.0/24   O_ASE  150  1           D  192.168.1.1     Vlanif10
        192.168.1.0/24   Direct 0    0           D  192.168.1.2     Vlanif10
        192.168.1.2/32   Direct 0    0           D  127.0.0.1       Vlanif10
        192.168.2.0/24   Direct 0    0           D  192.168.2.1     Vlanif20
        192.168.2.1/32   Direct 0    0           D  127.0.0.1       Vlanif20
    

  5. 配置路由发布策略

    # 在SwitchA配置地址前缀列表a2b。

    [SwitchA] ip ip-prefix a2b index 10 permit 172.16.17.0 24
    [SwitchA] ip ip-prefix a2b index 20 permit 172.16.18.0 24
    [SwitchA] ip ip-prefix a2b index 30 permit 172.16.19.0 24

    # 在SwitchA配置发布策略,引用地址前缀列表a2b进行过滤。

    [SwitchA] ospf
    [SwitchA-ospf-1] filter-policy ip-prefix a2b export static

    # 在SwitchB查看IP路由表,可以看到SwitchB仅接收到列表a2b中定义的3条路由。

    [SwitchB] display ip routing-table
    Route Flags: R - relay, D - download to fib, T - to vpn-instance
    ------------------------------------------------------------------------------
    Routing Tables: Public
             Destinations : 9        Routes : 9
     
    Destination/Mask    Proto  Pre  Cost     Flags NextHop         Interface
     
          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
        172.16.17.0/24  O_ASE  150  1           D  192.168.1.1     Vlanif10
        172.16.18.0/24  O_ASE  150  1           D  192.168.1.1     Vlanif10
        172.16.19.0/24  O_ASE  150  1           D  192.168.1.1     Vlanif10
        192.168.1.0/24  Direct 0    0           D  192.168.1.2     Vlanif10
        192.168.1.2/32  Direct 0    0           D  127.0.0.1       Vlanif10
        192.168.2.0/24  Direct 0    0           D  192.168.2.1     Vlanif20
        192.168.2.1/32  Direct 0    0           D  127.0.0.1       Vlanif20
    

  6. 配置路由接收策略

    # 在SwitchC配置地址前缀列表in。

    [SwitchC] ip ip-prefix in index 10 permit 172.16.18.0 24

    # 在SwitchC配置接收策略,引用地址前缀列表in进行过滤。

    [SwitchC] ospf
    [SwitchC-ospf-1] filter-policy ip-prefix in import
    [SwitchC-ospf-1] quit

    # 查看SwitchC的IP路由表,可以看到SwitchC的IP路由表中,仅接收了列表in定义的1条路由。

    [SwitchC] display ip routing-table
    Route Flags: R - relay, D - download to fib, T - to vpn-instance
    ------------------------------------------------------------------------------
    Routing Tables: Public
             Destinations : 5        Routes : 5
     
    Destination/Mask    Proto  Pre  Cost     Flags NextHop         Interface
     
          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
        172.16.18.0/24   O_ASE  150  1           D  192.168.2.1     Vlanif20
        192.168.2.0/24   Direct 0    0           D  192.168.2.2     Vlanif20
        192.168.2.2/32   Direct 0    0           D  127.0.0.1       Vlanif20

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
本实验旨在让网工学习基本的VLAN配置,包括VLAN的创建、端口的划分以及VLAN的通信等。 实验环境: - 三台交换机 - 一台主机 实验步骤: 1. 为交换机设定IP地址,使其能够互相通信。设定方法可参考以下命令: ``` Switch(config)#interface vlan 1 Switch(config-if)#ip address 192.168.1.1 255.255.255.0 ``` 2. 创建VLAN。创建VLAN需要使用以下命令: ``` Switch(config)#vlan 10 Switch(config-vlan)#name vlan10 ``` 3. 划分端口。将端口划分到对应的VLAN中,使用以下命令: ``` Switch(config)#interface fastethernet 0/1 Switch(config-if)#switchport mode access Switch(config-if)#switchport access vlan 10 ``` 4. 验证VLAN的配置是否正确。可以使用以下命令进行验证: ``` Switch#show vlan ``` 5. 配置VLAN间的通信。需要将不同VLAN的端口连通,使用以下命令: ``` Switch(config)#interface fastethernet 0/1 Switch(config-if)#switchport mode trunk ``` 6. 验证VLAN间的通信是否正确。可以使用以下命令进行验证: ``` Switch#show interfaces trunk ``` 7. 配置主机的IP地址,使其能够与交换机通信。可以使用以下命令进行配置: ``` ip address 192.168.1.2 255.255.255.0 ``` 8. 验证主机与交换机的通信是否正确。可以使用以下命令进行验证: ``` ping 192.168.1.1 ``` 以上就是基本的VLAN配置实验。通过实验,网工们可以更好地理解和掌握VLAN的概念和配置方法,为日后的网络工作打下基础。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值