如何不在 Cisco 路由器上路由

网络工程 思科 路由 路由器 VLAN 界面
2021-07-03 02:33:37

所以我们有一个路由器,带交换卡接口,8个端口

假设我有 4 个 VLAN(A、B、C、D),每个 VLAN 有 2 个交换机端口。

每个VLAN(即所有端口)都可以互相通信,因为自然都是连接在一个路由器上的……

但是说我只想要A&C,和B&D,能够互相看到和交流,这要怎么做?

我在想可能的 NAT,但我确定有一些行业标准的方法来做到这一点?

3个回答

虽然 Ron 和 Ron 的回答实际上启用了路由但阻止了流量,但他们的建议仍然将两个主机组打包到同一个路由实例中。

还有另一种思考方式:

a) VRF-lite

这基本上在一个盒子中创建了两个几乎完全(好吧,它们共享硬件资源......)分离的路由实例。

如果两个 VRF 共享相同的(单一)互联网访问和“上游”接口,事情可能会变得有点棘手(但并非不可能)。但你实际上并没有问这个。可能需要一些许可才能配置 VRF-lite,具体取决于型号。

此外,如果您仍然希望允许从一个 VRF 到另一个 VRF 的一些流量,事情往往会变得有点混乱(路由泄漏、耳环电缆等等),这将使我们刚刚建立的良好的 VRF 分离黯然失色目的。在这种情况下,不要采用 VRF-lite 方法。

以下是 VRF-lite 的操作:

! 
! Define two VRF instances
!
vrf definition VRF_AandC
 address-family ipv4
 exit-address-family

vrf definition VRF_BandC
 address-family ipv4
 exit-address-family

!
! the L2 VLANs
! 
vlan11
 name VLAN-A
vlan 12
 name VLAN-B
vlan 13
 name VLAN-C
vlan 14
 name VLAN-D

!
! map the switch ports to their VLAN
!
! assuming the interfaces of the switch modules are named GigabitEthernet1-8
!

interface GigabitEthernet 1
 descripton * Access Port into VLAN-A *
 switchport mode access
 switchport access vlan 11
 spanning-tree portfast
interface GigabitEthernet 2
 descripton * Access Port into VLAN-A *
 switchport mode access
 switchport access vlan 11
 spanning-tree portfast
!
interface GigabitEthernet 3
 descripton * Access Port into VLAN-B *
 switchport mode access
 switchport access vlan 12
 spanning-tree portfast
interface GigabitEthernet 4
 descripton * Access Port into VLAN-B*
 switchport mode access
 switchport access vlan 12
 spanning-tree portfast
!
interface GigabitEthernet 5
 descripton * Access Port into VLAN-C *
 switchport mode access
 switchport access vlan 13
 spanning-tree portfast
interface GigabitEthernet 6
 descripton * Access Port into VLAN-C *
 switchport mode access
 switchport access vlan 13
 spanning-tree portfast
!
interface GigabitEthernet 7
 descripton * Access Port into VLAN-D *
 switchport mode access
 switchport access vlan 14
 spanning-tree portfast
interface GigabitEthernet 8
 descripton * Access Port into VLAN-D *
 switchport mode access
 switchport access vlan 14
 spanning-tree portfast


!
! the L3 interfaces into the VLANs
! are attached to their respective VRF
!
interface vlan 11
 vrf forwarding VRF_AandC
 ip address <ip.ip.AAA.ip> <mask.mask.mask.mask>

interface vlan 12
 vrf forwarding VRF_BandD
 ip address <ip.ip.BBB.ip> <mask.mask.mask.mask>

interface vlan 13
 vrf forwarding VRF_AandC
 ip address <ip.ip.CCC.ip> <mask.mask.mask.mask>

interface vlan 14
 vrf forwarding VRF_AandC
 ip address <ip.ip.DDD.ip> <mask.mask.mask.mask>

b) 基于区域的防火墙

本质上与 Rons 提出的相同,但有一种高级方法,其中包含更多文本和配置项。这可能需要您的路由器上的 SEC 许可证。

ZBFW的关键点是:

  • 接口属于区域
  • 接口本身没有输入/输出 ACL
  • 同一区域的接口没有限制
  • “分区”和“非分区”接口之间没有通信
  • stateful:过滤定义(类映射的 ACL)只需要覆盖发起者到响应者的方向。
  • 应用感知:SIP、FTP、常见的可疑对象都可以检查,端口动态开放
  • 过滤和协议检查发生在 Src 和 Dst 区域,而不是接口。

我做了一些假设,根据你目前告诉我们的情况。我采取了一些自由,这实际上可能超出了您的问题的范围。我认为您会发现实际上不适用于您的特定情况的部分。

  • 有一个具有单个公共 IP 地址的“外部”接口/子网(“看哪,互联网!”)。
  • 有四个“内部”子网/VLAN A、B、C 和 D
  • 子网 A 和 C 应该能够无限制地通信
  • 子网 A 和 C 应该有一些通用的互联网访问和一些端口转发到 A 和 C 中的主机
  • 子网 B 和 D 应该能够无限制地通信
  • 子网 B 和 D 应该有一些通用的互联网访问和一些端口转发到 B 和 D 中的主机
  • 不得允许从(A 或 C)到/从(B 或 D)的通信。

