使用tinc+quagga搭建个人SD-WAN网络

简介: 使用tinc+quagga搭建个人SD-WAN网络

使用tinc+quagga搭建个人SD-WAN网络


拓扑如下


640.png

一、tinc安装与配置


1、CentOS7云主机安装tinc

640.jpg


640.jpg

yum install tinc

640.jpg

mkdir -p /etc/tinc/tincnet/
mkdir  /etc/tinc/tincnet/hosts
cd /etc/tinc/tincnet/
ll
vi tinc.conf
Name = Server_Node 
Interface = tinctun 
AddressFamily = ipv4
Mode = switch 
ConnectTo = Slave_Node
Compression=9 
Cipher = aes-256-cbc 
Digest = sha256 
PrivateKeyFile=/etc/tinc/tincnet/rsa_key.priv

640.jpg

vi tinc-up
#!/bin/sh
ip link set $INTERFACE up
ip addr add 10.254.254.2/24 dev $INTERFACE
ip route add 10.254.254.0/24 dev $INTERFACE
vi tinc-down 
#!/bin/sh
ip route del 10.254.254.0/24 dev $INTERFACE
ip addr del 10.254.254.2/24 dev $INTERFACE
ip link set $INTERFACE down
chmod 755 tinc*

640.jpg

cd /etc/tinc/tincnet/hosts
vi Server_Node
Address = 129.211.209.82
Subnet = 10.254.254.2/32
Port = 655

640.jpg


通过tincd生成非对称密钥


#通过tincd生成非对称密钥
tincd -n tincnet -K 4096


640.jpg


2、分支节点安装配置tinc


配置与上面类似,不再赘述,截图如下

640.jpg

640.jpg

640.jpg

640.jpg


3、保证两个节点的hosts文件夹都有全部节点的hosts信息


scp /etc/tinc/tincnet/hosts/Slave_Node root@129.211.209.82:/etc/tinc/tincnet/hosts/
scp root@129.211.209.82:/etc/tinc/tincnet/hosts/Server_Node /etc/tinc/tincnet/hosts

640.jpg


4、配置etc/sysctl.conf文件


net.ipv4.ip_forward = 1

640.jpg

5、防火墙放通655端口

640.jpg

640.jpg


6、启动tinc服务


systemctl start tinc@tincnet
systemctl status tinc@tincnet

640.jpg640.jpg

二、手工静态路由方式实现互访


添加路由前截图



640.jpg


例如分支节点上添加静态路由


route add -net 10.106.0.0/20 dev tinctun


640.jpg


三、安装quagga配置ospf实现互通


1、两节点均安装并配置quagga


yum install quagga
cd /etc/quagga/
cp /usr/share/doc/quagga-0.99.22.4/zebra.conf.sample ./
cp /usr/share/doc/quagga-0.99.22.4/ospfd.conf.sample ./
cp zebra.conf.sample zebra.conf
cp ospfd.conf.sample ospfd.conf
chmod 777 *.conf
chmod 777 /var/log/ospfd/
systemctl enable zebra
systemctl enable ospfd
systemctl start zebra
systemctl start ospfd


640.jpg

640.jpg

2、vtysh进行配置ospf

640.jpg

主节点配置步骤如下

VM-0-17-centos# conf t
VM-0-17-centos(config)# interface  eth0
VM-0-17-centos(config-if)# description  Server_eth0
VM-0-17-centos(config-if)# no shut
VM-0-17-centos(config-if)# exit
VM-0-17-centos(config)# interface  tinctun
VM-0-17-centos(config-if)# description  Server_tinctun
VM-0-17-centos(config-if)# no shut
VM-0-17-centos(config-if)# exit
VM-0-17-centos(config)# router ospf 
VM-0-17-centos(config-router)# router-id  1.1.1.1
VM-0-17-centos(config-router)# network  10.254.254.0/24 area 0
VM-0-17-centos(config-router)# network  10.206.0.17/20  area 0
VM-0-17-centos(config-router)# exit
VM-0-17-centos(config)# log file /var/log/quagga/ospfd.log
VM-0-17-centos(config)# exit
VM-0-17-centos# wr
Building Configuration...
Configuration saved to /etc/quagga/zebra.conf
Configuration saved to /etc/quagga/ospfd.conf
[OK]


640.jpg

分支节点配置步骤如下 vtysh


