当前位置:首页 > 系统 > CentOS7安装FRRouting使用BGP解决虚拟网卡互通

CentOS7安装FRRouting使用BGP解决虚拟网卡互通

系统3年前 (2020-12-22)

CentOS7安装FRRouting使用BGP解决虚拟网卡互通

FRRouting(frr)是一个路由软件套件,它衍生自Quagga,它为类Unix平台提供了所有主要路由协议的实现,这里使用两台CentOS7使用BGP协议解决network namespace的虚拟网卡互通问题


拓扑

CentOS7安装FRRouting使用BGP解决虚拟网卡互通


系统配置

hostnamectl --static set-hostname R1 && su
setenforce 0 && sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/' /etc/selinux/config
systemctl stop firewalld.service && systemctl disable firewalld.service && systemctl status firewalld.service
yum install git autoconf automake libtool make readline-devel texinfo net-snmp-devel groff pkgconfig json-c-devel pam-devel bison flex pytest c-ares-devel python-devel systemd-devel python-sphinx libcap-devel wget net-tools -y

sed -i "s#^net.ipv4.ip_forward.*#net.ipv4.ip_forward=1#g"  /etc/sysctl.conf
sed -i "s#^net.bridge.bridge-nf-call-ip6tables.*#net.bridge.bridge-nf-call-ip6tables=1#g"  /etc/sysctl.conf
sed -i "s#^net.bridge.bridge-nf-call-iptables.*#net.bridge.bridge-nf-call-iptables=1#g"  /etc/sysctl.conf
sed -i "s#^net.ipv6.conf.all.disable_ipv6.*#net.ipv6.conf.all.disable_ipv6=1#g"  /etc/sysctl.conf
sed -i "s#^net.ipv6.conf.default.disable_ipv6.*#net.ipv6.conf.default.disable_ipv6=1#g"  /etc/sysctl.conf
sed -i "s#^net.ipv6.conf.lo.disable_ipv6.*#net.ipv6.conf.lo.disable_ipv6=1#g"  /etc/sysctl.conf
sed -i "s#^net.ipv6.conf.all.forwarding.*#net.ipv6.conf.all.forwarding=1#g"  /etc/sysctl.conf
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
echo "net.bridge.bridge-nf-call-ip6tables = 1" >> /etc/sysctl.conf
echo "net.bridge.bridge-nf-call-iptables = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.default.disable_ipv6 = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.lo.disable_ipv6 = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.all.forwarding = 1"  >> /etc/sysctl.conf
sysctl -p


安装frr

curl -O https://rpm.frrouting.org/repo/frr-7-repo-1-0.el7.noarch.rpm
yum install frr-7-repo-1-0.el7.noarch.rpm -y
yum install frr frr-pythontools -y

sed -i "s/=no/=yes/g" /etc/frr/daemons
systemctl enable frr && systemctl start frr && systemctl status frr
netstat -anp | grep bgpd


配置虚拟网卡和网桥

R1

ip netns add ns1
ip link add veth1 type veth peer name eth0 netns ns1
ip netns exec ns1 ip link set lo up
ip netns exec ns1 ip link set eth0 up
ip netns exec ns1 ip addr add 1.1.1.1/24 dev eth0
ip netns exec ns1 ip route add default via 1.1.1.254 dev eth0
ip link set veth1 up
ip link add br1 type bridge
ip link set br1 up
ip link set veth1 master br1
ip addr add 1.1.1.254/24 dev br1
ip netns exec ns1 ifconfig -a

R2

ip netns add ns1
ip link add veth1 type veth peer name eth0 netns ns1
ip netns exec ns1 ip link set lo up
ip netns exec ns1 ip link set eth0 up
ip netns exec ns1 ip addr add 2.2.2.2/24 dev eth0
ip netns exec ns1 ip route add default via 2.2.2.254 dev eth0
ip link set veth1 up
ip link add br1 type bridge
ip link set br1 up
ip link set veth1 master br1
ip addr add 2.2.2.254/24 dev br1
ip netns exec ns1 ifconfig -a


frr bgp配置

R1

vtysh
config t
router bgp 57000
bgp router-id 192.168.3.210
neighbor 192.168.3.220 remote-as 57001
network 1.1.1.0/24
exit
do write

R2

vtysh
config t
router bgp 57001
bgp router-id 192.168.3.220
neighbor 192.168.3.210 remote-as 57000
network 2.2.2.0/24
exit
do write


本站所有文章均可随意转载,转载时请保留原文链接及作者。

本文链接:https://www.vos.cn/os/470.html

相关文章

修复升级EVE-NG后无法正常打开问题

修复升级EVE-NG后无法正常打开问题

升级流程Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.9.40-eve-ng-ukms+ x86_64) * Documentation:  ...

解决SecureCRT连接linux无配色

解决SecureCRT连接linux无配色

SecureCRT默认ssh连接linux是无配色的,看起来很难受左侧选中需要调整的会话名称->右键->Properties ->Session Options -> Term...

CentOS7 搭建LNMP

CentOS7 搭建LNMP

使用CentOS 1708,其实就是RHEL 7.4,使用YUM搭建LNMP环境(Linux、Nginx、MariaDB、PHP),全部使用新版组件,比如Nginx 1.12.2、MariaDB 10...

CentOS 7转换为OEL 7

CentOS 7转换为OEL 7

参考官方提供的脚本,支持将CentOS 5, 6, 7转换为使用UEK(Unbreakable Enterprise Kernel)的Oracle Enterprise Linux转换系统curl&n...

RHEL6.5修复LVM错误

RHEL6.5修复LVM错误

RHEL6.5启动出现UNEXPECTED INCONSISTENCY RUN fsck MANUALLY,无法正常进入系统输入ROOT密码后然后输入init 0关机虚拟机“电源”--“打开电源时进入...

输入正确root密码弹出跳回登录界面

输入正确root密码弹出跳回登录界面

服务器安装的版本为64位的RHEL 6.5,运行完rac脚本后重启,发现本地root无法登陆,输入正确的用户名密码后,回弹到原登录界面,但是SSH可正常登录。运行安装Oracle RAC环境配置脚本过...