This is my current network configuration:
{ lib, ... }:
let
defaultGw = "<redacted-ipv4-A>";
ipv4address = "<redacted-ipv4-B>";
defaultGw6 = "fe80::1";
ipv6address = "<redacted-ipv6-C>::1";
in
{
networking = {
defaultGateway = defaultGw;
defaultGateway6 = defaultGw6;
dhcpcd.enable = false;
enableIPv6 = true;
interfaces = {
ens18 = {
ipv4.addresses = [
{ address=ipv4address; prefixLength=20; }
];
ipv6.addresses = [
{ address=ipv6address; prefixLength=64; }
];
ipv4.routes = [ { address = defaultGw; prefixLength = 32; } ];
ipv6.routes = [ { address = defaultGw6; prefixLength = 128; } ];
};
};
nameservers = [ "8.8.8.8" ];
usePredictableInterfaceNames = lib.mkForce false;
};
services.udev.extraRules = ''
ATTR{address}=="<redacted-ipv6-D>", NAME="ens18"
'';
}
My VPS admin panel shows this info:
IPv4 addresses
IP: <redacted-ipv4-B>
Gateway: <redacted-ipv4-A>
Netmask: 255.255.255.0/24
rDNS: 80.246.56.2.in-addr.arpa.
IPv6 /64 subnets
First IP: <redacted-ipv6-C>::1
Subnet: <redacted-ipv6-C>:0:0:0:0/64
Gateway: fe80::1
Netmask: <redacted-ipv6-C>:0:0:0:0
My configuration builds ok, but fails like this on switch:
$ sudo /nix/var/nix/profiles/system/bin/switch-to-configuration switch
updating GRUB 2 menu...
activating the configuration...
setting up /etc...
reloading user units for stian...
setting up tmpfiles
warning: the following units failed: network-setup.service
Ă— network-setup.service - Networking Setup
Loaded: loaded (/etc/systemd/system/network-setup.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Sat 2023-09-30 08:55:16 CEST; 4s ago
Process: 39381 ExecStart=/nix/store/ay57nz191vzjg40xqyz9d3zz7b64pg22-unit-script-network-setup-start/bin/network-setup-start (code=exited, status=2)
Main PID: 39381 (code=exited, status=2)
IP: 0B in, 0B out
CPU: 32ms
Sep 30 08:55:16 myvps systemd[1]: Starting Networking Setup...
Sep 30 08:55:16 myvps network-setup-start[39390]: Error: Egress device not specified.
Sep 30 08:55:16 myvps systemd[1]: network-setup.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Sep 30 08:55:16 myvps systemd[1]: network-setup.service: Failed with result 'exit-code'.
Sep 30 08:55:16 myvps systemd[1]: Failed to start Networking Setup.
This stands out: network-setup-start[39390]: Error: Egress device not specified.. I’ve googled this, but I have not been able to understand what it means.
ping for ipv4 works, but not for ipv6:
$ ping -4 google.com
PING google.com (142.250.186.110) 56(84) bytes of data.
64 bytes from fra24s06-in-f14.1e100.net (142.250.186.110): icmp_seq=1 ttl=56 time=1.05 ms
64 bytes from fra24s06-in-f14.1e100.net (142.250.186.110): icmp_seq=2 ttl=56 time=1.03 ms
^C
--- google.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 1.029/1.037/1.045/0.008 ms
$ ping -6 google.com
ping: connect: Network is unreachable
route and ifconfig says this:
$ route -6
Kernel IPv6 routing table
Destination Next Hop Flag Met Ref Use If
localhost/128 [::] U 256 2 0 lo
<redacted-ipv6-C>::/64 [::] U 256 1 0 ens18
fe80::1/128 [::] U 1024 1 0 ens18
fe80::/64 [::] U 256 1 0 ens18
[::]/0 [::] !n -1 1 0 lo
localhost/128 [::] Un 0 4 0 lo
myvps/128 [::] Un 0 2 0 ens18
myvps/128 [::] Un 0 3 0 ens18
ff00::/8 [::] U 256 3 0 ens18
[::]/0 [::] !n -1 1 0 lo
$ ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:3f:3a:b2:af txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens18: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet <redacted-ipv4-B> netmask 255.255.240.0 broadcast 0.0.0.0
inet6 fe80::4863:6ff:fe3c:fd3 prefixlen 64 scopeid 0x20<link>
inet6 <redacted-ipv6-C>::1 prefixlen 64 scopeid 0x0<global>
ether <redacted-ipv6-D> txqueuelen 1000 (Ethernet)
RX packets 14176720 bytes 1395145826 (1.2 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 199818 bytes 41086424 (39.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 832 bytes 41600 (40.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 832 bytes 41600 (40.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Question 1: Do I need a services.udev.extraRules
? What should go there? I currently have a different ipv6 address there, originally from when I used nixos-infect on a different vps.
Question 2: What am I missing, or what have I misconfigured, so that ipv6 ping doesn’t work?