kayos@tcp.direct b673da7b39 | ||
---|---|---|
cmd | ||
.gitignore | ||
LICENSE | ||
README.md | ||
errors.go | ||
go.mod | ||
go.sum | ||
ifaces.go | ||
ifaces_test.go | ||
netif.go | ||
netif_test.go | ||
util.go |
ifupdown
golang library for working with network interfaces defined via ifupdown.
commonly recognized as /etc/network/interfaces
.
library
features
- read+parse interfaces file
- write interfaces file
- validate interfaces file (basic)
- validate interfaces file (thorough)
- translate interfaces file to JSON
- translate JSON to interfaces file
cmd
ifup2json
- translate interfaces file to JSONjson2ifup
- translate JSON to interfaces file
example usage
ifup2json
cat /etc/network/interfaces | ifup2json
{
"eth2": {
"name": "eth2",
"auto": true,
"address": "192.168.69.5",
"netmask": "////AA==",
"gateway": "192.168.69.1",
"config": 3,
"version": 1,
"hooks": {
"pre_up": [
"echo yeet"
],
"post_down": [
"echo yeeted"
]
}
},
"lo": {
"name": "lo",
"auto": true,
"config": 1,
"version": 1,
"hooks": {}
},
"ns3": {
"name": "ns3",
"auto": true,
"address": "10.9.0.6",
"netmask": "////AAAAAAAAAAAAAAAAAA==",
"config": 3,
"version": 1,
"hooks": {
"pre_up": [
"ip link add dev ns3 type wireguard"
],
"post_up": [
"wg setconf ns3 /etc/wireguard/ns3.conf"
]
}
}
}
json2ifup
cat /etc/network/interfaces | ifup2json | json2ifup
auto eth2
iface eth2 inet static
address 192.168.69.5
netmask 255.255.255.0
gateway 192.168.69.1
pre-up echo yeet
post-down echo yeeted
auto lo
iface lo inet loopback
auto ns3
iface ns3 inet static
address 10.9.0.6
netmask 255.255.255.0
pre-up ip link add dev ns3 type wireguard
post-up wg setconf ns3 /etc/wireguard/ns3.conf