将某公司内部的主机通过配置单臂路由、OSPF、RIP、引入路由、Easy IP技术来实现公司内部网络能够访问互联网。
在华为模拟器中新建如下图所示拓扑图
interface GigabitEthernet0/0/0
ip address 202.2.2.1 255.255.255.0 ##配置接口IP地址
\#
interface GigabitEthernet0/0/1
ip address 202.2.12.1 255.255.255.0 ##配置接口IP地址
interface GigabitEthernet0/0/0
ip address 10.1.113.1 255.255.255.0 ##配置接口IP地址
\#
interface GigabitEthernet0/0/2
ip address 10.1.111.1 255.255.255.0 ##配置接口IP地址
\#
interface GigabitEthernet10/0/0
ip address 10.1.112.1 255.255.255.0 ##配置接口IP地址
interface GigabitEthernet0/0/1
ip address 202.2.12.2 255.255.255.0 ##配置接口IP地址
\#
interface LoopBack0
ip address 2.2.2.2 255.255.255.255 ##配置环回IP地址
\#
ospf 1 router-id 2.2.2.2 ##配置router-id
default-route-advertise ##下发默认路由
area 0.0.0.0 ##进入骨干区域0
network 2.2.2.2 0.0.0.0
network 10.1.111.0 0.0.0.255
network 10.1.112.0 0.0.0.255
network 10.1.113.0 0.0.0.255 ##宣告网段
\#
acl number 3000 ##声明规则及序号是3000
rule permit ip source 10.1.0.0 0.0.255.255
##声明出接口公网IP地址允许哪个网段使用
\#
interface GigabitEthernet0/0/1
nat outbound 3000
\#
ip route-static 0.0.0.0 0.0.0.0 202.2.12.1 ##配置数据出去的默认路由
interface GigabitEthernet0/0/0
ip address 10.1.113.2 255.255.255.0
\#
interface GigabitEthernet0/0/1
ip address 10.1.134.1 255.255.255.0
\#
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
\#
ospf 1 router-id 3.3.3.3
import-route rip 1 cost 5 type 1 ##引入rip 1自治系统的路由信息
area 0.0.0.0 ##进入骨干区域0
network 3.3.3.3 0.0.0.0
network 10.1.113.0 0.0.0.255 ##宣告网段
\#
rip 1
default-route originate ##下发默认路由
version 2
network 10.0.0.0
import-route ospf 1 ##引入ospf1自治系统的路由信息
interface GigabitEthernet0/0/0.21
dot1q termination vid 21
ip address 10.1.21.1 255.255.255.0
arp broadcast enable ##在子接口配置vlan 21的网关地址
\#
interface GigabitEthernet0/0/0.22
dot1q termination vid 22
ip address 10.1.22.1 255.255.255.0
arp broadcast enable ####在子接口配置vlan 22的网关地址
\#
interface GigabitEthernet0/0/1
ip address 10.1.135.1 255.255.255.0
\#
interface GigabitEthernet0/0/2
ip address 10.1.134.2 255.255.255.0
\#
interface LoopBack0
ip address 4.4.4.4 255.255.255.255
\#
rip 1
version 2
network 10.0.0.0
network 4.0.0.0
interface GigabitEthernet0/0/0
ip address 10.1.100.1 255.255.255.0
\#
interface GigabitEthernet0/0/1
ip address 10.1.135.2 255.255.255.0
\#
interface LoopBack0
ip address 5.5.5.5 255.255.255.255
\#
rip 1
version 2
network 10.0.0.0
network 5.0.0.0
vlan batch 11 to 12 1000 to 1001
\#
interface Vlanif11
ip address 10.1.11.1 255.255.255.0
\#
interface Vlanif12
ip address 10.1.12.1 255.255.255.0
\#
interface Vlanif1000
ip address 10.1.122.11 255.255.255.0
\#
interface Vlanif1001
ip address 10.1.111.12 255.255.255.0
\#
interface Eth-Trunk1
port link-type access
port default vlan 1000
\#
interface GigabitEthernet0/0/1
port link-type access
port default vlan 11
\#
interface GigabitEthernet0/0/2
port link-type access
port default vlan 12
\#
interface GigabitEthernet0/0/3
port link-type access
port default vlan 1001
\#
interface GigabitEthernet0/0/4
eth-trunk 1
\#
interface GigabitEthernet0/0/5
eth-trunk 1
\#
interface LoopBack0
ip address 11.11.11.11 255.255.255.255
\#
ospf 1 router-id 11.11.11.11
area 0.0.0.0
network 11.11.11.11 0.0.0.0
network 10.1.11.0 0.0.0.255
network 10.1.12.0 0.0.0.255
network 10.1.122.0 0.0.0.255
network 10.1.111.0 0.0.0.255
vlan batch 13 to 14 1000 1002
\#
interface Vlanif13
ip address 10.1.13.1 255.255.255.0
\#
interface Vlanif14
ip address 10.1.14.1 255.255.255.0
\#
interface Vlanif1000
ip address 10.1.122.12 255.255.255.0
\#
interface Vlanif1002
ip address 10.1.112.12 255.255.255.0
\#
interface Eth-Trunk1
port link-type access
port default vlan 1000
\#
interface GigabitEthernet0/0/1
port link-type access
port default vlan 13
\#
interface GigabitEthernet0/0/2
port link-type access
port default vlan 14
\#
interface GigabitEthernet0/0/3
port link-type access
port default vlan 1002
\#
interface GigabitEthernet0/0/4
eth-trunk 1
\#
interface GigabitEthernet0/0/5
eth-trunk 1
\#
interface LoopBack0
ip address 22.22.22.22 255.255.255.255
\#
ospf 1 router-id 22.22.22.22
area 0.0.0.0
network 22.22.22.22 0.0.0.0
network 10.1.112.0 0.0.0.255
network 10.1.122.0 0.0.0.255
network 10.1.14.0 0.0.0.255
network 10.1.13.0 0.0.0.255
vlan batch 21 to 22
\#
interface Ethernet0/0/1
port link-type access
port default vlan 21
\#
interface Ethernet0/0/2
port link-type trunk
port trunk allow-pass vlan 21 to 22
\#
interface Ethernet0/0/3
port link-type access
port default vlan 22
公司内部网络内的主机都能成功访问互联网(下图为PC1ping通PC6)。
本次实验路由器R2和R3上需要配置的命令较多,需要理清思路,仔细的配置好。
路由器R2上需要配置接口和环回地址、ospf动态路由、下发路由和数据转发到互联网的默认路由。
路由器R3上需要配置接口和环回地址、ospf动态路由、rip v2动态路由、下发路由和引入路由。
同时本次实验运用到了下发默认路由的新命令,其含义是本路由器发布一条0.0.0.0/0.0.0.0的路由到域内其他路由器。其他路由器学习到这条默认路由后,下一跳就是指向发布这条路由的路由器。
配置在网关出接口路由器上的命令:
ospf 1
default-route-advertise
配置完后ospf区域内其他路由器会多一条默认路由:
配置在ASBR上的命令:
rip 1
default-route originate