This commit is contained in:
Alex D. 2023-09-03 10:47:28 +00:00
parent cc62fe6dad
commit 93cccc63fa
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
3 changed files with 90 additions and 71 deletions

14
generic.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/sh
. "$(dirname -- "$0")/netdev.sh"
new_if_phys "eth0"
IFACE="br0"
new_if_bridge "$IFACE"
bridge_property 'stp_state' "$IFACE"
bridge_property 'mcast_router' "$IFACE"
bridge_property 'mcast_snooping' "$IFACE" '0' ''
bridge_property 'mcast_querier' "$IFACE"
bridge_property 'mcast_mld_version' "$IFACE" '2' ''
new_if_slave "$IFACE" "eth0"

View File

@ -259,7 +259,7 @@ EOF
echo 'wg setconf $INTERFACE $CONFIG'
) rc/"$sname"/up
install -Dm644 <(echo oneshot) rc/"$sname"/type
install -Dm644 /dev/null rc/"$sname"/dependencies.d/"interface.$if.create"
install -Dm644 /dev/null rc/"$sname"/dependencies.d/interface."$if".create
install -Dm644 <(echo "/etc/wireguard/$if") env/"$sname"/CONFIG
}
@ -309,7 +309,6 @@ new_if_vlan() {
install -Dm644 /dev/null rc/"$sname"/dependencies.d/module.8021q
new_link "$if"
install -Dm644 /dev/null rc/interface."$if".link/dependencies.d/interface."$parent".link
}
addr_v6_static_if() {
@ -355,7 +354,7 @@ route_v6_vrf_default_if() {
) rc/"$sname"/down
install -Dm644 <(echo oneshot) rc/"$sname"/type
install -Dm644 /dev/null rc/"$sname"/dependencies.d/interface."$vrf".create
install -Dm644 /dev/null rc/"$sname"/dependencies.d/interface."$if".create
install -Dm644 /dev/null rc/"$sname"/dependencies.d/interface."$if".link
}
route_v6_vrf_default_unreach() {
@ -373,7 +372,7 @@ route_v6_vrf_default_unreach() {
echo 'ip -6 route del unreachable default vrf $INTERFACE'
) rc/"$sname"/down
install -Dm644 <(echo oneshot) rc/"$sname"/type
install -Dm644 /dev/null rc/"$sname"/dependencies.d/"interface.$if.create"
install -Dm644 /dev/null rc/"$sname"/dependencies.d/interface."$if".create
}
route_v6_vrf_sink_unreach() {
@ -393,5 +392,5 @@ route_v6_vrf_sink_unreach() {
echo 'ip -6 route del unreachable $ADDR vrf $INTERFACE'
) rc/"$sname"/down
install -Dm644 <(echo oneshot) rc/"$sname"/type
install -Dm644 /dev/null rc/"$sname"/dependencies.d/"interface.$if.create"
install -Dm644 /dev/null rc/"$sname"/dependencies.d/interface."$if".create
}

138
router.sh
View File

