2021-12-19 01:06:50 +00:00
|
|
|
{ config, lib, pkgs, utils, ... }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-12-19 01:06:50 +00:00
|
|
|
with utils.systemdUtils.unitOptions;
|
|
|
|
with utils.systemdUtils.lib;
|
2020-04-24 23:36:52 +00:00
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.systemd.network;
|
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
check = {
|
|
|
|
|
2022-03-13 04:00:48 +00:00
|
|
|
global = {
|
|
|
|
sectionNetwork = checkUnitConfig "Network" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"SpeedMeter"
|
|
|
|
"SpeedMeterIntervalSec"
|
|
|
|
"ManageForeignRoutingPolicyRules"
|
|
|
|
"ManageForeignRoutes"
|
|
|
|
"RouteTable"
|
|
|
|
])
|
|
|
|
(assertValueOneOf "SpeedMeter" boolValues)
|
|
|
|
(assertInt "SpeedMeterIntervalSec")
|
|
|
|
(assertValueOneOf "ManageForeignRoutingPolicyRules" boolValues)
|
|
|
|
(assertValueOneOf "ManageForeignRoutes" boolValues)
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionDHCPv4 = checkUnitConfig "DHCPv4" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"DUIDType"
|
|
|
|
"DUIDRawData"
|
|
|
|
])
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionDHCPv6 = checkUnitConfig "DHCPv6" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"DUIDType"
|
|
|
|
"DUIDRawData"
|
|
|
|
])
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
link = {
|
|
|
|
|
|
|
|
sectionLink = checkUnitConfig "Link" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Description"
|
|
|
|
"Alias"
|
|
|
|
"MACAddressPolicy"
|
|
|
|
"MACAddress"
|
|
|
|
"NamePolicy"
|
|
|
|
"Name"
|
|
|
|
"AlternativeNamesPolicy"
|
|
|
|
"AlternativeName"
|
|
|
|
"MTUBytes"
|
|
|
|
"BitsPerSecond"
|
|
|
|
"Duplex"
|
|
|
|
"AutoNegotiation"
|
|
|
|
"WakeOnLan"
|
|
|
|
"Port"
|
|
|
|
"Advertise"
|
|
|
|
"ReceiveChecksumOffload"
|
|
|
|
"TransmitChecksumOffload"
|
|
|
|
"TCPSegmentationOffload"
|
|
|
|
"TCP6SegmentationOffload"
|
|
|
|
"GenericSegmentationOffload"
|
|
|
|
"GenericReceiveOffload"
|
|
|
|
"LargeReceiveOffload"
|
|
|
|
"RxChannels"
|
|
|
|
"TxChannels"
|
|
|
|
"OtherChannels"
|
|
|
|
"CombinedChannels"
|
|
|
|
"RxBufferSize"
|
|
|
|
"TxBufferSize"
|
|
|
|
])
|
|
|
|
(assertValueOneOf "MACAddressPolicy" ["persistent" "random" "none"])
|
|
|
|
(assertMacAddress "MACAddress")
|
|
|
|
(assertByteFormat "MTUBytes")
|
|
|
|
(assertByteFormat "BitsPerSecond")
|
|
|
|
(assertValueOneOf "Duplex" ["half" "full"])
|
|
|
|
(assertValueOneOf "AutoNegotiation" boolValues)
|
|
|
|
(assertValueOneOf "WakeOnLan" ["phy" "unicast" "multicast" "broadcast" "arp" "magic" "secureon" "off"])
|
|
|
|
(assertValueOneOf "Port" ["tp" "aui" "bnc" "mii" "fibre"])
|
|
|
|
(assertValueOneOf "ReceiveChecksumOffload" boolValues)
|
|
|
|
(assertValueOneOf "TransmitChecksumOffload" boolValues)
|
|
|
|
(assertValueOneOf "TCPSegmentationOffload" boolValues)
|
|
|
|
(assertValueOneOf "TCP6SegmentationOffload" boolValues)
|
|
|
|
(assertValueOneOf "GenericSegmentationOffload" boolValues)
|
|
|
|
(assertValueOneOf "GenericReceiveOffload" boolValues)
|
|
|
|
(assertValueOneOf "LargeReceiveOffload" boolValues)
|
|
|
|
(assertInt "RxChannels")
|
|
|
|
(assertRange "RxChannels" 1 4294967295)
|
|
|
|
(assertInt "TxChannels")
|
|
|
|
(assertRange "TxChannels" 1 4294967295)
|
|
|
|
(assertInt "OtherChannels")
|
|
|
|
(assertRange "OtherChannels" 1 4294967295)
|
|
|
|
(assertInt "CombinedChannels")
|
|
|
|
(assertRange "CombinedChannels" 1 4294967295)
|
|
|
|
(assertInt "RxBufferSize")
|
|
|
|
(assertInt "TxBufferSize")
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
netdev = let
|
|
|
|
|
|
|
|
tunChecks = [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"MultiQueue"
|
|
|
|
"PacketInfo"
|
|
|
|
"VNetHeader"
|
|
|
|
"User"
|
|
|
|
"Group"
|
|
|
|
])
|
|
|
|
(assertValueOneOf "MultiQueue" boolValues)
|
|
|
|
(assertValueOneOf "PacketInfo" boolValues)
|
|
|
|
(assertValueOneOf "VNetHeader" boolValues)
|
|
|
|
];
|
|
|
|
in {
|
|
|
|
|
|
|
|
sectionNetdev = checkUnitConfig "Netdev" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Description"
|
|
|
|
"Name"
|
|
|
|
"Kind"
|
|
|
|
"MTUBytes"
|
|
|
|
"MACAddress"
|
|
|
|
])
|
|
|
|
(assertHasField "Name")
|
|
|
|
(assertHasField "Kind")
|
|
|
|
(assertValueOneOf "Kind" [
|
|
|
|
"bond"
|
|
|
|
"bridge"
|
|
|
|
"dummy"
|
|
|
|
"gre"
|
|
|
|
"gretap"
|
|
|
|
"erspan"
|
|
|
|
"ip6gre"
|
|
|
|
"ip6tnl"
|
|
|
|
"ip6gretap"
|
|
|
|
"ipip"
|
|
|
|
"ipvlan"
|
|
|
|
"macvlan"
|
|
|
|
"macvtap"
|
|
|
|
"sit"
|
|
|
|
"tap"
|
|
|
|
"tun"
|
|
|
|
"veth"
|
|
|
|
"vlan"
|
|
|
|
"vti"
|
|
|
|
"vti6"
|
|
|
|
"vxlan"
|
|
|
|
"geneve"
|
|
|
|
"l2tp"
|
|
|
|
"macsec"
|
|
|
|
"vrf"
|
|
|
|
"vcan"
|
|
|
|
"vxcan"
|
|
|
|
"wireguard"
|
|
|
|
"netdevsim"
|
|
|
|
"nlmon"
|
|
|
|
"fou"
|
|
|
|
"xfrm"
|
|
|
|
"ifb"
|
2021-12-06 16:07:01 +00:00
|
|
|
"batadv"
|
2020-08-20 17:08:02 +00:00
|
|
|
])
|
|
|
|
(assertByteFormat "MTUBytes")
|
|
|
|
(assertMacAddress "MACAddress")
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionVLAN = checkUnitConfig "VLAN" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Id"
|
|
|
|
"GVRP"
|
|
|
|
"MVRP"
|
|
|
|
"LooseBinding"
|
|
|
|
"ReorderHeader"
|
|
|
|
])
|
|
|
|
(assertInt "Id")
|
|
|
|
(assertRange "Id" 0 4094)
|
|
|
|
(assertValueOneOf "GVRP" boolValues)
|
|
|
|
(assertValueOneOf "MVRP" boolValues)
|
|
|
|
(assertValueOneOf "LooseBinding" boolValues)
|
|
|
|
(assertValueOneOf "ReorderHeader" boolValues)
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionMACVLAN = checkUnitConfig "MACVLAN" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Mode"
|
|
|
|
])
|
|
|
|
(assertValueOneOf "Mode" ["private" "vepa" "bridge" "passthru"])
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionVXLAN = checkUnitConfig "VXLAN" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"VNI"
|
|
|
|
"Remote"
|
|
|
|
"Local"
|
|
|
|
"Group"
|
|
|
|
"TOS"
|
|
|
|
"TTL"
|
|
|
|
"MacLearning"
|
|
|
|
"FDBAgeingSec"
|
|
|
|
"MaximumFDBEntries"
|
|
|
|
"ReduceARPProxy"
|
|
|
|
"L2MissNotification"
|
|
|
|
"L3MissNotification"
|
|
|
|
"RouteShortCircuit"
|
|
|
|
"UDPChecksum"
|
|
|
|
"UDP6ZeroChecksumTx"
|
|
|
|
"UDP6ZeroChecksumRx"
|
|
|
|
"RemoteChecksumTx"
|
|
|
|
"RemoteChecksumRx"
|
|
|
|
"GroupPolicyExtension"
|
|
|
|
"GenericProtocolExtension"
|
|
|
|
"DestinationPort"
|
|
|
|
"PortRange"
|
|
|
|
"FlowLabel"
|
|
|
|
"IPDoNotFragment"
|
|
|
|
])
|
|
|
|
(assertInt "VNI")
|
|
|
|
(assertRange "VNI" 1 16777215)
|
|
|
|
(assertValueOneOf "MacLearning" boolValues)
|
|
|
|
(assertInt "MaximumFDBEntries")
|
|
|
|
(assertValueOneOf "ReduceARPProxy" boolValues)
|
|
|
|
(assertValueOneOf "L2MissNotification" boolValues)
|
|
|
|
(assertValueOneOf "L3MissNotification" boolValues)
|
|
|
|
(assertValueOneOf "RouteShortCircuit" boolValues)
|
|
|
|
(assertValueOneOf "UDPChecksum" boolValues)
|
|
|
|
(assertValueOneOf "UDP6ZeroChecksumTx" boolValues)
|
|
|
|
(assertValueOneOf "UDP6ZeroChecksumRx" boolValues)
|
|
|
|
(assertValueOneOf "RemoteChecksumTx" boolValues)
|
|
|
|
(assertValueOneOf "RemoteChecksumRx" boolValues)
|
|
|
|
(assertValueOneOf "GroupPolicyExtension" boolValues)
|
|
|
|
(assertValueOneOf "GenericProtocolExtension" boolValues)
|
|
|
|
(assertInt "FlowLabel")
|
|
|
|
(assertRange "FlowLabel" 0 1048575)
|
|
|
|
(assertValueOneOf "IPDoNotFragment" (boolValues + ["inherit"]))
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionTunnel = checkUnitConfig "Tunnel" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Local"
|
|
|
|
"Remote"
|
|
|
|
"TOS"
|
|
|
|
"TTL"
|
|
|
|
"DiscoverPathMTU"
|
|
|
|
"IPv6FlowLabel"
|
|
|
|
"CopyDSCP"
|
|
|
|
"EncapsulationLimit"
|
|
|
|
"Key"
|
|
|
|
"InputKey"
|
|
|
|
"OutputKey"
|
|
|
|
"Mode"
|
|
|
|
"Independent"
|
|
|
|
"AssignToLoopback"
|
|
|
|
"AllowLocalRemote"
|
|
|
|
"FooOverUDP"
|
|
|
|
"FOUDestinationPort"
|
|
|
|
"FOUSourcePort"
|
|
|
|
"Encapsulation"
|
|
|
|
"IPv6RapidDeploymentPrefix"
|
|
|
|
"ISATAP"
|
|
|
|
"SerializeTunneledPackets"
|
|
|
|
"ERSPANIndex"
|
|
|
|
])
|
|
|
|
(assertInt "TTL")
|
|
|
|
(assertRange "TTL" 0 255)
|
|
|
|
(assertValueOneOf "DiscoverPathMTU" boolValues)
|
|
|
|
(assertValueOneOf "CopyDSCP" boolValues)
|
|
|
|
(assertValueOneOf "Mode" ["ip6ip6" "ipip6" "any"])
|
|
|
|
(assertValueOneOf "Independent" boolValues)
|
|
|
|
(assertValueOneOf "AssignToLoopback" boolValues)
|
|
|
|
(assertValueOneOf "AllowLocalRemote" boolValues)
|
|
|
|
(assertValueOneOf "FooOverUDP" boolValues)
|
|
|
|
(assertPort "FOUDestinationPort")
|
|
|
|
(assertPort "FOUSourcePort")
|
|
|
|
(assertValueOneOf "Encapsulation" ["FooOverUDP" "GenericUDPEncapsulation"])
|
|
|
|
(assertValueOneOf "ISATAP" boolValues)
|
|
|
|
(assertValueOneOf "SerializeTunneledPackets" boolValues)
|
|
|
|
(assertInt "ERSPANIndex")
|
|
|
|
(assertRange "ERSPANIndex" 1 1048575)
|
|
|
|
];
|
|
|
|
|
2021-10-17 02:12:59 +00:00
|
|
|
sectionFooOverUDP = checkUnitConfig "FooOverUDP" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Port"
|
|
|
|
"Encapsulation"
|
|
|
|
"Protocol"
|
|
|
|
])
|
|
|
|
(assertPort "Port")
|
|
|
|
(assertValueOneOf "Encapsulation" ["FooOverUDP" "GenericUDPEncapsulation"])
|
|
|
|
];
|
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
sectionPeer = checkUnitConfig "Peer" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Name"
|
|
|
|
"MACAddress"
|
|
|
|
])
|
|
|
|
(assertMacAddress "MACAddress")
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionTun = checkUnitConfig "Tun" tunChecks;
|
|
|
|
|
|
|
|
sectionTap = checkUnitConfig "Tap" tunChecks;
|
|
|
|
|
|
|
|
# NOTE The PrivateKey directive is missing on purpose here, please
|
|
|
|
# do not add it to this list. The nix store is world-readable let's
|
|
|
|
# refrain ourselves from providing a footgun.
|
|
|
|
sectionWireGuard = checkUnitConfig "WireGuard" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"PrivateKeyFile"
|
|
|
|
"ListenPort"
|
|
|
|
"FirewallMark"
|
2022-03-12 19:38:54 +00:00
|
|
|
"RouteTable"
|
|
|
|
"RouteMetric"
|
2020-08-20 17:08:02 +00:00
|
|
|
])
|
|
|
|
(assertInt "FirewallMark")
|
|
|
|
(assertRange "FirewallMark" 1 4294967295)
|
|
|
|
];
|
|
|
|
|
|
|
|
# NOTE The PresharedKey directive is missing on purpose here, please
|
|
|
|
# do not add it to this list. The nix store is world-readable,let's
|
|
|
|
# refrain ourselves from providing a footgun.
|
|
|
|
sectionWireGuardPeer = checkUnitConfig "WireGuardPeer" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"PublicKey"
|
|
|
|
"PresharedKeyFile"
|
|
|
|
"AllowedIPs"
|
|
|
|
"Endpoint"
|
|
|
|
"PersistentKeepalive"
|
2022-03-12 19:38:54 +00:00
|
|
|
"RouteTable"
|
|
|
|
"RouteMetric"
|
2020-08-20 17:08:02 +00:00
|
|
|
])
|
|
|
|
(assertInt "PersistentKeepalive")
|
|
|
|
(assertRange "PersistentKeepalive" 0 65535)
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionBond = checkUnitConfig "Bond" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Mode"
|
|
|
|
"TransmitHashPolicy"
|
|
|
|
"LACPTransmitRate"
|
|
|
|
"MIIMonitorSec"
|
|
|
|
"UpDelaySec"
|
|
|
|
"DownDelaySec"
|
|
|
|
"LearnPacketIntervalSec"
|
|
|
|
"AdSelect"
|
|
|
|
"AdActorSystemPriority"
|
|
|
|
"AdUserPortKey"
|
|
|
|
"AdActorSystem"
|
|
|
|
"FailOverMACPolicy"
|
|
|
|
"ARPValidate"
|
|
|
|
"ARPIntervalSec"
|
|
|
|
"ARPIPTargets"
|
|
|
|
"ARPAllTargets"
|
|
|
|
"PrimaryReselectPolicy"
|
|
|
|
"ResendIGMP"
|
|
|
|
"PacketsPerSlave"
|
|
|
|
"GratuitousARP"
|
|
|
|
"AllSlavesActive"
|
|
|
|
"DynamicTransmitLoadBalancing"
|
|
|
|
"MinLinks"
|
|
|
|
])
|
|
|
|
(assertValueOneOf "Mode" [
|
|
|
|
"balance-rr"
|
|
|
|
"active-backup"
|
|
|
|
"balance-xor"
|
|
|
|
"broadcast"
|
|
|
|
"802.3ad"
|
|
|
|
"balance-tlb"
|
|
|
|
"balance-alb"
|
|
|
|
])
|
|
|
|
(assertValueOneOf "TransmitHashPolicy" [
|
|
|
|
"layer2"
|
|
|
|
"layer3+4"
|
|
|
|
"layer2+3"
|
|
|
|
"encap2+3"
|
|
|
|
"encap3+4"
|
|
|
|
])
|
|
|
|
(assertValueOneOf "LACPTransmitRate" ["slow" "fast"])
|
|
|
|
(assertValueOneOf "AdSelect" ["stable" "bandwidth" "count"])
|
|
|
|
(assertInt "AdActorSystemPriority")
|
|
|
|
(assertRange "AdActorSystemPriority" 1 65535)
|
|
|
|
(assertInt "AdUserPortKey")
|
|
|
|
(assertRange "AdUserPortKey" 0 1023)
|
|
|
|
(assertValueOneOf "FailOverMACPolicy" ["none" "active" "follow"])
|
|
|
|
(assertValueOneOf "ARPValidate" ["none" "active" "backup" "all"])
|
|
|
|
(assertValueOneOf "ARPAllTargets" ["any" "all"])
|
|
|
|
(assertValueOneOf "PrimaryReselectPolicy" ["always" "better" "failure"])
|
|
|
|
(assertInt "ResendIGMP")
|
|
|
|
(assertRange "ResendIGMP" 0 255)
|
|
|
|
(assertInt "PacketsPerSlave")
|
|
|
|
(assertRange "PacketsPerSlave" 0 65535)
|
|
|
|
(assertInt "GratuitousARP")
|
|
|
|
(assertRange "GratuitousARP" 0 255)
|
|
|
|
(assertValueOneOf "AllSlavesActive" boolValues)
|
|
|
|
(assertValueOneOf "DynamicTransmitLoadBalancing" boolValues)
|
|
|
|
(assertInt "MinLinks")
|
|
|
|
(assertMinimum "MinLinks" 0)
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionXfrm = checkUnitConfig "Xfrm" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"InterfaceId"
|
|
|
|
"Independent"
|
|
|
|
])
|
|
|
|
(assertInt "InterfaceId")
|
|
|
|
(assertRange "InterfaceId" 1 4294967295)
|
|
|
|
(assertValueOneOf "Independent" boolValues)
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionVRF = checkUnitConfig "VRF" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Table"
|
|
|
|
])
|
|
|
|
(assertInt "Table")
|
|
|
|
(assertMinimum "Table" 0)
|
|
|
|
];
|
2021-12-06 16:07:01 +00:00
|
|
|
|
|
|
|
sectionBatmanAdvanced = checkUnitConfig "BatmanAdvanced" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"GatewayMode"
|
|
|
|
"Aggregation"
|
|
|
|
"BridgeLoopAvoidance"
|
|
|
|
"DistributedArpTable"
|
|
|
|
"Fragmentation"
|
|
|
|
"HopPenalty"
|
|
|
|
"OriginatorIntervalSec"
|
|
|
|
"GatewayBandwithDown"
|
|
|
|
"GatewayBandwithUp"
|
|
|
|
"RoutingAlgorithm"
|
|
|
|
])
|
|
|
|
(assertValueOneOf "GatewayMode" ["off" "client" "server"])
|
|
|
|
(assertValueOneOf "Aggregation" boolValues)
|
|
|
|
(assertValueOneOf "BridgeLoopAvoidance" boolValues)
|
|
|
|
(assertValueOneOf "DistributedArpTable" boolValues)
|
|
|
|
(assertValueOneOf "Fragmentation" boolValues)
|
|
|
|
(assertInt "HopPenalty")
|
|
|
|
(assertRange "HopPenalty" 0 255)
|
|
|
|
(assertValueOneOf "RoutingAlgorithm" ["batman-v" "batman-iv"])
|
|
|
|
];
|
2020-08-20 17:08:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
network = {
|
|
|
|
|
|
|
|
sectionLink = checkUnitConfig "Link" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"MACAddress"
|
|
|
|
"MTUBytes"
|
|
|
|
"ARP"
|
|
|
|
"Multicast"
|
|
|
|
"AllMulticast"
|
|
|
|
"Unmanaged"
|
2022-09-09 14:08:57 +00:00
|
|
|
"Group"
|
2020-08-20 17:08:02 +00:00
|
|
|
"RequiredForOnline"
|
2022-08-12 12:06:08 +00:00
|
|
|
"RequiredFamilyForOnline"
|
2021-09-26 12:46:18 +00:00
|
|
|
"ActivationPolicy"
|
2022-08-12 12:06:08 +00:00
|
|
|
"Promiscuous"
|
2020-08-20 17:08:02 +00:00
|
|
|
])
|
|
|
|
(assertMacAddress "MACAddress")
|
|
|
|
(assertByteFormat "MTUBytes")
|
|
|
|
(assertValueOneOf "ARP" boolValues)
|
|
|
|
(assertValueOneOf "Multicast" boolValues)
|
|
|
|
(assertValueOneOf "AllMulticast" boolValues)
|
2022-08-12 12:06:08 +00:00
|
|
|
(assertValueOneOf "Promiscuous" boolValues)
|
2020-08-20 17:08:02 +00:00
|
|
|
(assertValueOneOf "Unmanaged" boolValues)
|
2022-09-09 14:08:57 +00:00
|
|
|
(assertInt "Group")
|
|
|
|
(assertRange "Group" 0 2147483647)
|
2020-08-20 17:08:02 +00:00
|
|
|
(assertValueOneOf "RequiredForOnline" (boolValues ++ [
|
|
|
|
"missing"
|
|
|
|
"off"
|
|
|
|
"no-carrier"
|
|
|
|
"dormant"
|
|
|
|
"degraded-carrier"
|
|
|
|
"carrier"
|
|
|
|
"degraded"
|
|
|
|
"enslaved"
|
|
|
|
"routable"
|
|
|
|
]))
|
2022-08-12 12:06:08 +00:00
|
|
|
(assertValueOneOf "RequiredFamilyForOnline" [
|
|
|
|
"ipv4"
|
|
|
|
"ipv6"
|
|
|
|
"both"
|
|
|
|
"any"
|
|
|
|
])
|
2021-09-26 12:46:18 +00:00
|
|
|
(assertValueOneOf "ActivationPolicy" ([
|
|
|
|
"up"
|
|
|
|
"always-up"
|
|
|
|
"manual"
|
|
|
|
"always-down"
|
|
|
|
"down"
|
|
|
|
"bound"
|
|
|
|
]))
|
2020-08-20 17:08:02 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
sectionNetwork = checkUnitConfig "Network" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Description"
|
|
|
|
"DHCP"
|
|
|
|
"DHCPServer"
|
|
|
|
"LinkLocalAddressing"
|
|
|
|
"IPv4LLRoute"
|
|
|
|
"DefaultRouteOnDevice"
|
|
|
|
"LLMNR"
|
|
|
|
"MulticastDNS"
|
|
|
|
"DNSOverTLS"
|
|
|
|
"DNSSEC"
|
|
|
|
"DNSSECNegativeTrustAnchors"
|
|
|
|
"LLDP"
|
|
|
|
"EmitLLDP"
|
|
|
|
"BindCarrier"
|
|
|
|
"Address"
|
|
|
|
"Gateway"
|
|
|
|
"DNS"
|
|
|
|
"Domains"
|
|
|
|
"DNSDefaultRoute"
|
|
|
|
"NTP"
|
|
|
|
"IPForward"
|
|
|
|
"IPMasquerade"
|
|
|
|
"IPv6PrivacyExtensions"
|
|
|
|
"IPv6AcceptRA"
|
|
|
|
"IPv6DuplicateAddressDetection"
|
|
|
|
"IPv6HopLimit"
|
|
|
|
"IPv4ProxyARP"
|
|
|
|
"IPv6ProxyNDP"
|
|
|
|
"IPv6ProxyNDPAddress"
|
2021-03-09 03:18:52 +00:00
|
|
|
"IPv6SendRA"
|
2022-10-21 18:38:19 +00:00
|
|
|
"DHCPPrefixDelegation"
|
2020-08-20 17:08:02 +00:00
|
|
|
"IPv6MTUBytes"
|
|
|
|
"Bridge"
|
|
|
|
"Bond"
|
|
|
|
"VRF"
|
|
|
|
"VLAN"
|
|
|
|
"IPVLAN"
|
|
|
|
"MACVLAN"
|
|
|
|
"VXLAN"
|
|
|
|
"Tunnel"
|
|
|
|
"MACsec"
|
|
|
|
"ActiveSlave"
|
|
|
|
"PrimarySlave"
|
|
|
|
"ConfigureWithoutCarrier"
|
|
|
|
"IgnoreCarrierLoss"
|
|
|
|
"Xfrm"
|
|
|
|
"KeepConfiguration"
|
2021-12-06 16:07:01 +00:00
|
|
|
"BatmanAdvanced"
|
2020-08-20 17:08:02 +00:00
|
|
|
])
|
|
|
|
# Note: For DHCP the values both, none, v4, v6 are deprecated
|
|
|
|
(assertValueOneOf "DHCP" ["yes" "no" "ipv4" "ipv6"])
|
|
|
|
(assertValueOneOf "DHCPServer" boolValues)
|
|
|
|
(assertValueOneOf "LinkLocalAddressing" ["yes" "no" "ipv4" "ipv6" "fallback" "ipv4-fallback"])
|
|
|
|
(assertValueOneOf "IPv4LLRoute" boolValues)
|
|
|
|
(assertValueOneOf "DefaultRouteOnDevice" boolValues)
|
|
|
|
(assertValueOneOf "LLMNR" (boolValues ++ ["resolve"]))
|
|
|
|
(assertValueOneOf "MulticastDNS" (boolValues ++ ["resolve"]))
|
|
|
|
(assertValueOneOf "DNSOverTLS" (boolValues ++ ["opportunistic"]))
|
|
|
|
(assertValueOneOf "DNSSEC" (boolValues ++ ["allow-downgrade"]))
|
|
|
|
(assertValueOneOf "LLDP" (boolValues ++ ["routers-only"]))
|
|
|
|
(assertValueOneOf "EmitLLDP" (boolValues ++ ["nearest-bridge" "non-tpmr-bridge" "customer-bridge"]))
|
|
|
|
(assertValueOneOf "DNSDefaultRoute" boolValues)
|
|
|
|
(assertValueOneOf "IPForward" (boolValues ++ ["ipv4" "ipv6"]))
|
2022-01-22 01:22:15 +00:00
|
|
|
(assertValueOneOf "IPMasquerade" (boolValues ++ ["ipv4" "ipv6" "both"]))
|
2020-08-20 17:08:02 +00:00
|
|
|
(assertValueOneOf "IPv6PrivacyExtensions" (boolValues ++ ["prefer-public" "kernel"]))
|
|
|
|
(assertValueOneOf "IPv6AcceptRA" boolValues)
|
|
|
|
(assertInt "IPv6DuplicateAddressDetection")
|
|
|
|
(assertMinimum "IPv6DuplicateAddressDetection" 0)
|
|
|
|
(assertInt "IPv6HopLimit")
|
|
|
|
(assertMinimum "IPv6HopLimit" 0)
|
|
|
|
(assertValueOneOf "IPv4ProxyARP" boolValues)
|
|
|
|
(assertValueOneOf "IPv6ProxyNDP" boolValues)
|
2021-03-09 03:18:52 +00:00
|
|
|
(assertValueOneOf "IPv6SendRA" boolValues)
|
2022-10-21 18:38:19 +00:00
|
|
|
(assertValueOneOf "DHCPPrefixDelegation" boolValues)
|
2020-08-20 17:08:02 +00:00
|
|
|
(assertByteFormat "IPv6MTUBytes")
|
|
|
|
(assertValueOneOf "ActiveSlave" boolValues)
|
|
|
|
(assertValueOneOf "PrimarySlave" boolValues)
|
|
|
|
(assertValueOneOf "ConfigureWithoutCarrier" boolValues)
|
|
|
|
(assertValueOneOf "KeepConfiguration" (boolValues ++ ["static" "dhcp-on-stop" "dhcp"]))
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionAddress = checkUnitConfig "Address" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Address"
|
|
|
|
"Peer"
|
|
|
|
"Broadcast"
|
|
|
|
"Label"
|
|
|
|
"PreferredLifetime"
|
|
|
|
"Scope"
|
2022-10-30 15:09:59 +00:00
|
|
|
"RouteMetric"
|
2020-08-20 17:08:02 +00:00
|
|
|
"HomeAddress"
|
|
|
|
"DuplicateAddressDetection"
|
|
|
|
"ManageTemporaryAddress"
|
|
|
|
"AddPrefixRoute"
|
|
|
|
"AutoJoin"
|
|
|
|
])
|
|
|
|
(assertHasField "Address")
|
|
|
|
(assertValueOneOf "PreferredLifetime" ["forever" "infinity" "0" 0])
|
2022-10-30 15:09:59 +00:00
|
|
|
(assertInt "RouteMetric")
|
2020-08-20 17:08:02 +00:00
|
|
|
(assertValueOneOf "HomeAddress" boolValues)
|
|
|
|
(assertValueOneOf "DuplicateAddressDetection" ["ipv4" "ipv6" "both" "none"])
|
|
|
|
(assertValueOneOf "ManageTemporaryAddress" boolValues)
|
|
|
|
(assertValueOneOf "AddPrefixRoute" boolValues)
|
|
|
|
(assertValueOneOf "AutoJoin" boolValues)
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionRoutingPolicyRule = checkUnitConfig "RoutingPolicyRule" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"TypeOfService"
|
|
|
|
"From"
|
|
|
|
"To"
|
|
|
|
"FirewallMark"
|
|
|
|
"Table"
|
|
|
|
"Priority"
|
|
|
|
"IncomingInterface"
|
|
|
|
"OutgoingInterface"
|
|
|
|
"SourcePort"
|
|
|
|
"DestinationPort"
|
|
|
|
"IPProtocol"
|
|
|
|
"InvertRule"
|
|
|
|
"Family"
|
|
|
|
"User"
|
|
|
|
"SuppressPrefixLength"
|
2021-12-19 01:06:50 +00:00
|
|
|
"Type"
|
2022-10-21 18:38:19 +00:00
|
|
|
"SuppressInterfaceGroup"
|
2020-08-20 17:08:02 +00:00
|
|
|
])
|
|
|
|
(assertInt "TypeOfService")
|
|
|
|
(assertRange "TypeOfService" 0 255)
|
|
|
|
(assertInt "FirewallMark")
|
|
|
|
(assertRange "FirewallMark" 1 4294967295)
|
|
|
|
(assertInt "Priority")
|
|
|
|
(assertPort "SourcePort")
|
|
|
|
(assertPort "DestinationPort")
|
|
|
|
(assertValueOneOf "InvertRule" boolValues)
|
|
|
|
(assertValueOneOf "Family" ["ipv4" "ipv6" "both"])
|
|
|
|
(assertInt "SuppressPrefixLength")
|
|
|
|
(assertRange "SuppressPrefixLength" 0 128)
|
2021-12-19 01:06:50 +00:00
|
|
|
(assertValueOneOf "Type" ["blackhole" "unreachable" "prohibit"])
|
2022-10-21 18:38:19 +00:00
|
|
|
(assertRange "SuppressInterfaceGroup" 0 2147483647)
|
2020-08-20 17:08:02 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
sectionRoute = checkUnitConfig "Route" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Gateway"
|
|
|
|
"GatewayOnLink"
|
|
|
|
"Destination"
|
|
|
|
"Source"
|
|
|
|
"Metric"
|
|
|
|
"IPv6Preference"
|
|
|
|
"Scope"
|
|
|
|
"PreferredSource"
|
|
|
|
"Table"
|
|
|
|
"Protocol"
|
|
|
|
"Type"
|
|
|
|
"InitialCongestionWindow"
|
|
|
|
"InitialAdvertisedReceiveWindow"
|
|
|
|
"QuickAck"
|
|
|
|
"FastOpenNoCookie"
|
|
|
|
"TTLPropagate"
|
|
|
|
"MTUBytes"
|
|
|
|
"IPServiceType"
|
|
|
|
"MultiPathRoute"
|
|
|
|
])
|
|
|
|
(assertValueOneOf "GatewayOnLink" boolValues)
|
|
|
|
(assertInt "Metric")
|
|
|
|
(assertValueOneOf "IPv6Preference" ["low" "medium" "high"])
|
|
|
|
(assertValueOneOf "Scope" ["global" "site" "link" "host" "nowhere"])
|
|
|
|
(assertValueOneOf "Type" [
|
|
|
|
"unicast"
|
|
|
|
"local"
|
|
|
|
"broadcast"
|
|
|
|
"anycast"
|
|
|
|
"multicast"
|
|
|
|
"blackhole"
|
|
|
|
"unreachable"
|
|
|
|
"prohibit"
|
|
|
|
"throw"
|
|
|
|
"nat"
|
|
|
|
"xresolve"
|
|
|
|
])
|
|
|
|
(assertValueOneOf "QuickAck" boolValues)
|
|
|
|
(assertValueOneOf "FastOpenNoCookie" boolValues)
|
|
|
|
(assertValueOneOf "TTLPropagate" boolValues)
|
|
|
|
(assertByteFormat "MTUBytes")
|
|
|
|
(assertValueOneOf "IPServiceType" ["CS6" "CS4"])
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionDHCPv4 = checkUnitConfig "DHCPv4" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"UseDNS"
|
|
|
|
"RoutesToDNS"
|
|
|
|
"UseNTP"
|
|
|
|
"UseSIP"
|
|
|
|
"UseMTU"
|
|
|
|
"Anonymize"
|
|
|
|
"SendHostname"
|
|
|
|
"UseHostname"
|
|
|
|
"Hostname"
|
|
|
|
"UseDomains"
|
|
|
|
"UseRoutes"
|
|
|
|
"UseTimezone"
|
|
|
|
"ClientIdentifier"
|
|
|
|
"VendorClassIdentifier"
|
|
|
|
"UserClass"
|
|
|
|
"MaxAttempts"
|
|
|
|
"DUIDType"
|
|
|
|
"DUIDRawData"
|
|
|
|
"IAID"
|
|
|
|
"RequestBroadcast"
|
|
|
|
"RouteMetric"
|
|
|
|
"RouteTable"
|
|
|
|
"RouteMTUBytes"
|
|
|
|
"ListenPort"
|
|
|
|
"SendRelease"
|
|
|
|
"SendDecline"
|
|
|
|
"BlackList"
|
|
|
|
"RequestOptions"
|
|
|
|
"SendOption"
|
2022-10-21 18:38:19 +00:00
|
|
|
"FallbackLeaseLifetimeSec"
|
|
|
|
"Label"
|
|
|
|
"Use6RD"
|
2020-08-20 17:08:02 +00:00
|
|
|
])
|
|
|
|
(assertValueOneOf "UseDNS" boolValues)
|
|
|
|
(assertValueOneOf "RoutesToDNS" boolValues)
|
|
|
|
(assertValueOneOf "UseNTP" boolValues)
|
|
|
|
(assertValueOneOf "UseSIP" boolValues)
|
|
|
|
(assertValueOneOf "UseMTU" boolValues)
|
|
|
|
(assertValueOneOf "Anonymize" boolValues)
|
|
|
|
(assertValueOneOf "SendHostname" boolValues)
|
|
|
|
(assertValueOneOf "UseHostname" boolValues)
|
|
|
|
(assertValueOneOf "UseDomains" (boolValues ++ ["route"]))
|
|
|
|
(assertValueOneOf "UseRoutes" boolValues)
|
|
|
|
(assertValueOneOf "UseTimezone" boolValues)
|
|
|
|
(assertValueOneOf "ClientIdentifier" ["mac" "duid" "duid-only"])
|
|
|
|
(assertInt "IAID")
|
|
|
|
(assertValueOneOf "RequestBroadcast" boolValues)
|
|
|
|
(assertInt "RouteMetric")
|
|
|
|
(assertInt "RouteTable")
|
|
|
|
(assertRange "RouteTable" 0 4294967295)
|
|
|
|
(assertByteFormat "RouteMTUBytes")
|
|
|
|
(assertPort "ListenPort")
|
|
|
|
(assertValueOneOf "SendRelease" boolValues)
|
|
|
|
(assertValueOneOf "SendDecline" boolValues)
|
2022-10-21 18:38:19 +00:00
|
|
|
(assertValueOneOf "FallbackLeaseLifetimeSec" ["forever" "infinity"])
|
|
|
|
(assertValueOneOf "Use6RD" boolValues)
|
2020-08-20 17:08:02 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
sectionDHCPv6 = checkUnitConfig "DHCPv6" [
|
|
|
|
(assertOnlyFields [
|
2021-03-09 03:18:52 +00:00
|
|
|
"UseAddress"
|
2020-08-20 17:08:02 +00:00
|
|
|
"UseDNS"
|
|
|
|
"UseNTP"
|
2021-03-09 03:18:52 +00:00
|
|
|
"RouteMetric"
|
2020-08-20 17:08:02 +00:00
|
|
|
"RapidCommit"
|
2021-03-09 03:18:52 +00:00
|
|
|
"MUDURL"
|
|
|
|
"RequestOptions"
|
|
|
|
"SendVendorOption"
|
2020-08-20 17:08:02 +00:00
|
|
|
"PrefixDelegationHint"
|
2021-03-09 03:18:52 +00:00
|
|
|
"WithoutRA"
|
|
|
|
"SendOption"
|
|
|
|
"UserClass"
|
|
|
|
"VendorClass"
|
2021-10-06 13:57:05 +00:00
|
|
|
"DUIDType"
|
|
|
|
"DUIDRawData"
|
|
|
|
"IAID"
|
2022-10-21 18:38:19 +00:00
|
|
|
"UseDelegatedPrefix"
|
2020-08-20 17:08:02 +00:00
|
|
|
])
|
2021-03-09 03:18:52 +00:00
|
|
|
(assertValueOneOf "UseAddress" boolValues)
|
2020-08-20 17:08:02 +00:00
|
|
|
(assertValueOneOf "UseDNS" boolValues)
|
|
|
|
(assertValueOneOf "UseNTP" boolValues)
|
2021-03-09 03:18:52 +00:00
|
|
|
(assertInt "RouteMetric")
|
2020-08-20 17:08:02 +00:00
|
|
|
(assertValueOneOf "RapidCommit" boolValues)
|
2022-10-21 18:38:19 +00:00
|
|
|
(assertValueOneOf "WithoutRA" ["no" "solicit" "information-request"])
|
2021-03-09 03:18:52 +00:00
|
|
|
(assertRange "SendOption" 1 65536)
|
2021-10-06 13:57:05 +00:00
|
|
|
(assertInt "IAID")
|
2022-10-21 18:38:19 +00:00
|
|
|
(assertValueOneOf "UseDelegatedPrefix" boolValues)
|
2021-03-09 03:18:52 +00:00
|
|
|
];
|
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
sectionDHCPPrefixDelegation = checkUnitConfig "DHCPPrefixDelegation" [
|
2021-03-09 03:18:52 +00:00
|
|
|
(assertOnlyFields [
|
2022-10-21 18:38:19 +00:00
|
|
|
"UplinkInterface"
|
2021-03-09 03:18:52 +00:00
|
|
|
"SubnetId"
|
|
|
|
"Announce"
|
|
|
|
"Assign"
|
|
|
|
"Token"
|
2022-10-21 18:38:19 +00:00
|
|
|
"ManageTemporaryAddress"
|
|
|
|
"RouteMetric"
|
2021-03-09 03:18:52 +00:00
|
|
|
])
|
|
|
|
(assertValueOneOf "Announce" boolValues)
|
|
|
|
(assertValueOneOf "Assign" boolValues)
|
2022-10-21 18:38:19 +00:00
|
|
|
(assertValueOneOf "ManageTemporaryAddress" boolValues)
|
|
|
|
(assertRange "RouteMetric" 0 4294967295)
|
2021-03-09 03:18:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
sectionIPv6AcceptRA = checkUnitConfig "IPv6AcceptRA" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"UseDNS"
|
|
|
|
"UseDomains"
|
|
|
|
"RouteTable"
|
|
|
|
"UseAutonomousPrefix"
|
|
|
|
"UseOnLinkPrefix"
|
|
|
|
"RouterDenyList"
|
|
|
|
"RouterAllowList"
|
|
|
|
"PrefixDenyList"
|
|
|
|
"PrefixAllowList"
|
|
|
|
"RouteDenyList"
|
|
|
|
"RouteAllowList"
|
|
|
|
"DHCPv6Client"
|
2022-05-18 14:49:53 +00:00
|
|
|
"RouteMetric"
|
2022-10-21 18:38:19 +00:00
|
|
|
"UseMTU"
|
|
|
|
"UseGateway"
|
|
|
|
"UseRoutePrefix"
|
|
|
|
"Token"
|
2021-03-09 03:18:52 +00:00
|
|
|
])
|
|
|
|
(assertValueOneOf "UseDNS" boolValues)
|
|
|
|
(assertValueOneOf "UseDomains" (boolValues ++ ["route"]))
|
|
|
|
(assertRange "RouteTable" 0 4294967295)
|
|
|
|
(assertValueOneOf "UseAutonomousPrefix" boolValues)
|
|
|
|
(assertValueOneOf "UseOnLinkPrefix" boolValues)
|
|
|
|
(assertValueOneOf "DHCPv6Client" (boolValues ++ ["always"]))
|
2022-10-21 18:38:19 +00:00
|
|
|
(assertValueOneOf "UseMTU" boolValues)
|
|
|
|
(assertValueOneOf "UseGateway" boolValues)
|
|
|
|
(assertValueOneOf "UseRoutePrefix" boolValues)
|
2020-08-20 17:08:02 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
sectionDHCPServer = checkUnitConfig "DHCPServer" [
|
|
|
|
(assertOnlyFields [
|
2022-09-09 14:08:57 +00:00
|
|
|
"ServerAddress"
|
2020-08-20 17:08:02 +00:00
|
|
|
"PoolOffset"
|
|
|
|
"PoolSize"
|
|
|
|
"DefaultLeaseTimeSec"
|
|
|
|
"MaxLeaseTimeSec"
|
2022-09-09 14:08:57 +00:00
|
|
|
"UplinkInterface"
|
2020-08-20 17:08:02 +00:00
|
|
|
"EmitDNS"
|
|
|
|
"DNS"
|
|
|
|
"EmitNTP"
|
|
|
|
"NTP"
|
|
|
|
"EmitSIP"
|
|
|
|
"SIP"
|
2021-05-20 23:08:51 +00:00
|
|
|
"EmitPOP3"
|
|
|
|
"POP3"
|
|
|
|
"EmitSMTP"
|
|
|
|
"SMTP"
|
|
|
|
"EmitLPR"
|
|
|
|
"LPR"
|
2020-08-20 17:08:02 +00:00
|
|
|
"EmitRouter"
|
2022-09-09 14:08:57 +00:00
|
|
|
"Router"
|
2020-08-20 17:08:02 +00:00
|
|
|
"EmitTimezone"
|
|
|
|
"Timezone"
|
|
|
|
"SendOption"
|
2021-05-20 23:08:51 +00:00
|
|
|
"SendVendorOption"
|
2022-09-09 14:08:57 +00:00
|
|
|
"BindToInterface"
|
|
|
|
"RelayTarget"
|
|
|
|
"RelayAgentCircuitId"
|
|
|
|
"RelayAgentRemoteId"
|
2020-08-20 17:08:02 +00:00
|
|
|
])
|
|
|
|
(assertInt "PoolOffset")
|
|
|
|
(assertMinimum "PoolOffset" 0)
|
|
|
|
(assertInt "PoolSize")
|
|
|
|
(assertMinimum "PoolSize" 0)
|
|
|
|
(assertValueOneOf "EmitDNS" boolValues)
|
|
|
|
(assertValueOneOf "EmitNTP" boolValues)
|
|
|
|
(assertValueOneOf "EmitSIP" boolValues)
|
2021-05-20 23:08:51 +00:00
|
|
|
(assertValueOneOf "EmitPOP3" boolValues)
|
|
|
|
(assertValueOneOf "EmitSMTP" boolValues)
|
|
|
|
(assertValueOneOf "EmitLPR" boolValues)
|
2020-08-20 17:08:02 +00:00
|
|
|
(assertValueOneOf "EmitRouter" boolValues)
|
|
|
|
(assertValueOneOf "EmitTimezone" boolValues)
|
2022-09-09 14:08:57 +00:00
|
|
|
(assertValueOneOf "BindToInterface" boolValues)
|
2020-08-20 17:08:02 +00:00
|
|
|
];
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
sectionIPv6SendRA = checkUnitConfig "IPv6SendRA" [
|
2020-08-20 17:08:02 +00:00
|
|
|
(assertOnlyFields [
|
|
|
|
"Managed"
|
|
|
|
"OtherInformation"
|
|
|
|
"RouterLifetimeSec"
|
|
|
|
"RouterPreference"
|
2022-09-09 14:08:57 +00:00
|
|
|
"UplinkInterface"
|
2020-08-20 17:08:02 +00:00
|
|
|
"EmitDNS"
|
|
|
|
"DNS"
|
|
|
|
"EmitDomains"
|
|
|
|
"Domains"
|
|
|
|
"DNSLifetimeSec"
|
|
|
|
])
|
|
|
|
(assertValueOneOf "Managed" boolValues)
|
|
|
|
(assertValueOneOf "OtherInformation" boolValues)
|
|
|
|
(assertValueOneOf "RouterPreference" ["high" "medium" "low" "normal" "default"])
|
|
|
|
(assertValueOneOf "EmitDNS" boolValues)
|
|
|
|
(assertValueOneOf "EmitDomains" boolValues)
|
|
|
|
];
|
|
|
|
|
|
|
|
sectionIPv6Prefix = checkUnitConfig "IPv6Prefix" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"AddressAutoconfiguration"
|
|
|
|
"OnLink"
|
|
|
|
"Prefix"
|
|
|
|
"PreferredLifetimeSec"
|
|
|
|
"ValidLifetimeSec"
|
2022-10-21 18:38:19 +00:00
|
|
|
"Token"
|
2020-08-20 17:08:02 +00:00
|
|
|
])
|
|
|
|
(assertValueOneOf "AddressAutoconfiguration" boolValues)
|
|
|
|
(assertValueOneOf "OnLink" boolValues)
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
sectionIPv6RoutePrefix = checkUnitConfig "IPv6RoutePrefix" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"Route"
|
|
|
|
"LifetimeSec"
|
|
|
|
])
|
|
|
|
(assertHasField "Route")
|
|
|
|
(assertInt "LifetimeSec")
|
|
|
|
];
|
|
|
|
|
2021-12-19 01:06:50 +00:00
|
|
|
sectionDHCPServerStaticLease = checkUnitConfig "DHCPServerStaticLease" [
|
|
|
|
(assertOnlyFields [
|
|
|
|
"MACAddress"
|
|
|
|
"Address"
|
|
|
|
])
|
|
|
|
(assertHasField "MACAddress")
|
|
|
|
(assertHasField "Address")
|
|
|
|
(assertMacAddress "MACAddress")
|
|
|
|
];
|
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
};
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
commonNetworkOptions = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = true;
|
|
|
|
type = types.bool;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
|
|
|
Whether to manage network configuration using {command}`systemd-network`.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
matchConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { Name = "eth0"; };
|
|
|
|
type = types.attrsOf unitOption;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-12 12:06:08 +00:00
|
|
|
`[Match]` section of the unit. See
|
|
|
|
{manpage}`systemd.link(5)`
|
|
|
|
{manpage}`systemd.netdev(5)`
|
|
|
|
{manpage}`systemd.network(5)`
|
2020-04-24 23:36:52 +00:00
|
|
|
for details.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
|
|
|
default = "";
|
|
|
|
type = types.lines;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Extra configuration append to unit";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-03-13 04:00:48 +00:00
|
|
|
networkdOptions = {
|
|
|
|
networkConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { SpeedMeter = true; ManageForeignRoutingPolicyRules = false; };
|
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.global.sectionNetwork;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-03-13 04:00:48 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[Network]` section of the networkd config.
|
|
|
|
See {manpage}`networkd.conf(5)` for details.
|
2022-03-13 04:00:48 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
dhcpV4Config = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { DUIDType = "vendor"; };
|
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.global.sectionDHCPv4;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-03-13 04:00:48 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[DHCPv4]` section of the networkd config.
|
|
|
|
See {manpage}`networkd.conf(5)` for details.
|
2022-03-13 04:00:48 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
dhcpV6Config = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { DUIDType = "vendor"; };
|
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.global.sectionDHCPv6;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-03-13 04:00:48 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[DHCPv6]` section of the networkd config.
|
|
|
|
See {manpage}`networkd.conf(5)` for details.
|
2022-03-13 04:00:48 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
linkOptions = commonNetworkOptions // {
|
|
|
|
# overwrite enable option from above
|
|
|
|
enable = mkOption {
|
|
|
|
default = true;
|
|
|
|
type = types.bool;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
|
|
|
Whether to enable this .link unit. It's handled by udev no matter if {command}`systemd-networkd` is enabled or not
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
linkConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { MACAddress = "00:ff:ee:aa:cc:dd"; };
|
2020-08-20 17:08:02 +00:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.link.sectionLink;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[Link]` section of the unit. See
|
|
|
|
{manpage}`systemd.link(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
wireguardPeerOptions = {
|
|
|
|
options = {
|
|
|
|
wireguardPeerConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionWireGuardPeer;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-08-20 17:08:02 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[WireGuardPeer]` section of the unit. See
|
|
|
|
{manpage}`systemd.network(5)` for details.
|
2020-08-20 17:08:02 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
netdevOptions = commonNetworkOptions // {
|
|
|
|
|
|
|
|
netdevConfig = mkOption {
|
|
|
|
example = { Name = "mybridge"; Kind = "bridge"; };
|
2020-08-20 17:08:02 +00:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionNetdev;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[Netdev]` section of the unit. See
|
|
|
|
{manpage}`systemd.netdev(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
vlanConfig = mkOption {
|
|
|
|
default = {};
|
2020-07-18 16:06:22 +00:00
|
|
|
example = { Id = 4; };
|
2020-08-20 17:08:02 +00:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionVLAN;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[VLAN]` section of the unit. See
|
|
|
|
{manpage}`systemd.netdev(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
macvlanConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { Mode = "private"; };
|
2020-08-20 17:08:02 +00:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionMACVLAN;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[MACVLAN]` section of the unit. See
|
|
|
|
{manpage}`systemd.netdev(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
vxlanConfig = mkOption {
|
|
|
|
default = {};
|
2020-08-20 17:08:02 +00:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionVXLAN;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[VXLAN]` section of the unit. See
|
|
|
|
{manpage}`systemd.netdev(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
tunnelConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { Remote = "192.168.1.1"; };
|
2020-08-20 17:08:02 +00:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionTunnel;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[Tunnel]` section of the unit. See
|
|
|
|
{manpage}`systemd.netdev(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-10-17 02:12:59 +00:00
|
|
|
fooOverUDPConfig = mkOption {
|
|
|
|
default = { };
|
|
|
|
example = { Port = 9001; };
|
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionFooOverUDP;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-10-17 02:12:59 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[FooOverUDP]` section of the unit. See
|
|
|
|
{manpage}`systemd.netdev(5)` for details.
|
2021-10-17 02:12:59 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
peerConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { Name = "veth2"; };
|
2020-08-20 17:08:02 +00:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionPeer;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[Peer]` section of the unit. See
|
|
|
|
{manpage}`systemd.netdev(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
tunConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { User = "openvpn"; };
|
2020-08-20 17:08:02 +00:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionTun;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[Tun]` section of the unit. See
|
|
|
|
{manpage}`systemd.netdev(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
tapConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { User = "openvpn"; };
|
2020-08-20 17:08:02 +00:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionTap;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[Tap]` section of the unit. See
|
|
|
|
{manpage}`systemd.netdev(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
wireguardConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = {
|
|
|
|
PrivateKeyFile = "/etc/wireguard/secret.key";
|
|
|
|
ListenPort = 51820;
|
2021-10-06 13:57:05 +00:00
|
|
|
FirewallMark = 42;
|
2020-08-20 17:08:02 +00:00
|
|
|
};
|
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionWireGuard;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-08-20 17:08:02 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[WireGuard]` section of the unit. See
|
|
|
|
{manpage}`systemd.netdev(5)` for details.
|
|
|
|
Use `PrivateKeyFile` instead of
|
|
|
|
`PrivateKey`: the nix store is
|
2020-08-20 17:08:02 +00:00
|
|
|
world-readable.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
wireguardPeers = mkOption {
|
|
|
|
default = [];
|
|
|
|
example = [ { wireguardPeerConfig={
|
|
|
|
Endpoint = "192.168.1.1:51820";
|
|
|
|
PublicKey = "27s0OvaBBdHoJYkH9osZpjpgSOVNw+RaKfboT/Sfq0g=";
|
|
|
|
PresharedKeyFile = "/etc/wireguard/psk.key";
|
|
|
|
AllowedIPs = [ "10.0.0.1/32" ];
|
|
|
|
PersistentKeepalive = 15;
|
|
|
|
};}];
|
|
|
|
type = with types; listOf (submodule wireguardPeerOptions);
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-08-20 17:08:02 +00:00
|
|
|
Each item in this array specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[WireGuardPeer]` section of the unit. See
|
|
|
|
{manpage}`systemd.netdev(5)` for details.
|
|
|
|
Use `PresharedKeyFile` instead of
|
|
|
|
`PresharedKey`: the nix store is
|
2020-08-20 17:08:02 +00:00
|
|
|
world-readable.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
bondConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { Mode = "802.3ad"; };
|
2020-08-20 17:08:02 +00:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionBond;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[Bond]` section of the unit. See
|
|
|
|
{manpage}`systemd.netdev(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
xfrmConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { InterfaceId = 1; };
|
2020-08-20 17:08:02 +00:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionXfrm;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[Xfrm]` section of the unit. See
|
|
|
|
{manpage}`systemd.netdev(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
vrfConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { Table = 2342; };
|
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionVRF;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-08-20 17:08:02 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[VRF]` section of the unit. See
|
|
|
|
{manpage}`systemd.netdev(5)` for details.
|
2020-08-20 17:08:02 +00:00
|
|
|
A detailed explanation about how VRFs work can be found in the
|
2022-08-21 13:32:41 +00:00
|
|
|
[kernel docs](https://www.kernel.org/doc/Documentation/networking/vrf.txt).
|
2020-08-20 17:08:02 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
batmanAdvancedConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = {
|
|
|
|
GatewayMode = "server";
|
|
|
|
RoutingAlgorithm = "batman-v";
|
|
|
|
};
|
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.netdev.sectionBatmanAdvanced;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-12-06 16:07:01 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[BatmanAdvanced]` section of the unit. See
|
|
|
|
{manpage}`systemd.netdev(5)` for details.
|
2021-12-06 16:07:01 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
addressOptions = {
|
|
|
|
options = {
|
|
|
|
addressConfig = mkOption {
|
|
|
|
example = { Address = "192.168.0.100/24"; };
|
2020-08-20 17:08:02 +00:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.network.sectionAddress;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[Address]` section of the unit. See
|
|
|
|
{manpage}`systemd.network(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
routingPolicyRulesOptions = {
|
|
|
|
options = {
|
|
|
|
routingPolicyRuleConfig = mkOption {
|
|
|
|
default = { };
|
2021-10-06 13:57:05 +00:00
|
|
|
example = { Table = 10; IncomingInterface = "eth1"; Family = "both"; };
|
2020-08-20 17:08:02 +00:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.network.sectionRoutingPolicyRule;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[RoutingPolicyRule]` section of the unit. See
|
|
|
|
{manpage}`systemd.network(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
routeOptions = {
|
|
|
|
options = {
|
|
|
|
routeConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { Gateway = "192.168.0.1"; };
|
2020-08-20 17:08:02 +00:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.network.sectionRoute;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[Route]` section of the unit. See
|
|
|
|
{manpage}`systemd.network(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-05-03 17:38:23 +00:00
|
|
|
ipv6PrefixOptions = {
|
|
|
|
options = {
|
|
|
|
ipv6PrefixConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { Prefix = "fd00::/64"; };
|
2020-08-20 17:08:02 +00:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.network.sectionIPv6Prefix;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-05-03 17:38:23 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[IPv6Prefix]` section of the unit. See
|
|
|
|
{manpage}`systemd.network(5)` for details.
|
2020-05-03 17:38:23 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
ipv6RoutePrefixOptions = {
|
|
|
|
options = {
|
|
|
|
ipv6RoutePrefixConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { Route = "fd00::/64"; };
|
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.network.sectionIPv6RoutePrefix;
|
2022-09-11 15:47:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-09-09 14:08:57 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-09-11 15:47:08 +00:00
|
|
|
`[IPv6RoutePrefix]` section of the unit. See
|
|
|
|
{manpage}`systemd.network(5)` for details.
|
2022-09-09 14:08:57 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-12-19 01:06:50 +00:00
|
|
|
dhcpServerStaticLeaseOptions = {
|
|
|
|
options = {
|
|
|
|
dhcpServerStaticLeaseConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { MACAddress = "65:43:4a:5b:d8:5f"; Address = "192.168.1.42"; };
|
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.network.sectionDHCPServerStaticLease;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-12-19 01:06:50 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[DHCPServerStaticLease]` section of the unit. See
|
|
|
|
{manpage}`systemd.network(5)` for details.
|
2021-12-19 01:06:50 +00:00
|
|
|
|
|
|
|
Make sure to configure the corresponding client interface to use
|
2022-08-21 13:32:41 +00:00
|
|
|
`ClientIdentifier=mac`.
|
2021-12-19 01:06:50 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
networkOptions = commonNetworkOptions // {
|
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
linkConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { Unmanaged = true; };
|
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.network.sectionLink;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-08-20 17:08:02 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[Link]` section of the unit. See
|
|
|
|
{manpage}`systemd.network(5)` for details.
|
2020-08-20 17:08:02 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
networkConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { Description = "My Network"; };
|
2020-08-20 17:08:02 +00:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.network.sectionNetwork;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[Network]` section of the unit. See
|
|
|
|
{manpage}`systemd.network(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-05-03 17:38:23 +00:00
|
|
|
# systemd.network.networks.*.dhcpConfig has been deprecated in favor of ….dhcpV4Config
|
|
|
|
# Produce a nice warning message so users know it is gone.
|
2020-04-24 23:36:52 +00:00
|
|
|
dhcpConfig = mkOption {
|
2020-05-03 17:38:23 +00:00
|
|
|
visible = false;
|
|
|
|
apply = _: throw "The option `systemd.network.networks.*.dhcpConfig` can no longer be used since it's been removed. Please use `systemd.network.networks.*.dhcpV4Config` instead.";
|
|
|
|
};
|
|
|
|
|
|
|
|
dhcpV4Config = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { UseDNS = true; UseRoutes = true; };
|
2020-08-20 17:08:02 +00:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.network.sectionDHCPv4;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-05-03 17:38:23 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[DHCPv4]` section of the unit. See
|
|
|
|
{manpage}`systemd.network(5)` for details.
|
2020-05-03 17:38:23 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
dhcpV6Config = mkOption {
|
2020-04-24 23:36:52 +00:00
|
|
|
default = {};
|
2021-10-06 13:57:05 +00:00
|
|
|
example = { UseDNS = true; };
|
2020-08-20 17:08:02 +00:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.network.sectionDHCPv6;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-05-03 17:38:23 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[DHCPv6]` section of the unit. See
|
|
|
|
{manpage}`systemd.network(5)` for details.
|
2020-05-03 17:38:23 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
dhcpV6PrefixDelegationConfig = mkOption {
|
2022-10-21 18:38:19 +00:00
|
|
|
visible = false;
|
|
|
|
apply = _: throw "The option `systemd.network.networks.<name>.dhcpV6PrefixDelegationConfig` has been renamed to `systemd.network.networks.<name>.dhcpPrefixDelegationConfig`.";
|
|
|
|
};
|
|
|
|
|
|
|
|
dhcpPrefixDelegationConfig = mkOption {
|
2021-03-09 03:18:52 +00:00
|
|
|
default = {};
|
|
|
|
example = { SubnetId = "auto"; Announce = true; };
|
2022-10-21 18:38:19 +00:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.network.sectionDHCPPrefixDelegation;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-03-09 03:18:52 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-10-21 18:38:19 +00:00
|
|
|
`[DHCPPrefixDelegation]` section of the unit. See
|
2022-08-21 13:32:41 +00:00
|
|
|
{manpage}`systemd.network(5)` for details.
|
2021-03-09 03:18:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
ipv6AcceptRAConfig = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { UseDNS = true; DHCPv6Client = "always"; };
|
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.network.sectionIPv6AcceptRA;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-03-09 03:18:52 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[IPv6AcceptRA]` section of the unit. See
|
|
|
|
{manpage}`systemd.network(5)` for details.
|
2021-03-09 03:18:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
dhcpServerConfig = mkOption {
|
2020-05-03 17:38:23 +00:00
|
|
|
default = {};
|
2020-08-20 17:08:02 +00:00
|
|
|
example = { PoolOffset = 50; EmitDNS = false; };
|
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.network.sectionDHCPServer;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[DHCPServer]` section of the unit. See
|
|
|
|
{manpage}`systemd.network(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
# systemd.network.networks.*.ipv6PrefixDelegationConfig has been deprecated
|
|
|
|
# in 247 in favor of systemd.network.networks.*.ipv6SendRAConfig.
|
2020-08-20 17:08:02 +00:00
|
|
|
ipv6PrefixDelegationConfig = mkOption {
|
2021-03-09 03:18:52 +00:00
|
|
|
visible = false;
|
|
|
|
apply = _: throw "The option `systemd.network.networks.*.ipv6PrefixDelegationConfig` has been replaced by `systemd.network.networks.*.ipv6SendRAConfig`.";
|
|
|
|
};
|
|
|
|
|
|
|
|
ipv6SendRAConfig = mkOption {
|
2020-04-24 23:36:52 +00:00
|
|
|
default = {};
|
2020-08-20 17:08:02 +00:00
|
|
|
example = { EmitDNS = true; Managed = true; OtherInformation = true; };
|
2021-03-09 03:18:52 +00:00
|
|
|
type = types.addCheck (types.attrsOf unitOption) check.network.sectionIPv6SendRA;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Each attribute in this set specifies an option in the
|
2022-08-21 13:32:41 +00:00
|
|
|
`[IPv6SendRA]` section of the unit. See
|
|
|
|
{manpage}`systemd.network(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-12-19 01:06:50 +00:00
|
|
|
dhcpServerStaticLeases = mkOption {
|
|
|
|
default = [];
|
2022-08-12 12:06:08 +00:00
|
|
|
example = [ { dhcpServerStaticLeaseConfig = { MACAddress = "65:43:4a:5b:d8:5f"; Address = "192.168.1.42"; }; } ];
|
2021-12-19 01:06:50 +00:00
|
|
|
type = with types; listOf (submodule dhcpServerStaticLeaseOptions);
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-12-19 01:06:50 +00:00
|
|
|
A list of DHCPServerStaticLease sections to be added to the unit. See
|
2022-08-21 13:32:41 +00:00
|
|
|
{manpage}`systemd.network(5)` for details.
|
2021-12-19 01:06:50 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
ipv6Prefixes = mkOption {
|
|
|
|
default = [];
|
2022-08-12 12:06:08 +00:00
|
|
|
example = [ { ipv6PrefixConfig = { AddressAutoconfiguration = true; OnLink = true; }; } ];
|
2020-08-20 17:08:02 +00:00
|
|
|
type = with types; listOf (submodule ipv6PrefixOptions);
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-08-20 17:08:02 +00:00
|
|
|
A list of ipv6Prefix sections to be added to the unit. See
|
2022-08-21 13:32:41 +00:00
|
|
|
{manpage}`systemd.network(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
ipv6RoutePrefixes = mkOption {
|
|
|
|
default = [];
|
2022-09-11 15:47:08 +00:00
|
|
|
example = [ { ipv6RoutePrefixConfig = { Route = "fd00::/64"; LifetimeSec = 3600; }; } ];
|
2022-09-09 14:08:57 +00:00
|
|
|
type = with types; listOf (submodule ipv6RoutePrefixOptions);
|
2022-09-11 15:47:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-09-09 14:08:57 +00:00
|
|
|
A list of ipv6RoutePrefix sections to be added to the unit. See
|
2022-09-11 15:47:08 +00:00
|
|
|
{manpage}`systemd.network(5)` for details.
|
2022-09-09 14:08:57 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
name = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
The name of the network interface to match against.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
DHCP = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Whether to enable DHCP on the interfaces matched.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
domains = mkOption {
|
|
|
|
type = types.nullOr (types.listOf types.str);
|
|
|
|
default = null;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
A list of domains to pass to the network config.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
address = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.str;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
A list of addresses to be added to the network section of the
|
2022-08-21 13:32:41 +00:00
|
|
|
unit. See {manpage}`systemd.network(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
gateway = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.str;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
A list of gateways to be added to the network section of the
|
2022-08-21 13:32:41 +00:00
|
|
|
unit. See {manpage}`systemd.network(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
dns = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.str;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
A list of dns servers to be added to the network section of the
|
2022-08-21 13:32:41 +00:00
|
|
|
unit. See {manpage}`systemd.network(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
ntp = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.str;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
A list of ntp servers to be added to the network section of the
|
2022-08-21 13:32:41 +00:00
|
|
|
unit. See {manpage}`systemd.network(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
bridge = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.str;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
A list of bridge interfaces to be added to the network section of the
|
2022-08-21 13:32:41 +00:00
|
|
|
unit. See {manpage}`systemd.network(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
bond = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.str;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
A list of bond interfaces to be added to the network section of the
|
2022-08-21 13:32:41 +00:00
|
|
|
unit. See {manpage}`systemd.network(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
vrf = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.str;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
A list of vrf interfaces to be added to the network section of the
|
2022-08-21 13:32:41 +00:00
|
|
|
unit. See {manpage}`systemd.network(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
vlan = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.str;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
A list of vlan interfaces to be added to the network section of the
|
2022-08-21 13:32:41 +00:00
|
|
|
unit. See {manpage}`systemd.network(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
macvlan = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.str;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
A list of macvlan interfaces to be added to the network section of the
|
2022-08-21 13:32:41 +00:00
|
|
|
unit. See {manpage}`systemd.network(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
vxlan = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.str;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
A list of vxlan interfaces to be added to the network section of the
|
2022-08-21 13:32:41 +00:00
|
|
|
unit. See {manpage}`systemd.network(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
tunnel = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.str;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
A list of tunnel interfaces to be added to the network section of the
|
2022-08-21 13:32:41 +00:00
|
|
|
unit. See {manpage}`systemd.network(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
xfrm = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = types.listOf types.str;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
A list of xfrm interfaces to be added to the network section of the
|
2022-08-21 13:32:41 +00:00
|
|
|
unit. See {manpage}`systemd.network(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
addresses = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = with types; listOf (submodule addressOptions);
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
A list of address sections to be added to the unit. See
|
2022-08-21 13:32:41 +00:00
|
|
|
{manpage}`systemd.network(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
routingPolicyRules = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = with types; listOf (submodule routingPolicyRulesOptions);
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
A list of routing policy rules sections to be added to the unit. See
|
2022-08-21 13:32:41 +00:00
|
|
|
{manpage}`systemd.network(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
routes = mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = with types; listOf (submodule routeOptions);
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
A list of route sections to be added to the unit. See
|
2022-08-21 13:32:41 +00:00
|
|
|
{manpage}`systemd.network(5)` for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
networkConfig = { config, ... }: {
|
|
|
|
config = {
|
|
|
|
matchConfig = optionalAttrs (config.name != null) {
|
|
|
|
Name = config.name;
|
|
|
|
};
|
|
|
|
networkConfig = optionalAttrs (config.DHCP != null) {
|
|
|
|
DHCP = config.DHCP;
|
|
|
|
} // optionalAttrs (config.domains != null) {
|
|
|
|
Domains = concatStringsSep " " config.domains;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-03-13 04:00:48 +00:00
|
|
|
networkdConfig = { config, ... }: {
|
|
|
|
options = {
|
|
|
|
routeTables = mkOption {
|
|
|
|
default = {};
|
|
|
|
example = { foo = 27; };
|
|
|
|
type = with types; attrsOf int;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-03-13 04:00:48 +00:00
|
|
|
Defines route table names as an attrset of name to number.
|
2022-08-21 13:32:41 +00:00
|
|
|
See {manpage}`networkd.conf(5)` for details.
|
2022-03-13 04:00:48 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
addRouteTablesToIPRoute2 = mkOption {
|
|
|
|
default = true;
|
|
|
|
example = false;
|
|
|
|
type = types.bool;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-03-13 04:00:48 +00:00
|
|
|
If true and routeTables are set, then the specified route tables
|
|
|
|
will also be installed into /etc/iproute2/rt_tables.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
networkConfig = optionalAttrs (config.routeTables != { }) {
|
|
|
|
RouteTable = mapAttrsToList
|
|
|
|
(name: number: "${name}:${toString number}")
|
|
|
|
config.routeTables;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
commonMatchText = def: optionalString (def.matchConfig != { }) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
[Match]
|
|
|
|
${attrsToSection def.matchConfig}
|
|
|
|
'';
|
|
|
|
|
|
|
|
linkToUnit = name: def:
|
|
|
|
{ inherit (def) enable;
|
2020-08-20 17:08:02 +00:00
|
|
|
text = commonMatchText def
|
|
|
|
+ ''
|
2020-04-24 23:36:52 +00:00
|
|
|
[Link]
|
|
|
|
${attrsToSection def.linkConfig}
|
2020-08-20 17:08:02 +00:00
|
|
|
''
|
|
|
|
+ def.extraConfig;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
netdevToUnit = name: def:
|
|
|
|
{ inherit (def) enable;
|
2020-08-20 17:08:02 +00:00
|
|
|
text = commonMatchText def
|
|
|
|
+ ''
|
2020-04-24 23:36:52 +00:00
|
|
|
[NetDev]
|
|
|
|
${attrsToSection def.netdevConfig}
|
2020-08-20 17:08:02 +00:00
|
|
|
''
|
|
|
|
+ optionalString (def.vlanConfig != { }) ''
|
|
|
|
[VLAN]
|
|
|
|
${attrsToSection def.vlanConfig}
|
|
|
|
''
|
|
|
|
+ optionalString (def.macvlanConfig != { }) ''
|
|
|
|
[MACVLAN]
|
|
|
|
${attrsToSection def.macvlanConfig}
|
|
|
|
''
|
|
|
|
+ optionalString (def.vxlanConfig != { }) ''
|
|
|
|
[VXLAN]
|
|
|
|
${attrsToSection def.vxlanConfig}
|
|
|
|
''
|
|
|
|
+ optionalString (def.tunnelConfig != { }) ''
|
|
|
|
[Tunnel]
|
|
|
|
${attrsToSection def.tunnelConfig}
|
|
|
|
''
|
2021-10-17 02:12:59 +00:00
|
|
|
+ optionalString (def.fooOverUDPConfig != { }) ''
|
|
|
|
[FooOverUDP]
|
|
|
|
${attrsToSection def.fooOverUDPConfig}
|
|
|
|
''
|
2020-08-20 17:08:02 +00:00
|
|
|
+ optionalString (def.peerConfig != { }) ''
|
|
|
|
[Peer]
|
|
|
|
${attrsToSection def.peerConfig}
|
|
|
|
''
|
|
|
|
+ optionalString (def.tunConfig != { }) ''
|
|
|
|
[Tun]
|
|
|
|
${attrsToSection def.tunConfig}
|
|
|
|
''
|
|
|
|
+ optionalString (def.tapConfig != { }) ''
|
|
|
|
[Tap]
|
|
|
|
${attrsToSection def.tapConfig}
|
|
|
|
''
|
|
|
|
+ optionalString (def.wireguardConfig != { }) ''
|
|
|
|
[WireGuard]
|
|
|
|
${attrsToSection def.wireguardConfig}
|
|
|
|
''
|
|
|
|
+ flip concatMapStrings def.wireguardPeers (x: ''
|
|
|
|
[WireGuardPeer]
|
|
|
|
${attrsToSection x.wireguardPeerConfig}
|
|
|
|
'')
|
|
|
|
+ optionalString (def.bondConfig != { }) ''
|
|
|
|
[Bond]
|
|
|
|
${attrsToSection def.bondConfig}
|
|
|
|
''
|
|
|
|
+ optionalString (def.xfrmConfig != { }) ''
|
|
|
|
[Xfrm]
|
|
|
|
${attrsToSection def.xfrmConfig}
|
|
|
|
''
|
|
|
|
+ optionalString (def.vrfConfig != { }) ''
|
|
|
|
[VRF]
|
|
|
|
${attrsToSection def.vrfConfig}
|
|
|
|
''
|
2021-12-06 16:07:01 +00:00
|
|
|
+ optionalString (def.batmanAdvancedConfig != { }) ''
|
|
|
|
[BatmanAdvanced]
|
|
|
|
${attrsToSection def.batmanAdvancedConfig}
|
|
|
|
''
|
2020-08-20 17:08:02 +00:00
|
|
|
+ def.extraConfig;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-03-13 04:00:48 +00:00
|
|
|
renderConfig = def:
|
|
|
|
{ text = ''
|
|
|
|
[Network]
|
2022-04-15 01:41:22 +00:00
|
|
|
${attrsToSection def.networkConfig}
|
2022-03-13 04:00:48 +00:00
|
|
|
''
|
|
|
|
+ optionalString (def.dhcpV4Config != { }) ''
|
|
|
|
[DHCPv4]
|
|
|
|
${attrsToSection def.dhcpV4Config}
|
|
|
|
''
|
|
|
|
+ optionalString (def.dhcpV6Config != { }) ''
|
|
|
|
[DHCPv6]
|
|
|
|
${attrsToSection def.dhcpV6Config}
|
|
|
|
''; };
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
networkToUnit = name: def:
|
|
|
|
{ inherit (def) enable;
|
2020-08-20 17:08:02 +00:00
|
|
|
text = commonMatchText def
|
|
|
|
+ optionalString (def.linkConfig != { }) ''
|
|
|
|
[Link]
|
|
|
|
${attrsToSection def.linkConfig}
|
2020-04-24 23:36:52 +00:00
|
|
|
''
|
2020-08-20 17:08:02 +00:00
|
|
|
+ ''
|
2020-04-24 23:36:52 +00:00
|
|
|
[Network]
|
2020-08-20 17:08:02 +00:00
|
|
|
''
|
|
|
|
+ attrsToSection def.networkConfig
|
|
|
|
+ optionalString (def.address != [ ]) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
${concatStringsSep "\n" (map (s: "Address=${s}") def.address)}
|
2020-08-20 17:08:02 +00:00
|
|
|
''
|
|
|
|
+ optionalString (def.gateway != [ ]) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
${concatStringsSep "\n" (map (s: "Gateway=${s}") def.gateway)}
|
2020-08-20 17:08:02 +00:00
|
|
|
''
|
|
|
|
+ optionalString (def.dns != [ ]) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
${concatStringsSep "\n" (map (s: "DNS=${s}") def.dns)}
|
2020-08-20 17:08:02 +00:00
|
|
|
''
|
|
|
|
+ optionalString (def.ntp != [ ]) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
${concatStringsSep "\n" (map (s: "NTP=${s}") def.ntp)}
|
2020-08-20 17:08:02 +00:00
|
|
|
''
|
|
|
|
+ optionalString (def.bridge != [ ]) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
${concatStringsSep "\n" (map (s: "Bridge=${s}") def.bridge)}
|
2020-08-20 17:08:02 +00:00
|
|
|
''
|
|
|
|
+ optionalString (def.bond != [ ]) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
${concatStringsSep "\n" (map (s: "Bond=${s}") def.bond)}
|
2020-08-20 17:08:02 +00:00
|
|
|
''
|
|
|
|
+ optionalString (def.vrf != [ ]) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
${concatStringsSep "\n" (map (s: "VRF=${s}") def.vrf)}
|
2020-08-20 17:08:02 +00:00
|
|
|
''
|
|
|
|
+ optionalString (def.vlan != [ ]) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
${concatStringsSep "\n" (map (s: "VLAN=${s}") def.vlan)}
|
2020-08-20 17:08:02 +00:00
|
|
|
''
|
|
|
|
+ optionalString (def.macvlan != [ ]) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
${concatStringsSep "\n" (map (s: "MACVLAN=${s}") def.macvlan)}
|
2020-08-20 17:08:02 +00:00
|
|
|
''
|
|
|
|
+ optionalString (def.vxlan != [ ]) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
${concatStringsSep "\n" (map (s: "VXLAN=${s}") def.vxlan)}
|
2020-08-20 17:08:02 +00:00
|
|
|
''
|
|
|
|
+ optionalString (def.tunnel != [ ]) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
${concatStringsSep "\n" (map (s: "Tunnel=${s}") def.tunnel)}
|
2020-08-20 17:08:02 +00:00
|
|
|
''
|
|
|
|
+ optionalString (def.xfrm != [ ]) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
${concatStringsSep "\n" (map (s: "Xfrm=${s}") def.xfrm)}
|
2020-08-20 17:08:02 +00:00
|
|
|
''
|
|
|
|
+ ''
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
''
|
|
|
|
+ flip concatMapStrings def.addresses (x: ''
|
|
|
|
[Address]
|
|
|
|
${attrsToSection x.addressConfig}
|
|
|
|
'')
|
|
|
|
+ flip concatMapStrings def.routingPolicyRules (x: ''
|
|
|
|
[RoutingPolicyRule]
|
|
|
|
${attrsToSection x.routingPolicyRuleConfig}
|
|
|
|
'')
|
|
|
|
+ flip concatMapStrings def.routes (x: ''
|
|
|
|
[Route]
|
|
|
|
${attrsToSection x.routeConfig}
|
|
|
|
'')
|
|
|
|
+ optionalString (def.dhcpV4Config != { }) ''
|
|
|
|
[DHCPv4]
|
|
|
|
${attrsToSection def.dhcpV4Config}
|
|
|
|
''
|
|
|
|
+ optionalString (def.dhcpV6Config != { }) ''
|
|
|
|
[DHCPv6]
|
|
|
|
${attrsToSection def.dhcpV6Config}
|
|
|
|
''
|
2022-10-21 18:38:19 +00:00
|
|
|
+ optionalString (def.dhcpPrefixDelegationConfig != { }) ''
|
|
|
|
[DHCPPrefixDelegation]
|
|
|
|
${attrsToSection def.dhcpPrefixDelegationConfig}
|
2021-03-09 03:18:52 +00:00
|
|
|
''
|
|
|
|
+ optionalString (def.ipv6AcceptRAConfig != { }) ''
|
|
|
|
[IPv6AcceptRA]
|
|
|
|
${attrsToSection def.ipv6AcceptRAConfig}
|
|
|
|
''
|
2020-08-20 17:08:02 +00:00
|
|
|
+ optionalString (def.dhcpServerConfig != { }) ''
|
|
|
|
[DHCPServer]
|
|
|
|
${attrsToSection def.dhcpServerConfig}
|
|
|
|
''
|
2021-03-09 03:18:52 +00:00
|
|
|
+ optionalString (def.ipv6SendRAConfig != { }) ''
|
|
|
|
[IPv6SendRA]
|
|
|
|
${attrsToSection def.ipv6SendRAConfig}
|
2020-08-20 17:08:02 +00:00
|
|
|
''
|
|
|
|
+ flip concatMapStrings def.ipv6Prefixes (x: ''
|
|
|
|
[IPv6Prefix]
|
|
|
|
${attrsToSection x.ipv6PrefixConfig}
|
|
|
|
'')
|
2022-09-09 14:08:57 +00:00
|
|
|
+ flip concatMapStrings def.ipv6RoutePrefixes (x: ''
|
|
|
|
[IPv6RoutePrefix]
|
|
|
|
${attrsToSection x.ipv6RoutePrefixConfig}
|
|
|
|
'')
|
2021-12-19 01:06:50 +00:00
|
|
|
+ flip concatMapStrings def.dhcpServerStaticLeases (x: ''
|
|
|
|
[DHCPServerStaticLease]
|
|
|
|
${attrsToSection x.dhcpServerStaticLeaseConfig}
|
|
|
|
'')
|
2020-08-20 17:08:02 +00:00
|
|
|
+ def.extraConfig;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unitFiles = listToAttrs (map (name: {
|
|
|
|
name = "systemd/network/${name}";
|
|
|
|
value.source = "${cfg.units.${name}.unit}/${name}";
|
2022-04-15 01:41:22 +00:00
|
|
|
}) (attrNames cfg.units));
|
2020-04-24 23:36:52 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
|
|
|
|
systemd.network.enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Whether to enable networkd or not.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.network.links = mkOption {
|
|
|
|
default = {};
|
|
|
|
type = with types; attrsOf (submodule [ { options = linkOptions; } ]);
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Definition of systemd network links.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
systemd.network.netdevs = mkOption {
|
|
|
|
default = {};
|
|
|
|
type = with types; attrsOf (submodule [ { options = netdevOptions; } ]);
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Definition of systemd network devices.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
systemd.network.networks = mkOption {
|
|
|
|
default = {};
|
|
|
|
type = with types; attrsOf (submodule [ { options = networkOptions; } networkConfig ]);
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Definition of systemd networks.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-03-13 04:00:48 +00:00
|
|
|
systemd.network.config = mkOption {
|
|
|
|
default = {};
|
|
|
|
type = with types; submodule [ { options = networkdOptions; } networkdConfig ];
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Definition of global systemd network config.";
|
2022-03-13 04:00:48 +00:00
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
systemd.network.units = mkOption {
|
2022-09-09 14:08:57 +00:00
|
|
|
description = lib.mdDoc "Definition of networkd units.";
|
2020-04-24 23:36:52 +00:00
|
|
|
default = {};
|
|
|
|
internal = true;
|
|
|
|
type = with types; attrsOf (submodule (
|
|
|
|
{ name, config, ... }:
|
|
|
|
{ options = mapAttrs (_: x: x // { internal = true; }) concreteUnitOptions;
|
|
|
|
config = {
|
|
|
|
unit = mkDefault (makeUnit name config);
|
|
|
|
};
|
|
|
|
}));
|
|
|
|
};
|
|
|
|
|
2022-04-03 18:54:34 +00:00
|
|
|
systemd.network.wait-online = {
|
|
|
|
anyInterface = mkOption {
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-04-03 18:54:34 +00:00
|
|
|
Whether to consider the network online when any interface is online, as opposed to all of them.
|
|
|
|
This is useful on portable machines with a wired and a wireless interface, for example.
|
|
|
|
'';
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
ignoredInterfaces = mkOption {
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-04-03 18:54:34 +00:00
|
|
|
Network interfaces to be ignored when deciding if the system is online.
|
|
|
|
'';
|
|
|
|
type = with types; listOf str;
|
|
|
|
default = [];
|
|
|
|
example = [ "wg0" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
timeout = mkOption {
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-04-03 18:54:34 +00:00
|
|
|
Time to wait for the network to come online, in seconds. Set to 0 to disable.
|
|
|
|
'';
|
|
|
|
type = types.ints.unsigned;
|
|
|
|
default = 120;
|
|
|
|
example = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
extraArgs = mkOption {
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-04-03 18:54:34 +00:00
|
|
|
Extra command-line arguments to pass to systemd-networkd-wait-online.
|
2022-08-12 12:06:08 +00:00
|
|
|
These also affect per-interface `systemd-network-wait-online@` services.
|
2022-04-03 18:54:34 +00:00
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
See [{manpage}`systemd-networkd-wait-online.service(8)`](https://www.freedesktop.org/software/systemd/man/systemd-networkd-wait-online.service.html) for all available options.
|
2022-04-03 18:54:34 +00:00
|
|
|
'';
|
|
|
|
type = with types; listOf str;
|
|
|
|
default = [];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkMerge [
|
2020-05-03 17:38:23 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# .link units are honored by udev, no matter if systemd-networkd is enabled or not.
|
|
|
|
{
|
|
|
|
systemd.network.units = mapAttrs' (n: v: nameValuePair "${n}.link" (linkToUnit n v)) cfg.links;
|
|
|
|
environment.etc = unitFiles;
|
2022-04-03 18:54:34 +00:00
|
|
|
|
|
|
|
systemd.network.wait-online.extraArgs =
|
|
|
|
[ "--timeout=${toString cfg.wait-online.timeout}" ]
|
|
|
|
++ optional cfg.wait-online.anyInterface "--any"
|
|
|
|
++ map (i: "--ignore=${i}") cfg.wait-online.ignoredInterfaces;
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
(mkIf config.systemd.network.enable {
|
|
|
|
|
|
|
|
users.users.systemd-network.group = "systemd-network";
|
|
|
|
|
|
|
|
systemd.additionalUpstreamSystemUnits = [
|
2020-06-18 07:06:33 +00:00
|
|
|
"systemd-networkd-wait-online.service"
|
|
|
|
"systemd-networkd.service"
|
|
|
|
"systemd-networkd.socket"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
systemd.network.units = mapAttrs' (n: v: nameValuePair "${n}.netdev" (netdevToUnit n v)) cfg.netdevs
|
|
|
|
// mapAttrs' (n: v: nameValuePair "${n}.network" (networkToUnit n v)) cfg.networks;
|
|
|
|
|
2020-06-18 07:06:33 +00:00
|
|
|
# systemd-networkd is socket-activated by kernel netlink route change
|
|
|
|
# messages. It is important to have systemd buffer those on behalf of
|
|
|
|
# networkd.
|
|
|
|
systemd.sockets.systemd-networkd.wantedBy = [ "sockets.target" ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
systemd.services.systemd-networkd = {
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2020-06-18 07:06:33 +00:00
|
|
|
aliases = [ "dbus-org.freedesktop.network1.service" ];
|
2022-03-13 04:00:48 +00:00
|
|
|
restartTriggers = map (x: x.source) (attrValues unitFiles) ++ [
|
|
|
|
config.environment.etc."systemd/networkd.conf".source
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.systemd-networkd-wait-online = {
|
|
|
|
wantedBy = [ "network-online.target" ];
|
2022-04-03 18:54:34 +00:00
|
|
|
serviceConfig.ExecStart = [
|
|
|
|
""
|
|
|
|
"${config.systemd.package}/lib/systemd/systemd-networkd-wait-online ${utils.escapeSystemdExecArgs cfg.wait-online.extraArgs}"
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services."systemd-network-wait-online@" = {
|
|
|
|
description = "Wait for Network Interface %I to be Configured";
|
|
|
|
conflicts = [ "shutdown.target" ];
|
|
|
|
requisite = [ "systemd-networkd.service" ];
|
|
|
|
after = [ "systemd-networkd.service" ];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = true;
|
2022-04-03 18:54:34 +00:00
|
|
|
ExecStart = "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online -i %I ${utils.escapeSystemdExecArgs cfg.wait-online.extraArgs}";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-03-13 04:00:48 +00:00
|
|
|
environment.etc."systemd/networkd.conf" = renderConfig cfg.config;
|
|
|
|
|
|
|
|
networking.iproute2 = mkIf (cfg.config.addRouteTablesToIPRoute2 && cfg.config.routeTables != { }) {
|
|
|
|
enable = mkDefault true;
|
|
|
|
rttablesExtraConfig = ''
|
|
|
|
|
|
|
|
# Extra tables defined in NixOS systemd.networkd.config.routeTables.
|
|
|
|
${concatStringsSep "\n" (mapAttrsToList (name: number: "${toString number} ${name}") cfg.config.routeTables)}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
services.resolved.enable = mkDefault true;
|
|
|
|
})
|
|
|
|
];
|
|
|
|
}
|