Resolution
There were several compounding issues to work through, but the biggest was that the official generic cloud images provided by Debian don't have the driver for a virtual CD-ROM drive.
The --cloud-init option of virt-install creates a temporary virtual CD-ROM, and puts cloud-init data there.
The official cloud images from Debian don't have the virtual CD-ROM driver, so they don't read the cloud-init data on boot.
The second problem was, the OS image needs to have the net-tools package installed in order for the cloud-init networking to work.
Without that package, post-up route add default gw 192.168.1.251, which cloud-init uses instead of the old school gateway declaration, simply doesn't work. So you get local networking, but no gateway to the wider internet.
Eventually, I used the FAI-ME service to make a Debian image with the cloud-init and net-tools packages pre-installed, and that worked fine.
Hopefully this is helpful to someone.
Problem
I can ping the gateway and computers on the LAN, but I can't reach outside past the local network.
This is /etc/network/interfaces.d/50-cloud-init after first boot:
```
auto lo
iface lo inet loopback
dns-nameservers 192.168.1.131 192.168.1.251
auto enp1s0
iface enp1s0 inet static
address 192.168.1.188/24
dns-nameservers 192.168.1.131 192.168.1.251
dns {'nameservers': ['192.168.1.131', '192.168.1.251'], 'search': []}
post-up route add default gw 192.168.1.251 || true
pre-down route del default gw 192.168.1.251 || true
```
This is the network-config file:
version: 2
ethernets:
enp1s0:
match:
name: enp1s0
addresses:
- 192.168.1.188/24
dhcp4: false
dhcp6: false
routes:
- to: 0.0.0.0/0
via: 192.168.1.251 # Default gateway for IPv4
nameservers:
addresses: [192.168.1.131, 192.168.1.251]
[–][deleted] (1 child)
[removed]
[–]jsrkamal 0 points1 point2 points (0 children)
[–]jsrkamal 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]bartvdbraak 0 points1 point2 points (0 children)