将centos系统变成ospf路由器

将centos系统变成ospf路由器

Quagga是一个开源路由软件,支持RIP、OSPF、BGP和IS-IS等主要路由协议的路由器:
这里以centos7和H3C交换机组网ospf测试:centos地址是192.168.1.106,H3C交换机地址是192.168.1.252
1、安装quagga服务,并能看到简单的配置文件

[root@RAs ~]# yum install quagga
[root@RAs ~]# cd /usr/share/doc/quagga-0.99.22.4/
[root@RAs quagga-0.99.22.4]# ls -l *.sample
-rw-r--r-- 1 root root  655 Aug  4  2013 babeld.conf.sample
-rw-r--r-- 1 root root  566 Jul 13  2012 bgpd.conf.sample
-rw-r--r-- 1 root root  789 Jul 13  2012 isisd.conf.sample
-rw-r--r-- 1 root root 1110 Jul 13  2012 ospf6d.conf.sample
-rw-r--r-- 1 root root  182 Jul 13  2012 ospfd.conf.sample
-rw-r--r-- 1 root root  406 Jul 13  2012 ripd.conf.sample
-rw-r--r-- 1 root root  390 Jul 13  2012 ripngd.conf.sample
-rw-r--r-- 1 root root  369 Jul 13  2012 zebra.conf.sample

2、完成配置ospf的配置:
将配置文件复制到指定目录下:

[root@RAs ~]# cp /usr/share/doc/quagga-0.99.22.4/ospfd.conf.sample /etc/quagga/ospfd.conf
[root@RAs ~]# chown quagga.quagga /etc/quagga/ospfd.conf    #注意权限问题
[root@RAs ~]# systemctl start zebra      #开启守护进程
[root@RAs ~]# systemctl start ospfd     #开启ospf进程
[root@RAs ~]# vtysh     #进入类似思科路由器一样的终端界面

Centos配置过程:

RAs# configure  terminal  
RAs(config)# interface  lo
RAs(config-if)# ip address 1.1.1.1/32
RAs(config-if)# ip address 172.16.1.254/24
RAs(config-if)# ip address 172.16.2.254/24
RAs(config-if)# ip address 172.16.3.254/24
RAs(config-if)# exit
RAs(config)# exit  
RAs# show  interface  
Interface ens33 is up, line protocol detection is disabled
  index 2 metric 1 mtu 1500 
  flags: <UP,BROADCAST,RUNNING,MULTICAST>
  HWaddr: 00:0c:29:6a:27:a7
  inet 192.168.1.106/24 broadcast 192.168.1.255
  inet6 fe80::ba12:9bfa:b522:add7/64
Interface lo is up, line protocol detection is disabled
  index 1 metric 1 mtu 65536 
  flags: <UP,LOOPBACK,RUNNING>
  inet 1.1.1.1/32
  inet 127.0.0.1/8
  inet 172.16.1.254/24 broadcast 172.16.1.255
  inet 172.16.2.254/24 broadcast 172.16.2.255
  inet 172.16.3.254/24 broadcast 172.16.3.255
  inet6 ::1/128
RAs# configure  terminal  
RAs(config)# router ospf 
RAs(config-router)# router-id  1.1.1.1
RAs(config-router)# network  192.168.1.106/24 area  0
RAs(config-router)# network  172.16.1.254/24 area  0
RAs(config-router)# network  172.16.2.254/24 area  0
RAs(config-router)# network  172.16.3.254/24 area  0
RAs(config-router)# exit
RAs(config)# exit
RAs# write  
Building Configuration...
Configuration saved to /etc/quagga/zebra.conf
Configuration saved to /etc/quagga/ospfd.conf
[OK]
RAs# 
[root@RAs ~]# systemctl restart ospfd

H3C交换机配置过程:

