一、 拓扑图
二、配置
步骤:
1.基础配置
router配置:
interface FastEthernet0/0
ip address 192.168.2.254 255.255.255.0
interface FastEthernet0/1
ip address 192.168.1.254 255.255.255.0
Switch配置:
稍后配置
pc0配置:
ip: 192.168.1.2/24
gw:192.168.1.254
pc1配置:
ip: 192.168.1.2/24
gw:192.168.2.254
2. 解决问题
1)、如何给switch配置ip 地址
switch的ip是基于vlan的(这个问题等会再说)。配置:
interface Vlan1
ip address 192.168.1.3 255.255.255.0
结果:
PC>ping 192.168.1.3
Pinging 192.168.1.3 with 32 bytes of data:
Reply from 192.168.1.3: bytes=32 time=31ms TTL=255
Reply from 192.168.1.3: bytes=32 time=31ms TTL=255
Reply from 192.168.1.3: bytes=32 time=31ms TTL=255
Reply from 192.168.1.3: bytes=32 time=31ms TTL=255
2)、怎么实现pc0 telnet到switch
配置:
line vty 0 4
password cisco
login
结果:
PC>telnet 192.168.1.3
Trying 192.168.1.3 ...Open
User Access Verification
Password:
Switch>
Switch>enable
% No password set.
Switch>
如果想进的exec 配置模式
switch还需要配置:
enable password config
结果:
Switch>enable
Password:
Switch#
3)、 实现pc1 telnet到switch
PC>ping 192.168.1.3
Pinging 192.168.1.3 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
结果是ping不同的。分析---因为pc1的一个“外网的数据包”发给网关,即router。router查路由表,目的是192.168.1.3 是直连。发给switch,switch收到后,回复数据包,但switch没有路由表,说以要设置一个网关给它,配置:
ip default-gateway 192.168.1.254
结果:
PC>ping 192.168.1.3
Pinging 192.168.1.3 with 32 bytes of data:
Reply from 192.168.1.3: bytes=32 time=63ms TTL=254
Reply from 192.168.1.3: bytes=32 time=63ms TTL=254
Reply from 192.168.1.3: bytes=32 time=63ms TTL=254
Reply from 192.168.1.3: bytes=32 time=62ms TTL=254
PC>telnet 192.168.1.3
Trying 192.168.1.3 ...Open
User Access Verification
Password:
Switch>enable
Password:
Switch#
最后留一个问题:希望读者给个补充:在“不同vlan的telnet” 或者是“ 非本针vlan 的telnet ”怎么配置?