思科网络配置

如题所述

第1个回答  2022-07-11
enable
config t
1、创建相应的vlan
vlan 10
2、连接终端的端口加入到相应的VLAN
interface range f0/1-2
switchport access vlan 10
exit
3、将交换机与交换机的端口配置成TRUNK
interface f0/3
switchport mode trunk
end

1、交换机与交换机相连的端口配置成trunk
Switch(config)#interface range f0/1-2
Switch(config-if-range)#sw m t
2、创建相应的vlan(本汇聚层交换机以下所有vlan)
Switch(config)#vlan 10

enable
conf t
vlan 10
vlan 20
vlan 30
interface range f0/1-3
switchport trunk en do
switchport mode trunk
exit
interface vlan 10
ip address 192.168.10.254 255.255.255.0
exit
interface vlan 20
ip address 192.168.20.254 255.255.255.0
exit
interface vlan 30
ip address 192.168.30.254 255.255.255.0
exit
ip routing //启用ip路由功能
interface f0/1
no switchport
ip address 192.168.40.2 255.255.255.0
end
write

enable
conf t
vlan 40
vlan 50
int rang f0/2
switchport trunk en do
switchport mode trunk
exit

interface vlan 40
ip address 100.100.100.1 255.255.255.0
exit
interface vlan 50
ip address 110.110.110.1 255.255.255.0
ip routing
interface f0/1
no switchport
ip address 54.1.1.2 255.255.255.0
end
write

三层

router rip
network 54.1.1.0
network 100.100.100.0
network 110.110.110.0

路由5
conf t
router rip
network 45.1.1.0
network 54.1.1.0

路由4
en
show ip route

conf t
router rip
network 45.1.1.0
network 64.1.1.0

路由6
en
show ip route

conf t
router rip
network 64.1.1.0


路由6
en
conf t
access-list 1 permit 192.168.10.0 0.0.0.255
access-list 1 permit 192.168.20.0 0.0.0.255
ip nat inside source list 1 interface f0/1

interface f0/0
ip nat inside
exit
interface f0/1
ip nat outside

路由6
Router(config)#ip route 192.168.20.0 255.255.255.0 192.168.40.2
Router(config)#ip route 192.168.10.0 255.255.255.0 192.168.40.2
Router(config)#ip route 192.168.30.0 255.255.255.0 192.168.40.2
access-list 1 permit 192.168.30.0 0.0.0.255

RIP(Routing Information Protocol,路由信息协议)是一种 内部网关协议 (IGP),是一种 动态路由选择 协议,用于自治系统(AS)内的路由信息的传递。

如何配置动态路由协议RIP(内网三层设备都要rip,边界路由器)
Switch#show ip route 查路由表
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

端口映射:Router(config)#ip nat inside source static tcp 192.168.10.1 80 64.1.1.1 80

NAT上网的思路
1、内网做通(ok)
2、外网做通(ok)
3、采用NAT将内外网连通

NAT配置的位置:内网与外网相交的三层设备上进行配置

1、控制内网要上网的网段。
Router(config)#access-list 1 permit 192.168.10.0 0.0.0.255
Router(config)#access-list 1 permit 192.168.20.0 0.0.0.255
2、实现内网到外网的转换
Router(config)#ip nat inside source list 1 interface f0/1
inside source list 1 :内网要上网的网段
interface f0/1 (本路由器的外网接口)
3、指定本路由器内外网接口
Router(config)#interface f0/0
Router(config-if)#ip nat inside
Router(config-if)#exit
Router(config)#interface f0/1
Router(config-if)#ip nat outside

注意:内网所有的三层设备需要配置一个默认路由到公网:
Switch(config)#ip route 0.0.0.0 0.0.0.0 192.168.40.1


端口映射:Router(config)#ip nat inside source static tcp 192.168.10.1 80 64.1.1.1 80

路由器端口设置ip

1.规划网段

2.配置ip

3.配路由协议(让路由层面互通)

en
conf t
interface f0/0
no shutdown
ip address 192.168.50.2 255.255.255.0
exit
interface f0/1
no shutdown
ip address 192.168.50.1 255.255.255.0
exit

en
conf t
ip dhcp pool pc0
network 192.168.10.0 255.255.255.0
default-router 192.168.10.254
exit

设置DNS
dns-server 192.168.110.2

show ip route
en
conf t
router ospf 1 //进程号
network 192.168.10.0 0.0.0.255 area 0
network 192.168.20.0 0.0.0.255 area 0

// network 直连网段 反子网掩码 直连网段所处区域

R2

interface loopback 1
ip address 2.2.2.2 255.255.255.0

show ip protocols
router ospf 1
router-id 2.2.2.2
write
clear ip ospf process #重启OSPF路由协议,让配置生效

rouer ospf 1
network 2.2.2.0 0.0.0.255 area 2

router ospf 1
area 2(两个区域之间的区域) virtual-link 4.4.4.4(对方的身份证)

R4

interface loopback 1
ip address 4.4.4.4 255.255.255.0

router ospf 1
router-id 4.4.4.4
write
clear ip ospf process

rouer ospf 1
network 4.4.4.0 0.0.0.255 area 2

router ospf 1
area 2(两个区域之间的区域) virtual-link 2.2.2.2(对方的身份证)

Router#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
12.1.1.1 1 FULL/DR 00:00:35 12.1.1.1 FastEthernet0/0
34.1.1.3 1 FULL/DR 00:00:32 23.1.1.3 FastEthernet0/1
4.4.4.4 0 FULL/ - 00:00:38 34.1.1.4 OSPF_VL0

R1 ping R5能 ping通

两个交换机都要配

en

conf t

int vlan 10

standby 2 ip 192.168.20.253

修改pc的网关为192.168.10.253

router0
Router(config)#interface tunnel 1
Router(config-if)#tunnel source f0/1 (接口给本路由器的公网接口)
Router(config-if)#tunnel destination 110.110.110.2(给对方的公网地址)

router2
interface tunnel 1
tunnel source f0/0
tunnel destination 100.100.100.1

Router0
Router(config)#interface tunnel 1
Router(config-if)#ip address 1.1.1.1 255.255.255.0
Router2
Router(config)#interface tunnel 1
Router(config-if)#ip address 1.1.1.2 255.255.255.0
测试隧道是否能够通信。
Router#ping 1.1.1.1

第六部:将隧道接口所有的网段network到总部与分部所有的路由协议(rip\ospf)里面去。
Router0
Router(config)#router ospf 1
Router(config-router)#network 1.1.1.0 0.0.0.255 area 0
Router2
Router(config)#router ospf 1
Router(config-router)#network 1.1.1.0 0.0.0.255 area 0
或者
Router0
Router(config)#router rip
Router(config-router)#network 1.1.1.0
Router2
Router(config)#router rip
Router(config-router)#network 1.1.1.0
相似回答