CentOS7安装FRRouting使用BGP解决虚拟网卡互通
FRRouting(frr)是一个路由软件套件,它衍生自Quagga,它为类Unix平台提供了所有主要路由协议的实现,这里使用两台CentOS7使用BGP协议解决network namespace的虚拟网卡互通问题
拓扑
系统配置
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
本站所有文章均可随意转载,转载时请保留原文链接及作者。