diff options
-rwxr-xr-x | bin/config.awk | 2 | ||||
-rwxr-xr-x | bin/mkwgconfig.sh | 2 | ||||
-rwxr-xr-x | inet2.initd | 11 | ||||
-rwxr-xr-x | setup.sh | 32 |
4 files changed, 28 insertions, 19 deletions
diff --git a/bin/config.awk b/bin/config.awk index f4833ae..9d0a117 100755 --- a/bin/config.awk +++ b/bin/config.awk @@ -1,4 +1,4 @@ -#!/run/current-system/profile/bin/awk -f +#!/usr/bin/awk -f BEGIN { FS = "[ ]"; # use a single space as field separator and don't trim input diff --git a/bin/mkwgconfig.sh b/bin/mkwgconfig.sh index 3afa221..dcbb98f 100755 --- a/bin/mkwgconfig.sh +++ b/bin/mkwgconfig.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/bin/sh # args: /path/to/interface-config /path/to/output.conf inter="$1" diff --git a/inet2.initd b/inet2.initd index 7824bdc..5fe8c7c 100755 --- a/inet2.initd +++ b/inet2.initd @@ -25,7 +25,18 @@ runscripts() { fi } + + start() { + + for file in /sys/class/net/*; do # Clear all wireguard interfaces + type=$(cat "$file/type") + if [ "$type" = "65534" ]; then + ifname="$(basename $file)" + ip link del "$ifname" + fi + done + rm -rf /run/inet2/config 2>/dev/null rm -rf /run/inet2/wg 2>/dev/null cp /config/inet2.conf /run/inet2/inet2.conf @@ -39,7 +39,7 @@ run sysctl net.ipv6.conf.all.disable_ipv6=0 net.ipv6.conf.default.disable_ipv6=0 ospf="$(haskey OSPF)" escapebird() { - sed -e 's/\\/\\\\/g;s/"/\\"/g' + sed -e 's/\\/\\\\/g;s/"/\\"/g' } if [ -n "$ospf" ]; then @@ -47,7 +47,7 @@ if [ -n "$ospf" ]; then touch /var/log/bird.log chown bird:bird /var/log/bird.log - + selfas=$(getval AS) ( cat <<EOF @@ -56,21 +56,13 @@ log "/var/log/bird.log" all; $(getval RouterID | while read -r line; do echo "router id $line;"; done) protocol kernel { - ipv4 { - export filter { if source ~ [RTS_BGP, RTS_OSPF, RTS_OSPF_IA, RTS_OSPF_EXT1, RTS_OSPF_EXT2] then accept; else reject; }; - import all; - }; - learn; - scan time 10; + ipv4 { export all; }; } + protocol kernel { - ipv6 { - export filter { if source ~ [RTS_BGP, RTS_OSPF, RTS_OSPF_IA, RTS_OSPF_EXT1, RTS_OSPF_EXT2] then accept; else reject; }; - import all; - }; - learn; - scan time 10; + ipv6 { export all; }; } + protocol device { } @@ -79,6 +71,9 @@ protocol direct { ipv6; } +protocol static { + ipv4; +} EOF if [ -n "$ospf" ]; then @@ -89,6 +84,7 @@ EOF val="$(getval "interface $inter" OSPF)" if [ "$?" = "0" ]; then echo " interface \"$(printf "%s" "$inter" | escapebird)\" {" + echo " type ptp;" if [ -n "$val" ]; then echo " $val;"; fi @@ -102,19 +98,21 @@ EOF protocol ospf v3 ospf4 { ipv4 { import all; - export filter { if source ~ [RTS_DEVICE, RTS_INHERIT] then accept; else reject; }; + export filter { if source ~ [RTS_DEVICE, RTS_INHERIT] && net ~ [$(getval "Subnet" | grep -v ':' | while read -r line; do printf "%s+," "$line"; done | sed 's/,$//')] then accept; else reject; }; }; $interfacelist } protocol ospf v3 ospf6 { ipv6 { import all; - export filter { if source ~ [RTS_DEVICE, RTS_INHERIT] then accept; else reject; }; + export filter { if source ~ [RTS_DEVICE, RTS_INHERIT] && net ~ [$(getval "Subnet" | grep ':' | while read -r line; do printf "%s+," "$line"; done | sed 's/,$//')] then accept; else reject; }; }; $interfacelist } EOF - ) > /etc/bird.conf + fi +) > /etc/bird.conf + chown root:bird /etc/bird.conf chmod 640 /etc/bird.conf |