Hello, this is Quagga (version 0.99.22.4).
Copyright 1996-2005 Kunihiro Ishiguro, et al.
centos.walkingcloud.cn# conf t
centos.walkingcloud.cn(config)# interface  ens33
centos.walkingcloud.cn(config-if)# description  Slave_ens33
centos.walkingcloud.cn(config-if)# no shut
centos.walkingcloud.cn(config-if)# exit
centos.walkingcloud.cn(config)# interface tinctun
centos.walkingcloud.cn(config-if)# description  Slave_tinctun
centos.walkingcloud.cn(config-if)# no shut
centos.walkingcloud.cn(config-if)# exit
centos.walkingcloud.cn(config)# 
centos.walkingcloud.cn(config)# exit
centos.walkingcloud.cn# conf t
centos.walkingcloud.cn(config)# router ospf 
centos.walkingcloud.cn(config-router)# router-id  2.2.2.2
centos.walkingcloud.cn(config-router)# network  192.168.31.0/24 area  0
centos.walkingcloud.cn(config-router)# network  10.254.254.0/24 area 0
centos.walkingcloud.cn(config-router)# network 192.168.1.1/24 area 0
centos.walkingcloud.cn(config-router)# exit
centos.walkingcloud.cn(config)# log file  /var/log/quagga/ospfd.log
centos.walkingcloud.cn(config)# exit
centos.walkingcloud.cn# wr
Building Configuration...
Configuration saved to /etc/quagga/zebra.conf
[OK]
centos.walkingcloud.cn# exit


640.jpg


3、防火墙放通ospf协议


firewall-cmd --permanent --zone=public --add-protocol=ospf
firewall-cmd --reload


并重启ospf和zebra服务


systemctl restart zebra
systemctl restart ospfd

640.jpg

4、ospf状态检查


可以用vtysh中 show ip ospf neighbor检查邻居是否建立

show ip route查看对方是否学习到对方的ospf路由


show ip ospf neighbor
show ip route

640.jpg


640.jpg

5、最后进行连通性测试

640.jpg

640.jpg


四、总结


  • 1、本文只是测试使用quagga并使用ospf协议,实际中为了简单起见,可以直接使用静态路由即可
  • 2、当然个人家庭网络中不会把Linux服务器作为出口路由使用,可以openwrt路由器安装tinc来实现
相关文章
|
Kubernetes Cloud Native 网络安全
【云原生-K8s】kubeadm搭建k8s集群1.25版本完整教程【docker、网络插件calico、中间层cri-docker】
【云原生-K8s】kubeadm搭建k8s集群1.25版本完整教程【docker、网络插件calico、中间层cri-docker】
2425 0
【云原生-K8s】kubeadm搭建k8s集群1.25版本完整教程【docker、网络插件calico、中间层cri-docker】
|
4月前
|
监控 安全 网络安全
使用 Fortinet 安全 SD-WAN 解决方案进行全球跨国公司网络设计的最佳实践
使用 Fortinet 安全 SD-WAN 解决方案进行全球跨国公司网络设计的最佳实践
182 3
|
4月前
|
安全 网络性能优化 调度
SD-WAN 网络编排原理
【2月更文挑战第29天】网络编排是解决传统WAN部署复杂、耗时问题的关键技术,它通过策略驱动自动化协调硬件和软件资源。
|
消息中间件 监控 NoSQL
ELK搭建(三):监控服务器CPU、网络、磁盘、内存指标
本期我们来讲解如何通过ELK+metricbeat来监控服务器/主机中的CPU、网络、磁盘、内存等指标变化。并绘制会数据看板来方便我们实时监控
540 0
ELK搭建(三):监控服务器CPU、网络、磁盘、内存指标
|
机器学习/深度学习 数据挖掘 PyTorch
|
消息中间件 NoSQL 前端开发
云计算搭建全部内容总结,保证可以搭建一个完整的云计算服务器,包括节点安装、实例的分配和网络的配置等内容
云计算搭建全部内容总结,保证可以搭建一个完整的云计算服务器,包括节点安装、实例的分配和网络的配置等内容
351 0
云计算搭建全部内容总结,保证可以搭建一个完整的云计算服务器,包括节点安装、实例的分配和网络的配置等内容
|
TensorFlow 算法框架/工具 Python
【图像分类】TensorFlow2.7版本搭建NIN网络
注解:这里为了简单起见,只是模拟NIN网络结构,本代码只是采用3个mlpconv层和最终的全局平均池化输出层,每个mlpconv层中包含了3个1*1卷积层
126 0
【图像分类】TensorFlow2.7版本搭建NIN网络
|
安全 网络协议 网络安全
从 WAN 到 SD-WAN 边缘设备的网络架构
如今的应用程序和网络架构需要一种新的的方法,云、虚拟化和即服务模型的出现颠覆了传统的企业网络。在这个多云世界中,组织被迫重新考虑如何设计广域网以连接和统一分散的站点。
166 0
从 WAN 到 SD-WAN 边缘设备的网络架构
|
Web App开发 网络协议 安全
重学网络系列之(搭建Http实验环境)
前言 文本已收录至我的GitHub仓库,欢迎Star:github.com/bin39232820… 种一棵树最好的时间是十年前,其次是现在
194 0
|
弹性计算 网络协议 安全
ECS搭建企业级的专用网络隧道
现在很多企业都有移动办公的需求,希望出差员工,如同在公司内部一样可以访问公司的相关资源,很多企业直接购买商业VPN产品或者通过购买防火墙内的SCVPN授权方式满足此需求,在本章节将用开源软件OpenVPN实现此功能。
2160 0
ECS搭建企业级的专用网络隧道