@ -5,9 +5,11 @@
# Physical
new_if_phys "phys0"
new_if_phys "phys1"
IFACE="phys2"
new_if_phys "phys2"
new_if_vlan "phys2-42"
new_if_vlan "phys2-66"
new_if_vlan "$IFACE-42"
new_if_vlan "$IFACE-66"
new_if_phys "phys3"
# Virtual
@ -18,56 +20,79 @@ new_if_phys "vnet3"
new_if_phys "vnet4"
new_if_phys "vnet5"
# VRFs
IFACE="vrf-dn42"
new_if_vrf "$IFACE" 20
route_v6_vrf_default_unreach "$IFACE"
new_if_slave "$IFACE" "br-dn42"
new_if_slave "$IFACE" "famfo"
new_if_slave "$IFACE" "mark22k"
new_if_slave "$IFACE" "highdef"
new_if_slave "$IFACE" "kioubit"
new_if_slave "$IFACE" "lare"
new_if_slave "$IFACE" "vnet5"
IFACE="vrf-v6"
new_if_vrf "$IFACE" 10
route_v6_vrf_default_if "$IFACE" "intersix"
route_v6_vrf_sink_unreach "$IFACE" "2a04:5b81:2060::/48"
new_if_slave "$IFACE" "intersix"
new_if_slave "$IFACE" "b00b"
new_if_slave "$IFACE" "f33d"
new_if_slave "$IFACE" "d00d"
# Bridges
new_if_bridge "home"
bridge_property 'stp_state' "home"
bridge_property 'mcast_snooping' "home"
bridge_property 'mcast_querier' "home"
bridge_property 'mcast_querier_interval' "home" '120' ''
bridge_property 'mcast_stats_enabled' "home"
bridge_property 'mcast_mld_version' "home" '2' ''
new_forward "home"
new_if_slave "home" "vnet1"
new_if_slave "home" "phys3"
new_if_slave "home" "phys2"
IFACE="home"
new_if_bridge "$IFACE"
bridge_property 'stp_state' "$IFACE"
bridge_property 'mcast_router' "$IFACE"
bridge_property 'mcast_snooping' "$IFACE" '0' '' # TODO: Remove such entries when bridges play well with multicasting
bridge_property 'mcast_querier' "$IFACE"
bridge_property 'mcast_mld_version' "$IFACE" '2' ''
new_forward "$IFACE"
new_if_slave "$IFACE" "vnet1"
new_if_slave "$IFACE" "phys3"
new_if_slave "$IFACE" "phys2"
new_if_bridge "br-dn42"
new_if_slave "br-dn42" "phys2-42"
IFACE="br-dn42"
new_if_bridge "$IFACE"
new_if_slave "$IFACE" "phys2-42"
new_if_bridge "f33d"
bridge_property 'stp_state' "f33d"
bridge_property 'mcast_snooping' "f33d"
bridge_property 'mcast_querier' "f33d"
bridge_property 'mcast_querier_interval' "f33d" '120' ''
bridge_property 'mcast_stats_enabled' "f33d"
bridge_property 'mcast_mld_version' "f33d" '2' ''
if_lladdress "f33d" '02:00:00:00:f3:3d'
addr_v6_static_if "f33d" "2a04:5b81:2060:f33d::1/64"
new_if_slave "f33d" "vnet2"
IFACE="f33d"
new_if_bridge "$IFACE"
bridge_property 'stp_state' "$IFACE"
bridge_property 'mcast_router' "$IFACE"
bridge_property 'mcast_snooping' "$IFACE" '0' ''
bridge_property 'mcast_querier' "$IFACE"
bridge_property 'mcast_mld_version' "$IFACE" '2' ''
if_lladdress "$IFACE" '02:00:00:00:f3:3d'
addr_v6_static_if "$IFACE" "2a04:5b81:2060:f33d::1/64"
new_if_slave "$IFACE" "vnet2"
new_if_bridge "b00b"
bridge_property 'stp_state' "b00b"
bridge_property 'mcast_snooping' "b00b"
bridge_property 'mcast_querier' "b00b"
bridge_property 'mcast_querier_interval' "b00b" '120' ''
bridge_property 'mcast_stats_enabled' "b00b"
bridge_property 'mcast_mld_version' "b00b" '2' ''
if_lladdress "b00b" '02:00:00:00:b0:0b'
addr_v6_static_if "b00b" "2a04:5b81:2060:b00b::1/64"
new_if_slave "b00b" "vnet0"
new_if_slave "b00b" "vnet4"
new_if_slave "b00b" "phys2-66"
IFACE="b00b"
new_if_bridge "$IFACE"
bridge_property 'stp_state' "$IFACE"
bridge_property 'mcast_router' "$IFACE"
bridge_property 'mcast_snooping' "$IFACE" '0' ''
bridge_property 'mcast_querier' "$IFACE"
bridge_property 'mcast_stats_enabled' "$IFACE"
bridge_property 'mcast_mld_version' "$IFACE" '2' ''
if_lladdress "$IFACE" '02:00:00:00:b0:0b'
addr_v6_static_if "$IFACE" "2a04:5b81:2060:b00b::1/64"
new_if_slave "$IFACE" "vnet0"
new_if_slave "$IFACE" "vnet4"
new_if_slave "$IFACE" "phys2-66"
new_if_bridge "d00d"
bridge_property 'stp_state' "d00d"
bridge_property 'mcast_snooping' "d00d"
bridge_property 'mcast_querier' "d00d"
bridge_property 'mcast_querier_interval' "d00d" '120' ''
bridge_property 'mcast_stats_enabled' "d00d"
bridge_property 'mcast_mld_version' "d00d" '2' ''
if_lladdress "d00d" '02:00:00:00:d0:0d'
addr_v6_static_if "d00d" "2a04:5b81:2060:d00d::1/64"
new_if_slave "d00d" "vnet3"
IFACE="d00d"
new_if_bridge "$IFACE"
bridge_property 'stp_state' "$IFACE"
bridge_property 'mcast_router' "$IFACE"
bridge_property 'mcast_snooping' "$IFACE" '0' ''
bridge_property 'mcast_querier' "$IFACE"
bridge_property 'mcast_mld_version' "$IFACE" '2' ''
if_lladdress "$IFACE" '02:00:00:00:d0:0d'
addr_v6_static_if "$IFACE" "2a04:5b81:2060:d00d::1/64"
new_if_slave "$IFACE" "vnet3"
# Wireguard
new_if_wg "famfo"
@ -83,22 +108,3 @@ new_if_wg "lare"
new_if_wg "intersix"
addr_v6_static_if "intersix" "fe80::2/64"
addr_v6_static_if "intersix" "2a04:5b80:ffff:ff0b::2/64"
# VRFs
new_if_vrf "vrf-dn42" 20
route_v6_vrf_default_unreach "vrf-dn42"
new_if_slave "vrf-dn42" "br-dn42"
new_if_slave "vrf-dn42" "famfo"
new_if_slave "vrf-dn42" "mark22k"
new_if_slave "vrf-dn42" "highdef"
new_if_slave "vrf-dn42" "kioubit"
new_if_slave "vrf-dn42" "lare"
new_if_slave "vrf-dn42" "vnet5"
new_if_vrf "vrf-v6" 10
route_v6_vrf_default_if "vrf-v6" "intersix"
route_v6_vrf_sink_unreach "vrf-v6" "2a04:5b81:2060::/48"
new_if_slave "vrf-v6" "intersix"
new_if_slave "vrf-v6" "b00b"
new_if_slave "vrf-v6" "f33d"
new_if_slave "vrf-v6" "d00d"