Guides / Networking
Add IPv4, DHCP and DNS to a VPC
When something on your network needs IPv4, such as an older device or a client that cannot do IPv6, give the VPC an IPv4 cidr. Then add DHCP to hand out addresses and DNS to serve names.
1. Give the VPC an IPv4 network
The cidr is set when the VPC is created and cannot be changed later (prefix /16 to /29). For an existing IPv6-only VPC, create a new one with a cidr. The first host address is reserved for the VPC's services.
apiVersion: network.etorm.com/v1alpha1
kind: VPC
metadata: {name: office}
spec: {cidr: 10.20.0.0/24}
2. Hand out addresses with DHCP
Every Ready member already gets exactly the address Etorm allocated for it. The pool is for other devices on the segment, and reservations give a device a fixed lease by its MAC address.
apiVersion: network.etorm.com/v1alpha1
kind: DHCPService
metadata: {name: dhcp}
spec:
vpcRef: {name: office}
leaseSeconds: 3600
pool: {start: 10.20.0.100, end: 10.20.0.199}
routers: [10.20.0.5] # e.g. a member that forwards to the internet
domain: office.test
reservations:
- {macAddress: "aa:bb:cc:dd:ee:01", ipAddress: 10.20.0.50, hostname: printer}
DHCP serves IPv4 only. IPv6 members take their address from the prefix and their MAC. A VPC can have one DHCPService. A second one is Failed with reason DuplicateService.
3. Serve names with DNS
The service answers for one zone. Names outside it go to the forwarders, if you list any.
apiVersion: network.etorm.com/v1alpha1
kind: DNSService
metadata: {name: dns}
spec:
vpcRef: {name: office}
zone: office.test
forwarders: [1.1.1.1] # optional; public addresses only
records:
- {name: intranet, type: A, value: 10.20.0.60, ttl: 300}
- {name: "@", type: TXT, value: "v=owner acme"}
You do not need to add records for members. Each one is registered as <account>.office.test, pointing at the member's address (AAAA, and A when the VPC has IPv4). If you write a record with the same name, yours wins.
Check that both services are Ready
Both services wait for the VPC. Then query a member's name from another member.
kubectl ... get dhcpservice,dnsservice
kubectl ... get dnsservice dns -o jsonpath='{.status.phase}' # Ready when the VPC is Ready
dig @10.20.0.1 laptop.office.test A # from a member
Manage DNS records lists the record types and the limits of the DNS service.
Clean up
Remove the services, then the VPC once its accounts are gone.
kubectl ... delete dnsservice dns kubectl ... delete dhcpservice dhcp kubectl ... delete vpc office # after its accounts