• 使用华为eNSP组网试验⑸-访问控制


      今天练习使用华为sNSP模拟网络设备上的访问控制,这样的操作我经常在华为的S7706、S5720、S5735或者H3C的S5500、S5130、S7706上进行,在网络设备上根据情况应用访问控制的策略是一个网管必须熟练的操作,只是在真机上操作一般比较谨慎,现在模拟器上试验就轻松了许多。

      先准备一个全网通的环境:

      上面是全网通的环境,验证:

      路由器Router1的静态路由:

    1. ip route-static 1.1.1.1 255.255.255.255 11.11.12.1
    2. ip route-static 3.3.3.3 255.255.255.255 11.11.11.2
    3. ip route-static 4.4.4.4 255.255.255.255 11.11.11.2
    4. ip route-static 5.5.5.5 255.255.255.255 11.11.11.2
    5. ip route-static 11.11.13.0 255.255.255.0 11.11.11.2
    6. ip route-static 11.11.14.0 255.255.255.0 11.11.11.2
    7. ip route-static 172.16.2.0 255.255.255.0 11.11.11.2
    8. ip route-static 172.16.11.0 255.255.255.0 11.11.11.2
    9. ip route-static 192.168.9.0 255.255.255.0 11.11.12.1
    10. ip route-static 192.168.19.0 255.255.255.0 11.11.12.1
    11. ip route-static 192.168.29.0 255.255.255.0 11.11.12.1

      路由器Router2的静态路由:

    1. ip route-static 1.1.1.1 255.255.255.255 11.11.11.1
    2. ip route-static 2.2.2.2 255.255.255.255 11.11.11.1
    3. ip route-static 4.4.4.4 255.255.255.255 11.11.13.1
    4. ip route-static 5.5.5.5 255.255.255.255 11.11.14.1
    5. ip route-static 11.11.12.0 255.255.255.0 11.11.11.1
    6. ip route-static 172.16.2.0 255.255.255.0 11.11.13.1
    7. ip route-static 172.16.11.0 255.255.255.0 11.11.14.1
    8. ip route-static 192.168.9.0 255.255.255.0 11.11.11.1
    9. ip route-static 192.168.19.0 255.255.255.0 11.11.11.1
    10. ip route-static 192.168.29.0 255.255.255.0 11.11.11.1

      一、基于MAC地址拒绝网络设备上网

      这个方式可以通过访问控制列表限制IP、将这个IP放入黑洞、禁用接口等来实现,下面通过流策略来完成操作。

      假如限制IP地址为192.168.9.3的计算机,我们可以得到它的Mac地址为54-89-98-B4-4C-48。

      ①在交换机SW1上创建访问控制列表4019;

    1. acl number 4019
    2. rule 10 deny source-mac 5489-98b4-4c48

      ②在交换机SW1上创建流分类tc1,并且匹配访问控制列表4019;

    1. traffic classifier tc1 operator and
    2. if-match acl 4019

      ③在交换机SW1上创建流行为tb1,并且设置为拒绝;

    1. traffic behavior tb1
    2. deny

      ④在交换机SW1上创建流策略tp1并且绑定流分类tc1和流行为tb1;

    1. traffic policy tp1
    2. classifier tc1 behavior tb1

      ⑤在交换机SW1的端口GigabitEthernet0/0/0的入口处绑定流策略tp1。

    1. interface GigabitEthernet0/0/2
    2. port link-type access
    3. port default vlan 10
    4. traffic-policy tp1 inbound

      简单的写,也可以直接在端口上绑定访问控制列表:

    1. interface GigabitEthernet0/0/2
    2. port link-type access
    3. port default vlan 10
    4. traffic-filter inbound acl 4019

      也可以达到限制该计算机的上网,效果是一样的。

      二、限制访问目的设备

      假定172.16.2.5是服务器地址,拒绝192.168.9.0网段访问,但是允许192.168.19.0和192.168.29.0的网段访问。

      ①在交换机SW2上创建访问控制列表3019;

    1. acl number 3019
    2. rule 10 deny ip source 192.168.9.0 0.0.0.255 destination 172.16.2.5 0

      ②在交换机SW2上创建流分类tc1,并且匹配访问控制列表3019;

    1. traffic classifier tc1 operator and
    2. if-match acl 3019

      ③在交换机SW2上创建流行为tb1,并且设置为允许;

    1. traffic behavior tb1
    2. permit

      ④在交换机SW2上创建流策略tp1并且绑定流分类tc1和流行为tb1;

    1. traffic policy tp1
    2. classifier tc1 behavior tb1

      ⑤在交换机SW2的端口GigabitEthernet0/0/1的入口处绑定流策略tp1。

    1. interface GigabitEthernet0/0/1
    2. port link-type access
    3. port default vlan 300
    4. traffic-policy tp1 inbound

      上面的操作等价于:

    1. interface GigabitEthernet0/0/1
    2. port link-type access
    3. port default vlan 300
    4. traffic-filter inbound acl 3019

      但是显然流策略可以实现的目的更广泛,虽然ACL可以实现的目的也很多。
      上面的写法可以变化,访问控制列表为允许,那么流行为就是禁止,效果也是一样的。

      三、限制上网速度

      假定现在要限制IP地址为192.168.9.0的网段的网速,可以通过下面的设置来完成。

      ①在交换机SW1上创建访问控制列表3019;

    1. acl number 3019
    2. rule 10 permit ip source 192.168.9.0 0.0.0.255

      ②在交换机SW1上创建流分类tc1,并且匹配访问控制列表3019;

    1. traffic classifier tc1 operator and
    2. if-match acl 3019

      ③在交换机SW1上创建流行为tb1,并且设定网速的限制;

    1. traffic behavior tb1
    2. car cir 1024 pir 4096 cbs 128000 pbs 512000 green pass yellow pass red discard
    3. statistic enable

      限定网速为1M,最大为4M。

      ④在交换机SW1上创建流策略tp1并且绑定流分类tc1和流行为tb1;

    1. traffic policy tp1
    2. classifier tc1 behavior tb1

      ⑤在交换机SW1的端口GigabitEthernet0/0/0的入口处绑定流策略tp1。

    1. interface GigabitEthernet0/0/3
    2. port link-type access
    3. port default vlan 20
    4. traffic-policy tp1 inbound

      四、策略路由

      可以根据不同的IP决定数据流走不同的路由,有一些应用对不同的路由选择有需求,这个时候可以使用流策略来完成。

      实验图:

      上面的图示中,192.168.9.3最终访问172.16.1.2,192.168.19.3访问172.16.2.2,从而通过策略路由来达到隔离访问的目的,也可以限定网速,比如一条线路为高速,一条线路为一般速度,可以根据源IP来决定是否走高速。

      路由器R0:

    1. [V200R003C00]
    2. #
    3. sysname Router0
    4. #
    5. snmp-agent local-engineid 800007DB03000000000000
    6. snmp-agent
    7. #
    8. clock timezone China-Standard-Time minus 08:00:00
    9. #
    10. portal local-server load portalpage.zip
    11. #
    12. drop illegal-mac alarm
    13. #
    14. undo info-center enable
    15. #
    16. set cpu-usage threshold 80 restore 75
    17. #
    18. acl number 3010
    19. rule 10 permit ip source 192.168.9.0 0.0.0.255
    20. acl number 3020
    21. rule 10 permit ip source 192.168.19.0 0.0.0.255
    22. #
    23. traffic classifier tc20 operator or
    24. if-match acl 3020
    25. traffic classifier tc10 operator or
    26. if-match acl 3010
    27. #
    28. traffic behavior tb20
    29. redirect ip-nexthop 11.11.13.2
    30. traffic behavior tb10
    31. redirect ip-nexthop 11.11.11.2
    32. #
    33. traffic policy tp10
    34. classifier tc10 behavior tb10
    35. classifier tc20 behavior tb20
    36. #
    37. aaa
    38. authentication-scheme default
    39. authorization-scheme default
    40. accounting-scheme default
    41. domain default
    42. domain default_admin
    43. local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
    44. local-user admin service-type http
    45. #
    46. firewall zone Local
    47. priority 15
    48. #
    49. interface GigabitEthernet0/0/0
    50. ip address 11.11.11.1 255.255.255.252
    51. #
    52. interface GigabitEthernet0/0/1
    53. ip address 11.11.13.1 255.255.255.252
    54. #
    55. interface GigabitEthernet0/0/2
    56. ip address 11.11.9.2 255.255.255.252
    57. traffic-policy tp10 inbound
    58. #
    59. interface NULL0
    60. #
    61. ip route-static 192.168.9.0 255.255.255.0 11.11.9.1
    62. ip route-static 192.168.19.0 255.255.255.0 11.11.9.1
    63. #
    64. user-interface con 0
    65. authentication-mode password
    66. user-interface vty 0 4
    67. user-interface vty 16 20
    68. #
    69. wlan ac
    70. #
    71. return

      路由器R1:

    1. [V200R003C00]
    2. #
    3. sysname Router1
    4. #
    5. snmp-agent local-engineid 800007DB03000000000000
    6. snmp-agent
    7. #
    8. clock timezone China-Standard-Time minus 08:00:00
    9. #
    10. portal local-server load flash:/portalpage.zip
    11. #
    12. drop illegal-mac alarm
    13. #
    14. undo info-center enable
    15. #
    16. wlan ac-global carrier id other ac id 0
    17. #
    18. set cpu-usage threshold 80 restore 75
    19. #
    20. aaa
    21. authentication-scheme default
    22. authorization-scheme default
    23. accounting-scheme default
    24. domain default
    25. domain default_admin
    26. local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
    27. local-user admin service-type http
    28. #
    29. firewall zone Local
    30. priority 15
    31. #
    32. interface GigabitEthernet0/0/0
    33. ip address 11.11.11.2 255.255.255.252
    34. arp-proxy enable
    35. #
    36. interface GigabitEthernet0/0/1
    37. ip address 172.16.1.1 255.255.255.0
    38. arp-proxy enable
    39. #
    40. interface GigabitEthernet0/0/2
    41. #
    42. interface NULL0
    43. #
    44. interface LoopBack0
    45. ip address 2.2.2.2 255.255.255.255
    46. #
    47. ospf 1 router-id 2.2.2.2
    48. import-route static
    49. area 0.0.0.0
    50. network 2.2.2.2 0.0.0.0
    51. network 11.11.11.2 0.0.0.0
    52. network 11.11.12.2 0.0.0.0
    53. #
    54. ip route-static 192.168.9.0 255.255.255.0 11.11.11.1
    55. ip route-static 192.168.19.0 255.255.255.0 11.11.11.1
    56. #
    57. user-interface con 0
    58. authentication-mode password
    59. user-interface vty 0 4
    60. user-interface vty 16 20
    61. #
    62. wlan ac
    63. #
    64. return

      路由器R2:

    1. [V200R003C00]
    2. #
    3. snmp-agent local-engineid 800007DB03000000000000
    4. snmp-agent
    5. #
    6. clock timezone China-Standard-Time minus 08:00:00
    7. #
    8. portal local-server load portalpage.zip
    9. #
    10. drop illegal-mac alarm
    11. #
    12. undo info-center enable
    13. #
    14. set cpu-usage threshold 80 restore 75
    15. #
    16. aaa
    17. authentication-scheme default
    18. authorization-scheme default
    19. accounting-scheme default
    20. domain default
    21. domain default_admin
    22. local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
    23. local-user admin service-type http
    24. #
    25. firewall zone Local
    26. priority 15
    27. #
    28. interface GigabitEthernet0/0/0
    29. ip address 11.11.13.2 255.255.255.252
    30. #
    31. interface GigabitEthernet0/0/1
    32. ip address 172.16.2.1 255.255.255.0
    33. #
    34. interface GigabitEthernet0/0/2
    35. #
    36. interface NULL0
    37. #
    38. interface LoopBack0
    39. ip address 3.3.3.3 255.255.255.255
    40. #
    41. ospf 1 router-id 3.3.3.3
    42. import-route static
    43. area 0.0.0.0
    44. network 3.3.3.3 0.0.0.0
    45. network 11.11.13.2 0.0.0.0
    46. network 11.11.14.2 0.0.0.0
    47. #
    48. ip route-static 192.168.9.0 255.255.255.0 11.11.13.1
    49. ip route-static 192.168.19.0 255.255.255.0 11.11.13.1
    50. #
    51. user-interface con 0
    52. authentication-mode password
    53. user-interface vty 0 4
    54. user-interface vty 16 20
    55. #
    56. wlan ac
    57. #
    58. return

      通过流策略还可以做很多其他的事情,比如限制协议、限制私密访问、限制端口、隔离特殊应用等等,这些在特殊条件下可以根据需要可以使用流策略来完成。

  • 相关阅读:
    mannose-CHO|甘露糖-醛基|甘露糖-聚乙二醇-醛基|醛基-PEG-甘露糖
    RustDay03——记录刷完Rust100题
    L57.linux命令每日一练 -- 第九章 Linux进程管理命令 -- ps和pstree
    深入理解Linux I/O系统
    大数据之数据倾斜
    基于枚举实现的观察者模式
    springboot的可执行fatjar打包部署后,在运行时加载外部jar包;
    网课答案公众号搭建过程详解
    【深度学习实验】数据可视化
    33、Java 异常掌握这些就够了(图解 Java 中的异常)
  • 原文地址:https://blog.csdn.net/dawn0718/article/details/133563561