<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R1
[R1]int g0/0/1 ###进入端口
[R1-GigabitEthernet0/0/1]ip add 15.0.0.1 30 ###设置IP地址
[R1-GigabitEthernet0/0/1]un sh ###开启端口
[R1-GigabitEthernet0/0/1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 12.0.0.1 30
[R1-GigabitEthernet0/0/0]un sh
[R1-GigabitEthernet0/0/0]int loo 0 ###进入环回口
[R1-LoopBack0]ip add 1.1.1.1 32
[R1-LoopBack0]q
[R1]ospf 1 router-id 1.1.1.1 ###开启OSPF
[R1-ospf-1]area 0 ###0号区域
[R1-ospf-1-area-0.0.0.0]network 12.0.0.0 0.0.0.3 ###宣告网络号,有多少说多少,掩码是反掩码
[R1-ospf-1-area-0.0.0.0]network 1.1.1.1 0.0.0.0
[R1-ospf-1-area-0.0.0.0]network 15.0.0.0 0.0.0.3
[R1-ospf-1-area-0.0.0.0]q
[R1-ospf-1]q
[R1]bgp 100 ###启用BGP 区域100
[R1-bgp]router-id 1.1.1.1
[R1-bgp]peer 2.2.2.2 as-number 100 ###建立邻居 在区域100
[R1-bgp]peer 2.2.2.2 connect-interface loo 0 ###表示用loo 0跟邻居交流
[R1-bgp]peer 5.5.5.5 as-number 100
[R1-bgp]peer 5.5.5.5 connect-interface loo 0
R2配置:
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R2
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 12.0.0.2 30
[R2-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[R2-GigabitEthernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 23.0.0.1 30
[R2-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[R2-GigabitEthernet0/0/1]int loo 0
[R2-LoopBack0]ip add 2.2.2.2 32
[R2-LoopBack0]q
[R2]ospf 1 router-id 2.2.2.2 ###启用OSPF
[R2-ospf-1]area 0 ###0号区域
[R2-ospf-1-area-0.0.0.0]network 12.0.0.0 0.0.0.3 ###宣告网络号
[R2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[R2-ospf-1-area-0.0.0.0]q
[R2-ospf-1]q
[R2]bgp 100 ###启用BGP 100区域
[R2-bgp]router-id 2.2.2.2
[R2-bgp]peer 1.1.1.1 as-number 100 ###建立邻居关系
[R2-bgp]peer 1.1.1.1 connect-interface loo 0
[R2-bgp]peer 5.5.5.5 as-number 100
[R2-bgp]peer 5.5.5.5 connect-interface loo 0
[R2-bgp]peer 3.3.3.3 as-number 200 ###建立邻居关系,要写3.3.3.3所在的区域
[R2-bgp]peer 3.3.3.3 connect-interface loo 0
[R2-bgp]peer 3.3.3.3 ebgp-max-hop 2 ###EBGP,跳两下(一般默认两下)
[R2-bgp]q
[R2]rip 1 ###启用rip 1
[R2-rip-1]v 2 ###2号版本
[R2-rip-1]un summary ###关闭路由汇总信息
[R2-rip-1]network 23.0.0.0 ###宣告网络号
[R2-rip-1]network 2.0.0.0
R4配置:
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R4
[R4]int g0/0/1
[R4-GigabitEthernet0/0/1]ip add 15.0.0.2 30
[R4-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[R4-GigabitEthernet0/0/1]int loo 0 ###进入 0 号环回口
[R4-LoopBack0]ip add 5.5.5.5 32
[R4-LoopBack0]int loo1 ###进入 1 号环回口
[R4-LoopBack1]ip add 202.0.0.1 24
[R4-LoopBack1]int loo2 ###进入 2 号环回口
[R4-LoopBack2]ip add 202.0.1.1 24
[R4-LoopBack2]q
[R4]ospf 1 router-id 5.5.5.5 ###启用OSPF
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]network 15.0.0.0 0.0.0.3 ###宣告网络号,反掩码
[R4-ospf-1-area-0.0.0.0]network 5.5.5.5 0.0.0.0
[R4-ospf-1-area-0.0.0.0]q
[R4-ospf-1]q
[R4]bgp 100 ###启用BGP
[R4-bgp]router-id 5.5.5.5
[R4-bgp]peer 1.1.1.1 as-number 100
[R4-bgp]peer 1.1.1.1 connect-interface loo 0
[R4-bgp]peer 2.2.2.2 as-number 100
[R4-bgp]peer 2.2.2.2 connect-interface loo 0
[R4-bgp]network 202.0.0.0
[R4-bgp]network 202.0.1.0
R3配置:
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R3
[R3]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 23.0.0.2 30
[R3-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[R3-GigabitEthernet0/0/1]int loo 0
[R3-LoopBack0]ip add 3.3.3.3 32
[R3-LoopBack0]q
[R3]rip ###启用rip
[R3-rip-1]v 2 ###2号版本
[R3-rip-1]un summary ###关闭路由汇总信息
[R3-rip-1]network 23.0.0.0 ###宣告网络号
[R3-rip-1]network 2.0.0.0 ###这个我设错了
[R3-rip-1]undo network 2.0.0.0 ###把他删除
[R3-rip-1]network 3.0.0.0
[R3-rip-1]dis this ###不太放心的话可以dis this看一下
[V200R003C00]
#
rip 1
undo summary
version 2
network 23.0.0.0
network 3.0.0.0
#
return
[R3-rip-1]q ###发现没有问题,退出准备启用BGP
[R3]bgp 200 ###启用BGP 因为他在另一个区域200,所以设置 200
[R3-bgp]router-id 3.3.3.3
[R3-bgp]peer 2.2.2.2 as-number 100
[R3-bgp]peer 2.2.2.2 connect-interface loo 0
[R3-bgp]peer 2.2.2.2 ebgp-max-hop 2 ###EBGP到邻居2.2.2.2需要两跳(默认两跳)
然后我们查看一下路由信息
R3已经学习到R4的两条路由了。其他的肯定也都学习到了,自己可以去看看。
然后我们去把R4上面的两条路由删掉,换一种方法看看R3还能不能学到。
[R4]bgp 100
[R4-bgp]dis this
[V200R003C00]
#
bgp 100
router-id 5.5.5.5
peer 1.1.1.1 as-number 100
peer 1.1.1.1 connect-interface LoopBack0
peer 2.2.2.2 as-number 100
peer 2.2.2.2 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
network 202.0.0.0 ###看这儿
network 202.0.1.0 ###还有这儿
peer 1.1.1.1 enable
peer 2.2.2.2 enable
#
return
[R4-bgp]undo network 202.0.0.0 ###删掉这条路由
[R4-bgp]undo network 202.0.1.0 ###删掉这条路由
[R4-bgp]dis this ##再查看一下还在不在
[V200R003C00]
#
bgp 100
router-id 5.5.5.5
peer 1.1.1.1 as-number 100
peer 1.1.1.1 connect-interface LoopBack0
peer 2.2.2.2 as-number 100
peer 2.2.2.2 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
###可以看到两条路由没了
peer 1.1.1.1 enable
peer 2.2.2.2 enable
#
return
[R4-bgp]import-route direct ###宣告所有的直连信息