傍晚时分,你坐在屋檐下,看着天慢慢地黑下去,心里寂寞而凄凉,感到自己的生命被剥夺了。当时我是个年轻人,但我害怕这样生活下去,衰老下去。在我看来,这是比死亡更可怕的事。--------王小波
需求:实验室有一条接入网线,该网线直接连接PC,PC的IP设置为 192.168.100.xxx 后可以访问服务器机房的服务器(IP为192.168.100.1),但是想要实验室内的多台PC都能访问 192.168.100.1,请问交换机应该如何配置?
拓扑图。配置 |
配置三层交换机 |
配置终端IP |
ping测试 |
Please press enter to start cmd line!
[Huawei]interface Vlanif 100
[Huawei-Vlanif100]ip address 192.168.100.254 24
[Huawei-Vlanif100]quit
[Huawei]interface Vlanif 10
[Huawei-Vlanif10]ip address 192.168.10.254 24
[Huawei-Vlanif10]quit
[Huawei]display ip routing-table include /24
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 6 Routes : 6
Destination/Mask Proto Pre Cost Flags NextHop Interface
192.168.10.0/24 Direct 0 0 D 192.168.10.254 Vlanif10
192.168.100.0/24 Direct 0 0 D 192.168.100.254 Vlanif100
[Huawei]
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fea0:1eb4
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.100.1
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.100.254
Physical address..................: 54-89-98-A0-1E-B4
DNS server........................:
PC>ping 192.168.10.2
Ping 192.168.10.2: 32 data bytes, Press Ctrl_C to break
From 192.168.10.2: bytes=32 seq=1 ttl=127 time=110 ms
From 192.168.10.2: bytes=32 seq=2 ttl=127 time=47 ms
From 192.168.10.2: bytes=32 seq=3 ttl=127 time=46 ms
--- 192.168.10.2 ping statistics ---
3 packet(s) transmitted
3 packet(s) received
0.00% packet loss
round-trip min/avg/max = 46/67/110 ms
Welcome to use PC Simulator!
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fea7:1ca1
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.10.2
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.10.254
Physical address..................: 54-89-98-A7-1C-A1
DNS server........................:
PC>ping 192.168.100.1
Ping 192.168.100.1: 32 data bytes, Press Ctrl_C to break
From 192.168.100.1: bytes=32 seq=1 ttl=127 time=47 ms
From 192.168.100.1: bytes=32 seq=2 ttl=127 time=31 ms
--- 192.168.100.1 ping statistics ---
2 packet(s) transmitted
2 packet(s) received
0.00% packet loss
round-trip min/avg/max = 31/39/47 ms
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fe84:2ce2
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.10.3
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.10.254
Physical address..................: 54-89-98-84-2C-E2
DNS server........................:
PC>ping 192.168.100.1
Ping 192.168.100.1: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 192.168.100.1: bytes=32 seq=2 ttl=127 time=47 ms
From 192.168.100.1: bytes=32 seq=3 ttl=127 time=47 ms
From 192.168.100.1: bytes=32 seq=4 ttl=127 time=47 ms
--- 192.168.100.1 ping statistics ---
4 packet(s) transmitted
3 packet(s) received
25.00% packet loss
round-trip min/avg/max = 0/47/47 ms
案例(更合理地使用三层交换机):交换机、三层交换机、路由构建网络
需求:实验室有一条接入网线,该网线直接连接PC,PC的IP设置为 192.168.4.xxx 后可以访问服务器机房的服务器(IP为192.168.5.1),但是想要实验室内的多台PC都能访问 192.168.5.1,请问交换机应该如何配置?
综合组网 |
第一步:设计好网络拓扑结构;为了缓解三层交换机的压力,通常连接外部网路需要连接一个路由器。路由器的功能要比三成交换机强大。 |
PC1: IP地址:192.168.1.1/24 网关:192.168.1.254
PC2: IP地址:192.168.2.1/24 网关:192.168.2.254
PC3: IP地址:192.168.3.1/24 网关:192.168.3.254
PC4: IP地址:192.168.5.1/24 网关:192.168.5.254
[LSW1]interface Ethernet 0/0/2
[LSW1-Ethernet0/0/2]port link-type access
[LSW1-Ethernet0/0/2]port default vlan 2
[LSW1-Ethernet0/0/2]display vlan #查看结果
[LSW1]interface Ethernet 0/0/3
[LSW1-Ethernet0/0/3]port link-type access
[LSW1-Ethernet0/0/3]port default vlan 3
[LSW1-Ethernet0/0/3]display vlan #查看结果
#在二层交换机LSW1 (S3700)的Ethernet 0/0/4接口配置trunk
[LSW1]interface Ethernet 0/0/4
[LSW1-Ethernet0/0/4]port link-type trunk
[LSW1-Ethernet0/0/4]port trunk allow-pass vlan all
[LSW1-Ethernet0/0/4]quit
[LSW1]display current-configuration
#在三层交换机LSW2(S5700)的Ethernet 0/0/4接口配置trunk
[LSW2]interface GigabitEthernet 0/0/1
[LSW2-GigabitEthernet0/0/1]port link-type trunk
[LSW2-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[LSW2-GigabitEthernet0/0/1]quit
[LSW2]display current-configuration
#在vlan 1上配置IP地址
[LSW2]interface Vlanif 1
[LSW2-Vlanif1]ip address 192.168.1.254 24
[LSW2-Vlanif1]quit
#在vlan 2上配置IP地址
[LSW2]interface Vlanif 2
[LSW2-Vlanif2]ip address 192.168.2.254 24
[LSW2-Vlanif2]quit
#在vlan 3上配置IP地址
[LSW2]interface Vlanif 3
[LSW2-Vlanif3]ip address 192.168.3.254 24
[LSW2-Vlanif3]quit
#在vlan 4上配置IP地址
[LSW2]interface Vlanif 4
[LSW2-Vlanif4]ip address 192.168.4.1 24
[LSW2-Vlanif4]quit
[LSW2]display ip routing-table include /24 #查看虚接口配置信息
……