两个不同VLAN间怎么才能互相ping通,不要解释,需要配置命令!要代码!!!pc0和pc1是一个

2024-11-14 12:19:09
推荐回答(1个)
回答1:

这里,核心的一口接sw0的一口;sw0 的一口接sw1上网一口;sw1的二口接PC0,三口接PC1,四口接PC2,五口接PC3;PC0和PC1网段是192.168.1.0网段,掩码是255.255.255.0,网关地址是192.168.1.1;PC2和PC3网段是192.168.2.0网段,子网掩码四255.255.255.0,网关地址是192.168.2.1,四台电脑都可以自动获取地址
核心配置:
vlan 10
vlan 20
interface Vlan10
ip address 192.168.1.1 255.255.255.0
no shutdown
interface Vlan20
ip address 192.168.2.1 255.255.255.0
no shutdown
ip dhcp pool 10
network 192.168.1.0 255.255.255.0
default-router 192.168.1.1
dns-server 8.8.8.8
ip dhcp pool 20
network 192.168.2.0 255.255.255.0
default-router 192.168.2.1
dns-server 8.8.8.8
iprouting
interface FastEthernet0/1
switchport trunk encapsulation dot1q
switchport mode trunk

SW0配置:
vlan 10
vlan 20
interface FastEthernet0/1
switchport mode trunk
interface FastEthernet0/2
switchport mode trunk

SW1配置:
vlan 10
vlan 20
interface FastEthernet0/1
switchport mode trunk
interface FastEthernet0/2
switchport access vlan 10
switchport mode access
interface FastEthernet0/3
switchport access vlan 10
switchport mode access
interface FastEthernet0/4
switchport access vlan 20
switchport mode access
interface FastEthernet0/5
switchport access vlan 2
switchport mode access