Revision 393330323063 () - Diff

Link to this snippet: https://friendpaste.com/4zrXvdx1l5fjDRG1oheHMN
Embed:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# REQUIRE: netif
# PROVIDE: netgraph
# BEFORE: routing

. /etc/rc.subr

name="netgraph"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
HOST_IP="XXX::11/64"
ETHER_IF="ixl2"

netgraph_start() {
# Ensure the kernel modules are loaded
kldload ng_bridge ng_eiface ng_ether

# Create the graph
ngctl -f- <<EOF
mkpeer ${ETHER_IF}: vlan lower downstream
name ${ETHER_IF}:lower vlan0
mkpeer vlan0: bridge 204 link0
mkpeer vlan0: bridge nomatch link0
msg vlan0: addfilter { vid=204 hook="204" }
name vlan0:204 wg
name vlan0:nomatch public
msg ixl2: setpromisc 1
msg ixl2: setautosrc 0
EOF

ngctl mkpeer public: eiface link2 ether
ifconfig ngeth0 inet6 ${HOST_IP} auto_linklocal up
ifconfig ngeth0 media 10Gbase-T mediaopt full-duplex



}

netgraph_stop() {
ngctl shutdown vlan0:
ngctl shutdown wg:
ngctl shutdown public:
}

load_rc_config $name
run_rc_command "$1"