配置项现在的顺序与它们应该应用的顺序不同。如果您按此顺序粘贴它们,IOS 会吠叫。我故意这样做,是为了让 ZBFW 的配置层更清晰一点。(在现实生活中,自下而上执行:ACL、类映射、策略映射、区域、区域对、接口到区域)。

请注意:其中一半来自现实生活中的设置,一半是徒手创作的。请指出任何拼写错误或项目拼写错误的配置项目名称。

让我们从定义区域开始一个区域可以跨越给定路由器的多个第 3 层接口,但一个接口可能只属于一个区域的一部分。

zone security Z-INTERNET
 description * the outside world *
zone security Z-AC
 description * VLANs/Subnets A and C *
zone security Z-BD
 description * VLANs/Subnets A and C *

需要接口分配给区域在现实世界中,你会在最后这样做 - 否则你会影响已经流经路由器的流量。NAT内/外位已经在那里了。

 interface vlan 11
  ip nat inside
  zone-member security Z-AC

 interface vlan 12
  ip nat inside 
  zone-member security Z-BD

  interface vlan 13
  ip nat inside
  zone-member security Z-AC

 interface vlan 14
  ip nat inside 
  zone-member security Z-BD

 interface <outsideIF>
  ip address <some.possibly.public.ip> <mask>
  ip nat outside
  zone-member security Z-INTERNET

然后,我们需要一些zone-pairs,每个zone-pairs都有自己的服务策略。区域对是单向的如果您有在给定方向上启动的流量模式,则只需要一个。注意 AC-to-BD 和 BD-to-AC 没有区域对定义。

zone-pair security AC-TO-INTERNET source Z-AC destination Z-INTERNET
 service-policy type inspect PMAP-AC-TO-INTERNET-TRAFFIC

zone-pair security INTERNET-TO-AC source Z-INTERNET destination Z-AC
 service-policy type inspect PMAP-INTERNET-TO-AC-TRAFFIC

zone-pair security BD-TO-INTERNET source Z-BD destination Z-INTERNET
 service-policy type inspect PMAP-BD-TO-INTERNET-TRAFFIC

zone-pair security INTERNET-TO-BD source Z-INTERNET destination Z-BD
 service-policy type inspect PMAP-INTERNET-TO-BD-TRAFFIC

现在我们需要多个带有policy-map,class-map和 的MQC 构造access-list,因为我们都喜欢或讨厌 QoS。您会注意到我可能有点过头了,因为每个区域对都有一个几乎完整的策略映射/类映射/访问列表元组,几乎没有重复使用公共项目。这就是我的想法 - 忍不住。

“类型检查”策略映射定义了不同类别的流量会发生什么:通过检查丢弃每个区域对都有自己的策略映射(见上文)。

policy-map type inspect PMAP-INTERNET-TO-AC-TRAFFIC
 class type inspect CMAP-COMMON-TRACE-TRAFFIC
  pass
 class type inspect CMAP-INTERNET-TO-AC-TRAFFIC
  inspect
 class class-default
  drop log

policy-map type inspect PMAP-INTERNET-TO-BD-TRAFFIC
 class type inspect CMAP-COMMON-TRACE-TRAFFIC
  pass
 class type inspect CMAP-INTERNET-TO-BD-TRAFFIC
  inspect
 class class-default
  drop log

 policy-map type inspect PMAP-AC-TO-INTERNET-TRAFFIC
 class type inspect CMAP-COMMON-TRACE-TRAFFIC
  pass
 class type inspect CMAP-AC-TO-INTERNET-STANDARD-TRAFFIC
  inspect
 class class-default
  drop log

policy-map type inspect PMAP-BD-TO-INTERNET-TRAFFIC
 class type inspect CMAP-COMMON-TRACE-TRAFFIC
  pass
 class type inspect CMAP-BD-TO-INTERNET-STANDARD-TRAFFIC
  inspect
 class class-default
  drop log

当然,我们必须定义我们考虑的流量类别。这是通过“类型检查”的类映射和一些 ACL 完成的(匹配“协议”也有效)。

首先,我们将重用一些项目(注意配置项目名称中的“COMMON”)

class-map type inspect match-any CMAP-COMMON-TRACE-TRAFFIC
  match access-group name ACLv4-COMMON-ICMP-AND-TRACE

ip access-list extended ACLv4-COMMON-ICMP-AND-TRACE
 permit icmp any any time-exceeded
 permit icmp any any ttl-exceeded
 permit icmp any any unreachable
 permit icmp any any administratively-prohibited
 permit icmp any any packet-too-big
 permit icmp any any echo
 permit icmp any any echo-reply

ip access-list extended ACLv4-COMMON-STANDARD-TRAFFIC
 ! well in this example, we're allowing almost anything out 
 permit tcp any any
 permit udp any any

然后,每个区域对策略映射获取其特定的类映射同样,您会注意到没有定义流量的类映射,允许从 AC 到 BD,反之亦然。

往/返 AC 的互联网:

class-map type inspect match-any CMAP-AC-TO-INTERNET-STANDARD-TRAFFIC
 match access-group name ACLv4-COMMON-STANDARD-TRAFFIC

class-map type inspect match-any CMAP-INTERNET-TO-AC-TRAFFIC
 match access-group name ACLv4-INTERNET-TO-AC-TRAFFIC

ip access-list extended ACLv4-INTERNET-TO-AC-TRAFFIC
 ! note: destination IP and port as seen AFTER DstNAT and port translation
 permit tcp any host <ip.ip.AAA.ip> eq <port>
 permit tcp any host <ip.ip.AAA.ip> eq <port>
 permit udp any host <ip.ip.CCC.ip> eq <port>

互联网往/返 BD:

class-map type inspect match-any CMAP-INTERNET-TO-BD-TRAFFIC
 match access-group name ACLv4-INTERNET-TO-BD-TRAFFIC

ip access-list extended ACLv4-INTERNET-TO-BD-TRAFFIC
 ! note: destination IP and port as seen AFTER DstNAT and port translation
 permit tcp any host <ip.ip.BBB.ip> eq <port>
 permit tcp any host <ip.ip.DDD.ip> eq <port>
 permit udp any host <ip.ip.DDD.ip> eq <port>

class-map type inspect match-any CMAP-BD-TO-INTERNET-STANDARD-TRAFFIC
 match access-group name ACLv4-COMMON-STANDARD-TRAFFIC

ZBFW 就这么多。有些项目需要与给定的 NAT/portfowarding 设置保持协调。

这是NATty 要做的事情,外部接口的 NAT 过载,以及一些端口转发。

ip access-list extended ACLv4-NAT-TO-INTERNET
 permit ip ip.ip.AAA.0 0.0.0.<wildcard bits>
 permit ip ip.ip.BBB.0 0.0.0.<wildcard bits>
 permit ip ip.ip.CCC.0 0.0.0.<wildcard bits>
 permit ip ip.ip.DDD.0 0.0.0.<wildcard bits>

ip nat inside source list ACLv4-NAT-TO-INTERNET interface <outsideIF> overload 
ip nat inside source static tcp <ip.ip.AAA.ip> <dstPortOnInside> interface <outsideIF> <dstPortOnOutside>
ip nat inside source static tcp <ip.ip.AAA.ip> <dstPortOnInside> interface <outsideIF> <dstPortOnOutside>
ip nat inside source static udp <ip.ip.CCC.ip> <dstPortOnInside> interface <outsideIF> <dstPortOnOutside>
ip nat inside source static tcp <ip.ip.BBB.ip> <dstPortOnInside> interface <outsideIF> <dstPortOnOutside>
ip nat inside source static tcp <ip.ip.DDD.ip> <dstPortOnInside> interface <outsideIF> <dstPortOnOutside>
ip nat inside source static udp <ip.ip.DDD.ip> <dstPortOnInside> interface <outsideIF> <dstPortOnOutside>

添加在:

在您的评论中,您提到了“SBC” - 就像在Session Border Controller 中一样,我想?如果流量/服务要在路由器本身上终止,这可能需要引入“SELF”区域。我无能为力 - 没有使用过它。一个资源:https : //community.cisco.com/t5/security-documents/zbfw-self-zone-integration/ta-p/3154572

自我区:

是包含所有路由器接口 IP 地址的 FW 区域(即使对于未连接到任何特定区域的接口)。

您必须将 self-zone 视为路由器本身,因此当我们配置包含 Self-zone 的策略时,与以下相关:

 -Traffic to the router

 -Traffic from the router

所以当有人问以下问题时

 What Traffic Should I Consider When I Deal With The Self-Zone?

      You should answer:

           -Managment plane traffic (SSH,Telnet,etc)

           -Control plane traffic(Routing Protocols)

您可以简单地创建访问列表来限制流量,并将这些访问列表放在 VLAN 接口上。

例如10.11.12.0/2410.11.13.0/24可以创建用于阻止流量的 ACL并将其放置在10.11.12.0网络的 VLAN 接口上

ip access-list 12 deny 10.11.13.0 0.0.0.255
ip access-list 12 permit any
!
interface VLAN 12
 ip access-group 12 in
!

方向(inout)是从路由器的角度来看的,而不是网络的角度。

您还可以创建一个 ACL 以放置在10.11.13.0网络的 VLAN 上

ip access-list 13 deny 10.11.12.0 0.0.0.255
ip access-list 13 permit any
!
interface VLAN 13
 ip access-group 13 out
!

您好,欢迎来到网络工程!我们希望您能成为这个社区的贡献者。

最简单的方法是使用访问列表。它们本质上是可以阻止特定源地址或目标地址的过滤器。

您可以创建一个访问列表并将其应用于仅允许流向 B 的流量并阻止流向 C 和 D 的流量的 Vlan A。