不同网段交换机与路由器配置

1.网络拓扑图,交换机只充当转发功能

在电脑上指定ip 网关,eg:20.1.1.1 255.255.255.0 20.1.1.254

在路由器Route 0配置
         --- System Configuration Dialog ---

Continue with configuration dialog? [yes/no]: no
% Please answer 'yes' or 'no'.
Continue with configuration dialog? [yes/no]: n


Press RETURN to get started!



Router>en
Router#config
Configuring from terminal, memory, or network [terminal]? 
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#hostn
Router(config)#hostname wyq
wyq(config)#int f0/0
wyq(config-if)#ip add 10.1.1.254 255.255.255.0
wyq(config-if)#no shut

%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

wyq(config-if)#exit
wyq(config)#int f0/1
wyq(config-if)#ip add 20.1.1.254 255.255.255.0
wyq(config-if)#no sh

%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up

#可以观察到灯是绿的,证明已经配置成功!
#全网互通,可以相互通信

#
#路由器配置
wyq(config-if)#exit
wyq(config)#config
% Incomplete command.
wyq(config)#username oldxu password 123456
wyq(config)#line vty 0 4
wyq(config-line)#login local

测试10.1.1.1

#现在呢,交换机2950-24很嘚瑟,他说我也要被控制,咋办?
#打开交换机进行配置(左边第一台交换机)

Switch>en
Switch#config
Configuring from terminal, memory, or network [terminal]? 
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#username oldxu password 123456
Switch(config)#line vty 0 4
Switch(config-line)#login local
Switch(config-line)#exit
Switch(config)#int f0/1
Switch(config)#int vlan 1
Switch(config-if)#ip add 10.1.1.253 255.255.255.0
Switch(config-if)#no shut


#在pc端ping 10.1.1.253,测试可以ping 通
PC>ping 10.1.1.253

Pinging 10.1.1.253 with 32 bytes of data:

Reply from 10.1.1.253: bytes=32 time=30ms TTL=255
Reply from 10.1.1.253: bytes=32 time=20ms TTL=255

Ping statistics for 10.1.1.253:
    Packets: Sent = 2, Received = 2, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 20ms, Maximum = 30ms, Average = 25ms

Control-C
^C
PC>telnet 10.1.1.253
Trying 10.1.1.253 ...Open


User Access Verification

Username: oldxu
Password: 
Switch>



#第二台交换机同理
#打开交换机进行配置(右边那台交换机)
Switch>en
Switch#config
Configuring from terminal, memory, or network [terminal]? 
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#int vlan 1
Switch(config-if)#hostname sw2
sw2(config)#int vlan 1
sw2(config-if)#ip add 20.1.1.253 255.255.255.0
sw2(config-if)#no shut

%LINK-5-CHANGED: Interface Vlan1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up

sw2(config-if)#exit
sw2(config)#line vty 0 4
sw2(config-line)#login local
sw2(config-line)#exit
sw2(config)#username oldxu password 123456
sw2(config)#


#使用20.1.1.1进行测试,证明配置成功了
PC>ping 20.1.1.254

Pinging 20.1.1.254 with 32 bytes of data:

Reply from 20.1.1.254: bytes=32 time=13ms TTL=255
Reply from 20.1.1.254: bytes=32 time=12ms TTL=255


PC>telnet 20.1.1.253
Trying 20.1.1.253 ...Open


User Access Verification

Username: oldxu
Password: 
sw2>

#但是10.1.1.1这台pc是连不上右边这台交换机的,那么应该怎么做才可以被管理呢?

给交换机配网关,希望这个交换机可以被跨网段管理

#在右边交换机sw2上面配置网关,进入全局模式
sw2(config)#ip default-gateway 20.1.1.254

#现在10.1.1.1可以管理sw2了,oldxu是不是很开心???
posted @ 2020-05-14 10:09  老王教你学Linux  阅读(1442)  评论(0编辑  收藏  举报