AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 773765
Accepted
parsecpython
parsecpython
Asked: 2016-04-29 20:36:44 +0800 CST2016-04-29 20:36:44 +0800 CST 2016-04-29 20:36:44 +0800 CST

这是将路由映射用于 intervlan 路由的正确方法吗?

  • 772

网络地图截图

网络非常简单。用于 nat/WAN 访问的单棒路由器,用于 intervlan 路由的第 3 层交换机。

路由器:

ip nat inside source list nated-nets interface FastEthernet0/0 overload
ip access-list extended nated-nets
 permit ip 192.168.10.0 0.0.0.255 any
 permit ip 192.168.11.0 0.0.0.255 any
 permit ip 192.168.12.0 0.0.0.255 any

interface FastEthernet0/0
 description [f0/0][ISP]
 ip address dhcp
 no ip redirects
 no ip unreachables
 no ip proxy-arp
 ip nat outside
 ip virtual-reassembly in
 duplex auto
 speed auto

interface FastEthernet0/1.10
 description [f0/1.10][vlan10]
 encapsulation dot1Q 10
 ip address 192.168.10.254 255.255.255.0
 no ip redirects
 no ip unreachables
 no ip proxy-arp
 ip nat inside
 ip virtual-reassembly in

interface FastEthernet0/1.11
 description [f0/1.11][vlan11]
 encapsulation dot1Q 11
 ip address 192.168.11.254 255.255.255.0
 no ip redirects
 no ip unreachables
 no ip proxy-arp
 ip nat inside
 ip virtual-reassembly in

interface FastEthernet0/1.12
 description [f0/1.12][vlan12]
 encapsulation dot1Q 12
 ip address 192.168.12.254 255.255.255.0
 no ip redirects
 no ip unreachables
 no ip proxy-arp
 ip nat inside
 ip virtual-reassembly in

转变:

interface range gigabitEthernet 0/1-7
 switchport mode access
 switchport access vlan 10
 spanning-tree portfast
 switchport nonegotiate

interface range gigabitEthernet 0/8-14
 switchport mode access
 switchport access vlan 11
 spanning-tree portfast
 switchport nonegotiate

interface range gigabitEthernet 0/15-21
 switchport mode access
 switchport access vlan 12
 spanning-tree portfast
 switchport nonegotiate

interface GigabitEthernet0/24
 description [g0/24][router]
 switchport trunk encapsulation dot1q
 switchport trunk allowed vlan 10-12
 switchport mode trunk
 switchport nonegotiate
 load-interval 30
 carrier-delay msec 0
 spanning-tree portfast trunk

interface Vlan10
 ip address 192.168.10.1 255.255.255.0
 no ip redirects
 no ip unreachables
 no ip proxy-arp
 ip policy route-map vlan10

interface Vlan11
 ip address 192.168.11.1 255.255.255.0
 no ip redirects
 no ip unreachables
 no ip proxy-arp
 ip policy route-map vlan11

interface Vlan12
 ip address 192.168.12.1 255.255.255.0
 no ip redirects
 no ip unreachables
 no ip proxy-arp
 ip policy route-map vlan12

route-map vlan10 permit 10
 match ip address vlan-gateway
 set ip next-hop 192.168.10.254

route-map vlan11 permit 10
 match ip address vlan-gateway
 set ip next-hop 192.168.11.254

route-map vlan12 permit 10
 match ip address vlan-gateway
 set ip next-hop 192.168.12.254

ip access-list extended vlan-gateway
 deny ip 192.168.10.0 0.0.0.255 192.168.0.0 0.0.255.255
 deny ip 192.168.11.0 0.0.0.255 192.168.0.0 0.0.255.255
 deny ip 192.168.12.0 0.0.0.255 192.168.0.0 0.0.255.255
 permit ip any any

交换机路由表:

Switch# show ip route
 Gateway of last resort is not set
 C    192.168.10.0/24 is directly connected, Vlan10
 C    192.168.11.0/24 is directly connected, Vlan11
 C    192.168.12.0/24 is directly connected, Vlan12

期望的结果:

源IP:192.168.10.25
目的IP:192.168.11.15
路由:192.168.10.25 --> 192.168.10.1 --> 192.168.11.15

源IP:192.168.10.25
目的IP:8.8.8.8
路由:192.168.10.25 --> 192.168.10.1 --> 192.168.10.254 --> ISP

我试图避免的事情:

源IP:192.168.10.25
目的IP:192.168.11.15
路由:192.168.10.25 --> 192.168.10.1 --> 192.168.10.254 --> 192.168.11.15

源IP:192.168.10.25
目的IP:8.8.8.8
路由:192.168.10.25 --> 192.168.10.1 --> 192.168.11.254 --> ISP

尽管此配置可以按原样工作,但感觉很草率。
查看访问列表时,我也看到了意想不到的结果。我有 12 个终端窗口打开 ping 其他本地子网中的 IP 和 5 个 ping 外部子网,我有一堆随机的 youtube、vine、facebook 和其他数据包聊天丰富的网站打开。我以为这个数字会更高。