[H3C]interface LoopBack 0
[H3C-LoopBack0]ip address  2.2.2.2 32
[H3C-LoopBack0]interface LoopBack 1
[H3C-LoopBack1]ip address 192.168.11.254 24
[H3C-LoopBack1]interface LoopBack 2
[H3C-LoopBack2]ip address 192.168.12.254 24
[H3C-LoopBack2]interface LoopBack 3
[H3C-LoopBack3]ip address 192.168.13.254 24
[H3C-LoopBack3]quit
[H3C]
[H3C]ospf 1 router-id 2.2.2.2
[H3C-ospf-1]area 0 
[H3C-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[H3C-ospf-1-area-0.0.0.0]network 192.168.1.252 0.0.0.0
[H3C-ospf-1-area-0.0.0.0]network 192.168.11.254 0.0.0.0
[H3C-ospf-1-area-0.0.0.0]network 192.168.12.254 0.0.0.0
[H3C-ospf-1-area-0.0.0.0]network 192.168.13.254 0.0.0.0
[H3C-ospf-1-area-0.0.0.0]quit
[H3C-ospf-1]quit

3、检查两端的路由:

RAs# show ip route  ospf  
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, A - Babel,
       > - selected route, * - FIB route

O   1.1.1.1/32 [110/10] is directly connected, lo, 00:01:24
O>* 2.2.2.2/32 [110/10] via 192.168.1.252, ens33, 00:01:07
O>* 172.16.1.254/32 [110/10] is directly connected, lo, 00:01:24
O>* 172.16.2.254/32 [110/10] is directly connected, lo, 00:01:24
O>* 172.16.3.254/32 [110/10] is directly connected, lo, 00:01:24
O   192.168.1.0/24 [110/10] is directly connected, ens33, 00:01:24
O>* 192.168.11.254/32 [110/10] via 192.168.1.252, ens33, 00:01:07
O>* 192.168.12.254/32 [110/10] via 192.168.1.252, ens33, 00:01:07
O>* 192.168.13.254/32 [110/10] via 192.168.1.252, ens33, 00:01:07
[H3C]display ip routing-table protocol ospf 

Summary count : 9

OSPF Routing table status : <Active>
Summary count : 4

Destination/Mask   Proto   Pre Cost        NextHop         Interface
1.1.1.1/32         O_INTRA 10  11          192.168.1.106   Vlan1
172.16.1.254/32    O_INTRA 10  11          192.168.1.106   Vlan1
172.16.2.254/32    O_INTRA 10  11          192.168.1.106   Vlan1
172.16.3.254/32    O_INTRA 10  11          192.168.1.106   Vlan1

OSPF Routing table status : <Inactive>
Summary count : 5

Destination/Mask   Proto   Pre Cost        NextHop         Interface
2.2.2.2/32         O_INTRA 10  0           0.0.0.0         Loop0
192.168.1.0/24     O_INTRA 10  1           0.0.0.0         Vlan1
192.168.11.254/32  O_INTRA 10  0           0.0.0.0         Loop1
192.168.12.254/32  O_INTRA 10  0           0.0.0.0         Loop2
192.168.13.254/32  O_INTRA 10  0           0.0.0.0         Loop3
[H3C]
[H3C]ping 172.16.1.254
Ping 172.16.1.254 (172.16.1.254): 56 data bytes, press CTRL_C to break
56 bytes from 172.16.1.254: icmp_seq=0 ttl=64 time=1.795 ms
56 bytes from 172.16.1.254: icmp_seq=1 ttl=64 time=1.517 ms
56 bytes from 172.16.1.254: icmp_seq=2 ttl=64 time=1.646 ms
56 bytes from 172.16.1.254: icmp_seq=3 ttl=64 time=1.579 ms
56 bytes from 172.16.1.254: icmp_seq=4 ttl=64 time=1.689 ms

--- Ping statistics for 172.16.1.254 ---
5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss
round-trip min/avg/max/std-dev = 1.517/1.645/1.795/0.095 ms
[H3C]%Jan  1 02:58:30:507 2013 H3C PING/6/PING_STATISTICS: Ping statistics for 172.16.1.254: 5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss, round-trip min/avg/max/std-dev = 1.517/1.645/1.795/0.095 ms.

[H3C]
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zdl244

你的鼓励是我最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值