Add lakewood.united-states
This commit is contained in:
parent
e9a673688b
commit
b0b610689a
360
hosts/lakewood.united-states/main.go
Normal file
360
hosts/lakewood.united-states/main.go
Normal file
@ -0,0 +1,360 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"net/netip"
|
||||
"os"
|
||||
|
||||
"git.redxen.eu/caskd/s6-netdev"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var (
|
||||
err error
|
||||
l = log.New(os.Stderr, "s6-netdev: ", log.Ltime|log.Lshortfile|log.Lmsgprefix)
|
||||
ifs = make(s6netdev.IfMap)
|
||||
)
|
||||
t := s6netdev.S6NewTree()
|
||||
|
||||
// Loopback
|
||||
ifs.AddIf(&s6netdev.Iface{
|
||||
Name: "lo",
|
||||
Type: &s6netdev.NetdevIfTypes.Loopback,
|
||||
})
|
||||
|
||||
// Physical interfaces
|
||||
ifs.AddIf(&s6netdev.Iface{
|
||||
Name: "enp2s0",
|
||||
Type: &s6netdev.NetdevIfTypes.Phys,
|
||||
})
|
||||
ifs.AddIf(&s6netdev.Iface{
|
||||
Name: "enp13s0",
|
||||
Type: &s6netdev.NetdevIfTypes.Phys,
|
||||
})
|
||||
ifs.AddIf(&s6netdev.Iface{
|
||||
Name: "enp16s0",
|
||||
Type: &s6netdev.NetdevIfTypes.Phys,
|
||||
})
|
||||
ifs.AddIf(&s6netdev.Iface{
|
||||
Name: "enp17s0",
|
||||
Type: &s6netdev.NetdevIfTypes.Phys,
|
||||
})
|
||||
ifs.AddIf(&s6netdev.Iface{
|
||||
Name: "enp18s0",
|
||||
Type: &s6netdev.NetdevIfTypes.Phys,
|
||||
})
|
||||
|
||||
// VLAN Interfaces
|
||||
ifs.AddIf(&s6netdev.Iface{
|
||||
Name: "phys.42",
|
||||
Type: &s6netdev.NetdevIfTypes.Vlan,
|
||||
VlanId: 42,
|
||||
})
|
||||
ifs.AddIf(&s6netdev.Iface{
|
||||
Name: "phys.66",
|
||||
Type: &s6netdev.NetdevIfTypes.Vlan,
|
||||
VlanId: 66,
|
||||
})
|
||||
ifs.AddIf(&s6netdev.Iface{
|
||||
Name: "phys.100",
|
||||
Type: &s6netdev.NetdevIfTypes.Vlan,
|
||||
VlanId: 100,
|
||||
})
|
||||
ifs.AddIf(&s6netdev.Iface{
|
||||
Name: "phys.101",
|
||||
Type: &s6netdev.NetdevIfTypes.Vlan,
|
||||
VlanId: 101,
|
||||
})
|
||||
|
||||
// Wireguard interfaces
|
||||
ifs.AddIf(&s6netdev.Iface{
|
||||
Name: "famfo",
|
||||
Type: &s6netdev.NetdevIfTypes.Wireguard,
|
||||
Addresses: []netip.Prefix{netip.MustParsePrefix("fe80::1422:1/64")},
|
||||
Sysctls: s6netdev.Sysctl_IP{
|
||||
V6: []s6netdev.Property{
|
||||
{Key: "forwarding", Value: "1", Default: "0"},
|
||||
},
|
||||
},
|
||||
})
|
||||
ifs.AddIf(&s6netdev.Iface{
|
||||
Name: "mark22k",
|
||||
Type: &s6netdev.NetdevIfTypes.Wireguard,
|
||||
Addresses: []netip.Prefix{netip.MustParsePrefix("fe80::4546/64")},
|
||||
Sysctls: s6netdev.Sysctl_IP{
|
||||
V6: []s6netdev.Property{
|
||||
{Key: "forwarding", Value: "1", Default: "0"},
|
||||
},
|
||||
},
|
||||
})
|
||||
ifs.AddIf(&s6netdev.Iface{
|
||||
Name: "highdef",
|
||||
Type: &s6netdev.NetdevIfTypes.Wireguard,
|
||||
Addresses: []netip.Prefix{netip.MustParsePrefix("fe80::2/64")},
|
||||
Sysctls: s6netdev.Sysctl_IP{
|
||||
V6: []s6netdev.Property{
|
||||
{Key: "forwarding", Value: "1", Default: "0"},
|
||||
},
|
||||
},
|
||||
})
|
||||
ifs.AddIf(&s6netdev.Iface{
|
||||
Name: "kioubit",
|
||||
Type: &s6netdev.NetdevIfTypes.Wireguard,
|
||||
Addresses: []netip.Prefix{netip.MustParsePrefix("fe80::2/64")},
|
||||
Sysctls: s6netdev.Sysctl_IP{
|
||||
V6: []s6netdev.Property{
|
||||
{Key: "forwarding", Value: "1", Default: "0"},
|
||||
},
|
||||
},
|
||||
})
|
||||
ifs.AddIf(&s6netdev.Iface{
|
||||
Name: "lare",
|
||||
Type: &s6netdev.NetdevIfTypes.Wireguard,
|
||||
Addresses: []netip.Prefix{netip.MustParsePrefix("fe80::2/64")},
|
||||
Sysctls: s6netdev.Sysctl_IP{
|
||||
V6: []s6netdev.Property{
|
||||
{Key: "forwarding", Value: "1", Default: "0"},
|
||||
},
|
||||
},
|
||||
})
|
||||
ifs.AddIf(&s6netdev.Iface{
|
||||
Name: "haktron",
|
||||
Type: &s6netdev.NetdevIfTypes.Wireguard,
|
||||
Addresses: []netip.Prefix{netip.MustParsePrefix("fe80::2/64")},
|
||||
Sysctls: s6netdev.Sysctl_IP{
|
||||
V6: []s6netdev.Property{
|
||||
{Key: "forwarding", Value: "1", Default: "0"},
|
||||
},
|
||||
},
|
||||
})
|
||||
ifs.AddIf(&s6netdev.Iface{
|
||||
Name: "vultrbgp",
|
||||
Type: &s6netdev.NetdevIfTypes.Wireguard,
|
||||
Addresses: []netip.Prefix{
|
||||
netip.MustParsePrefix("fe80::2/64"),
|
||||
},
|
||||
Sysctls: s6netdev.Sysctl_IP{
|
||||
V6: []s6netdev.Property{
|
||||
{Key: "forwarding", Value: "1", Default: "0"},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// Bridge interfaces
|
||||
ifs.AddIf(&s6netdev.Iface{
|
||||
Name: "phys",
|
||||
Type: &s6netdev.NetdevIfTypes.Bridge,
|
||||
MACAddr: net.HardwareAddr{0x52, 0x54, 0x00, 0xf4, 0x2b, 0xd1},
|
||||
DHCP: s6netdev.DHCP_IP{V4: true},
|
||||
Properties: []s6netdev.Property{
|
||||
{Key: "stp_state", Value: "1", Default: "0"},
|
||||
{Key: "mcast_snooping", Value: "0", Default: "1"},
|
||||
},
|
||||
Sysctls: s6netdev.Sysctl_IP{
|
||||
V6: []s6netdev.Property{
|
||||
{Key: "forwarding", Value: "0", Default: "0"},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
ifs.AddIf(&s6netdev.Iface{
|
||||
Name: "br-dn42",
|
||||
Type: &s6netdev.NetdevIfTypes.Bridge,
|
||||
Sysctls: s6netdev.Sysctl_IP{
|
||||
V6: []s6netdev.Property{
|
||||
{Key: "forwarding", Value: "1", Default: "0"},
|
||||
},
|
||||
},
|
||||
Properties: []s6netdev.Property{
|
||||
{Key: "stp_state", Value: "0", Default: "0"},
|
||||
{Key: "mcast_snooping", Value: "0", Default: "1"},
|
||||
},
|
||||
})
|
||||
|
||||
ifs.AddIf(&s6netdev.Iface{
|
||||
Name: "b00b",
|
||||
Type: &s6netdev.NetdevIfTypes.Bridge,
|
||||
MACAddr: net.HardwareAddr{0x02, 0x00, 0x00, 0x00, 0xb0, 0x0b},
|
||||
Addresses: []netip.Prefix{
|
||||
netip.MustParsePrefix("2a04:5b81:2060:b00b::1/64"),
|
||||
},
|
||||
Sysctls: s6netdev.Sysctl_IP{
|
||||
V6: []s6netdev.Property{
|
||||
{Key: "forwarding", Value: "1", Default: "0"},
|
||||
{Key: "autoconf", Value: "0", Default: "0"},
|
||||
},
|
||||
},
|
||||
Properties: []s6netdev.Property{
|
||||
{Key: "stp_state", Value: "0", Default: "0"},
|
||||
{Key: "mcast_snooping", Value: "0", Default: "1"},
|
||||
},
|
||||
})
|
||||
ifs.AddIf(&s6netdev.Iface{
|
||||
Name: "f33d",
|
||||
Type: &s6netdev.NetdevIfTypes.Bridge,
|
||||
MACAddr: net.HardwareAddr{0x02, 0x00, 0x00, 0x00, 0xf3, 0x3d},
|
||||
Addresses: []netip.Prefix{
|
||||
netip.MustParsePrefix("2a04:5b81:2060:f33d::1/64"),
|
||||
},
|
||||
Sysctls: s6netdev.Sysctl_IP{
|
||||
V6: []s6netdev.Property{
|
||||
{Key: "forwarding", Value: "1", Default: "0"},
|
||||
{Key: "autoconf", Value: "0", Default: "0"},
|
||||
},
|
||||
},
|
||||
Properties: []s6netdev.Property{
|
||||
{Key: "stp_state", Value: "0", Default: "0"},
|
||||
{Key: "mcast_snooping", Value: "0", Default: "1"},
|
||||
},
|
||||
})
|
||||
ifs.AddIf(&s6netdev.Iface{
|
||||
Name: "d00d",
|
||||
Type: &s6netdev.NetdevIfTypes.Bridge,
|
||||
MACAddr: net.HardwareAddr{0x02, 0x00, 0x00, 0x00, 0xd0, 0x0d},
|
||||
Addresses: []netip.Prefix{
|
||||
netip.MustParsePrefix("2a04:5b81:2060:d00d::1/64"),
|
||||
},
|
||||
Sysctls: s6netdev.Sysctl_IP{
|
||||
V6: []s6netdev.Property{
|
||||
{Key: "forwarding", Value: "1", Default: "0"},
|
||||
{Key: "autoconf", Value: "0", Default: "0"},
|
||||
},
|
||||
},
|
||||
Properties: []s6netdev.Property{
|
||||
{Key: "stp_state", Value: "0", Default: "0"},
|
||||
{Key: "mcast_snooping", Value: "0", Default: "1"},
|
||||
},
|
||||
})
|
||||
|
||||
// VRFs
|
||||
ifs.AddIf(&s6netdev.Iface{
|
||||
Name: "vrf-dn42",
|
||||
Type: &s6netdev.NetdevIfTypes.Vrf,
|
||||
Table: 20,
|
||||
Sysctls: s6netdev.Sysctl_IP{
|
||||
V6: []s6netdev.Property{
|
||||
{Key: "forwarding", Value: "1", Default: "0"},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
ifs.AddIf(&s6netdev.Iface{
|
||||
Name: "vrf-v6",
|
||||
Type: &s6netdev.NetdevIfTypes.Vrf,
|
||||
Table: 10,
|
||||
Sysctls: s6netdev.Sysctl_IP{
|
||||
V6: []s6netdev.Property{
|
||||
{Key: "forwarding", Value: "1", Default: "0"},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
for _, m := range []struct {
|
||||
Master string
|
||||
Slaves []string
|
||||
}{
|
||||
{
|
||||
Master: "vrf-dn42",
|
||||
Slaves: []string{
|
||||
"br-dn42",
|
||||
"famfo",
|
||||
"mark22k",
|
||||
"highdef",
|
||||
"kioubit",
|
||||
"lare",
|
||||
"haktron",
|
||||
},
|
||||
},
|
||||
{
|
||||
Master: "vrf-v6",
|
||||
Slaves: []string{
|
||||
"vultrbgp",
|
||||
"b00b",
|
||||
"f33d",
|
||||
"d00d",
|
||||
},
|
||||
},
|
||||
{
|
||||
Master: "phys",
|
||||
Slaves: []string{
|
||||
"enp13s0",
|
||||
},
|
||||
},
|
||||
{
|
||||
Master: "b00b",
|
||||
Slaves: []string{
|
||||
"enp16s0",
|
||||
"phys.66",
|
||||
},
|
||||
},
|
||||
{
|
||||
Master: "br-dn42",
|
||||
Slaves: []string{
|
||||
"enp2s0",
|
||||
"phys.42",
|
||||
},
|
||||
},
|
||||
{
|
||||
Master: "f33d",
|
||||
Slaves: []string{
|
||||
"enp17s0",
|
||||
"phys.100",
|
||||
},
|
||||
},
|
||||
{
|
||||
Master: "d00d",
|
||||
Slaves: []string{
|
||||
"enp18s0",
|
||||
"phys.101",
|
||||
},
|
||||
},
|
||||
} {
|
||||
master := ifs[m.Master]
|
||||
for _, slave := range m.Slaves {
|
||||
master.Slaves = append(master.Slaves, ifs[slave])
|
||||
}
|
||||
ifs[m.Master] = master
|
||||
}
|
||||
|
||||
// Parent of VLANs
|
||||
for _, v := range []int{42, 66, 100, 101} {
|
||||
ifs[fmt.Sprintf("phys.%d", v)].Parent = ifs["phys"]
|
||||
}
|
||||
|
||||
// Unreachable routes
|
||||
ifs["lo"].Routes = append(ifs["lo"].Routes, s6netdev.Route{
|
||||
Type: "unreachable",
|
||||
Net: netip.MustParsePrefix("2a04:5b81:2060::/44"),
|
||||
Vrf: ifs["vrf-v6"],
|
||||
Metric: 4278198272,
|
||||
}, s6netdev.Route{
|
||||
Type: "unreachable",
|
||||
Default: true,
|
||||
IPver: 6,
|
||||
Vrf: ifs["vrf-dn42"],
|
||||
Metric: 4278198272,
|
||||
})
|
||||
|
||||
// Self-referencing
|
||||
ifs["vultrbgp"].Routes = append(ifs["vultrbgp"].Routes, s6netdev.Route{
|
||||
Default: true,
|
||||
IPver: 6,
|
||||
Vrf: ifs["vrf-v6"],
|
||||
})
|
||||
|
||||
for _, v := range ifs {
|
||||
t.Services(*v)
|
||||
}
|
||||
|
||||
for _, v := range t.S6Services() {
|
||||
if s6netdev.NetdevIsDummy(v.Name) {
|
||||
continue
|
||||
}
|
||||
l.Printf("Commiting %s\n", v.Name)
|
||||
if err = t.S6CommitService(v); err != nil {
|
||||
l.Fatalf("Failed to commit %s, %s\n", v.Name, err)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user