Extended IP access list vlan-gateway
     10 deny ip 192.168.10.0 0.0.0.255 192.168.0.0 0.0.255.255
     20 deny ip 192.168.11.0 0.0.0.255 192.168.0.0 0.0.255.255 (478 matches)
     30 deny ip 192.168.12.0 0.0.0.255 192.168.0.0 0.0.255.255 (3062 matches)
     40 permit ip any any (47 matches)
cisco policy-routing
  • 2 2 个回答
  • 494 Views

2 个回答

  • Voted
  1. Best Answer
    Massimo
    2016-05-01T05:41:46+08:002016-05-01T05:41:46+08:00

    使用您当前的配置,您不会在交换机上执行 VLAN 间路由;你在路由器上这样做。这很糟糕,原因有很多,其中一个主要原因是,从一个 VLAN 到另一个 VLAN 的所有流量都通过中继连接和路由器(这会导致瓶颈)。另外,您说您要使用“Router-on-a-stick 进行 nat/WAN 访问,第 3 层交换机用于 intervlan 路由”,所以您当前所做的实际上并不是您想要做的。

    由于您的交换机支持第 3 层,您只需在每个 VLAN(它已经拥有)上给它一个 IP 地址,并使用命令启用 IP 路由ip routing;这将处理 VLAN 间路由。

    然后,您需要修改网络映射以使用不同的 IP 子网将交换机连接到路由器,而不是通过中继连接将所有 VLAN 传送到路由器;您还必须将交换机配置为使用路由器作为其默认网关。需要相应地修改路由器配置:与交换机的单个连接,以及一些路由表条目以告诉它“您可以通过与交换机的连接访问那些内部 IP 子网”。最后但同样重要的是,每个 VLAN 中的所有计算机都需要使用该 VLAN 中的交换机接口(192.168.10.1、192.168.11.1 或 192.168.12.1)作为默认网关。

    这将实现您的要求:

    Source IP: 192.168.10.25
    Destination IP: 192.168.11.15
    Route: 192.168.10.25 --> 192.168.10.1 --> 192.168.11.15
    
    Source IP: 192.168.10.25
    Destination IP: 8.8.8.8
    Route: 192.168.10.25 --> 192.168.10.1 --> Router --> ISP 
    

    这是修改后的网络图(使用 192.168.42.0/24 进行路由器交换机连接):

    在此处输入图像描述

    以下是交换机的相应示例配置(为简洁起见,省略了一些细节):

    interface range gigabitEthernet 0/1-7
     switchport mode access
     switchport access vlan 10
    
    interface range gigabitEthernet 0/8-14
     switchport mode access
     switchport access vlan 11
    
    interface range gigabitEthernet 0/15-21
     switchport mode access
     switchport access vlan 12
    
    interface GigabitEthernet0/24
     ip address 192.168.42.42 255.255.255.0
    
    interface Vlan10
     ip address 192.168.10.1 255.255.255.0
    
    interface Vlan11
     ip address 192.168.11.1 255.255.255.0
    
    interface Vlan12
     ip address 192.168.12.1 255.255.255.0
    
    ip routing
    
    ip route 0.0.0.0 0.0.0.0 192.168.42.1
    

    这是路由器的相应示例配置(再次,为简洁起见省略了一些细节):

    ip access-list extended nated-nets
     permit ip 192.168.10.0 0.0.0.255 any
     permit ip 192.168.11.0 0.0.0.255 any
     permit ip 192.168.12.0 0.0.0.255 any
     permit ip 192.168.42.0 0.0.0.255 any
    
    ip nat inside source list nated-nets interface FastEthernet0/0 overload
    
    interface FastEthernet0/0
     ip address dhcp
     ip nat outside
    
    interface FastEthernet0/1
     ip address 192.168.42.1 255.255.255.0
     ip nat inside
    
    ip route 192.168.10.0 255.255.255.0 192.168.42.42
    ip route 192.168.11.0 255.255.255.0 192.168.42.42
    ip route 192.168.12.0 255.255.255.0 192.168.42.42
    

    当然,这可以进一步优化(fe /24 子网不需要只连接两个设备,并且那些路由表条目可以很容易地合并);但这应该足以让您入门。

    • 1
  2. Jhon
    2016-05-01T05:06:06+08:002016-05-01T05:06:06+08:00

    access-list的提示很奇怪,也许你可以用debug IP packet access-list或者wireshark来详细看看。不过这种设计很不寻常,也没有cisco的最佳实践,因为你避免了cef,增加了子处理转发。

    • 0

相关问题

  • 为 Cisco ASA 5510 上的端口 443/80 创建 NAT 规则和安全策略

  • 识别连接到交换机的机器

  • Cisco WS-C6509-E Arp 缓存损坏问题?

  • 广播 SSID 对客户端体验有何影响?

  • DHCP/网络问题

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve