Forked from zimmertr/BGP MetalLB Ubiquiti Edgerouter 2019
Created
January 6, 2021 23:37
-
-
Save Roman-Blinkov/d06b2ec5dc788d3d5e97cecb4608a7ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Apply the metallb manifests to Kubernetes | |
kubectl apply -f https://raw.githubusercontent.com/google/metallb/v0.8.1/manifests/metallb.yaml | |
# Apply a metallb configuration to Kubernetes | |
cat <<EOF | kubectl apply -f - | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
namespace: metallb-system | |
name: config | |
data: | |
config: | | |
peers: | |
- peer-address: 192.168.1.1 | |
peer-asn: 64512 | |
my-asn: 64512 | |
address-pools: | |
- name: default | |
protocol: bgp | |
addresses: | |
- 192.168.60.0/24 | |
EOF | |
# Configure the Edgerouter | |
configure | |
# Enabling hardware offloading to improve VLAN-trunked client speed | |
set system offload ipv4 forwarding enable | |
set system offload ipv4 gre enable | |
set system offload ipv4 pppoe enable | |
set system offload ipv4 vlan enable | |
set system offload ipv4 bonding enable | |
set system offload ipv6 forwarding enable | |
set system offload ipv6 pppoe enable | |
set system offload ipv6 vlan enable | |
set system offload ipsec enable | |
# Configure Kubernetes worker nodes to be BGP neighbors. | |
# Be sure to ensure that these IP Addresses are the primary addresses on the eth0 NIC. | |
# If DHCP messed this up (it probably will) Do the following. BE SURE TO DO SO BEFORE KUBELET IS INITALIZED OR KUBERNETES WILL BREAK. | |
# sudo vim /etc/network/interfaces && sudo update-rc.d -f dhcpd remove && sudo ip addr flush dev eth0 | |
# | |
# iface eth0 inet static | |
# address 192.168.40.100/24 | |
# gateway 192.168.40.1 | |
# dns-nameservers 192.168.1.100 192.168.1.110 | |
# dns-domain sol.milkyway | |
# | |
# iface eth0 inet static | |
# address 192.168.40.101/24 | |
# gateway 192.168.40.1 | |
# dns-nameservers 192.168.1.100 192.168.1.110 | |
# dns-domain sol.milkyway | |
# | |
# iface eth0 inet static | |
# address 192.168.40.102/24 | |
# gateway 192.168.40.1 | |
# dns-nameservers 192.168.1.100 192.168.1.110 | |
# dns-domain sol.milkyway | |
set protocols bgp 64512 parameters router-id 192.168.1.1 | |
set protocols bgp 64512 neighbor 192.168.40.224 remote-as 64512 | |
set protocols bgp 64512 neighbor 192.168.40.225 remote-as 64512 | |
set protocols bgp 64512 neighbor 192.168.40.226 remote-as 64512 | |
set protocols bgp 64512 redistribute static | |
# Configure the Debian Wheezy package repository | |
set system package repository wheezy components 'main contrib non-free' | |
set system package repository wheezy distribution wheezy | |
set system package repository wheezy url http://archive.debian.org/debian | |
commit; save | |
exit | |
# Confirm that a BGP relationship has been established. | |
sleep 10 | |
show ip bgp neighbors | grep state | |
# Set up mDNS for Airplay -> AVR Receiver across VLANs | |
configure | |
set service mdns repeater interface eth1.3 | |
set service mdns repeater interface eth1.60 | |
commit; save | |
# Update package repositories and install some nice-to-have packages | |
apt-get update | |
apt-get install vnstat vim wget -y | |
# Stop vnstat and configure it. | |
/etc/init.d/vnstat stop | |
mkdir /var/log/vnstat | |
mkdir -p /config/tj/vnstat | |
sed -i 's/\/var\/lib\/vnstat/\/var\/log\/vnstat/' /etc/vnstat.conf | |
sed -i 's/MaxBandwidth\ 100/MaxBandwidth\ 0/' /etc/vnstat.conf | |
# Set up vnstat-php web frontend. | |
wget http://www.sqweek.com/sqweek/files/vnstat_php_frontend-1.5.1.tar.gz -O /config/tj/vnstat/vnstat.tar.gz | |
tar -xzvf /config/tj/vnstat/vnstat.tar.gz -C /config/tj/vnstat/ | |
rm /config/tj/vnstat/vnstat.tar.gz | |
mv /config/tj/vnstat/vnstat_php_frontend-1.5.1/* /config/tj/vnstat/ | |
rm -rf /config/tj/vnstat/vnstat_php_frontend-1.5.1 | |
sed -i "s/\$locale\ =\ 'en_US.UTF-8';//" /config/tj/vnstat/config.php | |
sed -i "`wc -l < /config/tj/vnstat/config.php`i\\ \$locale = 'en_US.UTF-8'; $language = 'en'; date_default_timezone_set('America/Los_Angeles');" /config/tj/vnstat/config.php | |
ln -s /config/tj/vnstat/ /var/www/htdocs/stat | |
echo "" >> /etc/lighttpd/lighttpd.conf | |
echo 'url.rewrite-once = ( "^/stat/(.*)" => "/stat/$1", "^(/(lib|media|ws|tests)/.*)" => "$0", "^/([^\?]+)' >> /etc/lighttpd/lighttpd.conf | |
# Reboot the router to apply the changes | |
reboot | |
# Troubleshooting tips | |
#set protocols bgp 64512 parameters log-neighbor-changes | |
#debug bgp | |
#tail -F /var/log/messages |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment