Skip to content

04 Static addressing ​

A NAT switch with its DHCP server turned off. Every VM gets a static address, gateway and DNS from cloud-init.

What you practice ​

  • dhcp: false on a switch
  • Static addresses, routes and DNS in a cloud-init network-config
  • The Mac's first address is the NAT gateway and DNS proxy

Topology ​

NodeImageCPUs / memoryAddressesRole
webdebian-131 / 1GiBlan 10.104.0.11/24Static 10.104.0.11
dbdebian-131 / 1GiBlan 10.104.0.12/24Static 10.104.0.12

Before you start ​

bash
vz image pull disk debian-13

Run it ​

bash
cd examples/04-static-addressing
vz validate
vz up
vz node ls
vz node console web   # login: lab / lab

Try it ​

bash
ssh lab@10.104.0.11 'ip -br addr; ip route; resolvectl status | head -20'
ssh lab@10.104.0.11 'sudo ip addr add 10.104.0.50/24 dev lan && ip -br addr show lan'
ping -c 2 10.104.0.50     # the new address answers right away

See init/web/network-config for the static configuration.

Clean up ​

bash
vz down
vz destroy --yes   # deletes the overlays and state of this lab