VLAN下的IP如何与其他VLAN的IP通信?

网络工程 思科 转变 路由器 联网 路线
2022-02-27 02:20:39

我的网络拓扑如下:

在此处输入图像描述

我想使用 Server0 来管理(通信)到10.10.10.1-3.

你知道10.10.10.1-3是vlan100的SVI。

vlan 100vlan 501

知识产权计划:

vlan 100(10.10.10.0/24) 
vlan 501(10.50.1.0/24)

服务器的 IP 是 10.10.10.5,但如果它也可以10.50.1.*/24(我的意思是我只希望 Server0 可以管理10.10.10.0/24

如何实现?


配置如下:

开关0:

Switch#show running-config 
Building configuration...

Current configuration : 1427 bytes
!
version 12.2(37)SE1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Switch

!
spanning-tree mode pvst
!
!
!
!
!
!
interface FastEthernet0/1
...
interface FastEthernet0/24
!
interface GigabitEthernet0/1
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
interface GigabitEthernet0/2
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
interface Vlan1
 no ip address
 shutdown
!
interface Vlan100
 mac-address 0005.5ed1.7601
 ip address 10.10.10.1 255.255.255.0
!
interface Vlan501
 mac-address 0005.5ed1.7602
 ip address 10.50.1.254 255.255.255.0
!
ip classless
!
ip flow-export version 9
!
!
!
!
!
!
!
!
line con 0
!
line aux 0
!
line vty 0 4
 login
!
!
!
!
end

开关1:

Switch#show running-config 
Building configuration...

Current configuration : 1341 bytes
!
version 12.2(37)SE1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Switch
!

!
spanning-tree mode pvst
!
!
!
!
!
!
interface FastEthernet0/1
...
interface FastEthernet0/24
!
interface GigabitEthernet0/1
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
interface GigabitEthernet0/2
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
interface Vlan1
 no ip address
 shutdown
!
interface Vlan100
 mac-address 00d0.ff83.b201
 ip address 10.10.10.2 255.255.255.0
!
ip classless
!
ip flow-export version 9
!
!
!
!
!
!
!
!
line con 0
!
line aux 0
!
line vty 0 4
 login
!
!
!
!
end

开关2:

Switch#show running-config 
Building configuration...

Current configuration : 1459 bytes
!
version 12.2(37)SE1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Switch
!
!
spanning-tree mode pvst
!
!
!
!
!
!
interface FastEthernet0/1
 switchport access vlan 501
!
interface FastEthernet0/2
...
!
interface FastEthernet0/24
!
interface GigabitEthernet0/1
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
interface GigabitEthernet0/2
 switchport access vlan 501
 switchport trunk encapsulation dot1q
 switchport mode access
 switchport nonegotiate
!
interface Vlan1
 no ip address
 shutdown
!
interface Vlan100
 mac-address 0002.179a.3701
 ip address 10.10.10.3 255.255.255.0
!
ip classless
ip route 0.0.0.0 0.0.0.0 10.10.10.1 
!
ip flow-export version 9
!
!
!
line con 0
!
line aux 0
!
line vty 0 4
 login
!
!
!
!
end

所有的 Switch 都有vlan 100vlan 501


EDIT-01

我已将服务器的 IP 更改为10.50.1.5/24. 但我不知道如何将网关添加到 SVI。

Vlanif 中的命令似乎没有添加网关的参数:

Switch(config-if)#ip address 10.10.10.2 255.255.255.0 ?
<cr>

我的目的是让服务器管理(通信)10.10.10.0/24.

2个回答

服务器的地址必须是其配置所在子网的一部分。由于您的服务器位于 VLAN 501 上,因此其 IP 地址必须位于 10.50.1.0/24 子网中,而不是您配置的。
将服务器的默认网关设置为 VLAN 501 上的 SVI:10.50.1.254。

交换机 1 还需要将网关设置为 Sw0 上的 SVI:10.10.10.1,方法与 Sw2 相同。

如果要使用 Server0 与 通信10.10.10.0/24,则应满足以下条件:

  1. Switch0、Switch1、Switch2 都应该有vlan 100vlan 501
  2. Switch0 有两个 SVI:vlanif-100: 10.10.10.1/24vlanif-501: 10.50.1.254/24.
  3. 我假设 Server0 的 IP 是10.50.1.5.
  4. 然后10.50.1.5可以与 通信10.10.10.1,因为 Switch0 本身就有 SVI。
  5. 如果要与其他交换机通信,则应在交换机中写入静态路由。ip route 10.50.1.5 255.255.255.255 10.10.10.1.