proxmox – assign ipv4 and ipv6 to vm’s

hani llm yoktu? varmi? cok ayip…. cok….

Step 1 — Configure /etc/network/interfaces on the Proxmox host
bash# /etc/network/interfaces

auto lo
iface lo inet loopback

# Physical NIC
auto eth0
iface eth0 inet manual

# vmbr0 — uplink bridge (real IPv4 + IPv6 from ISP)
auto vmbr0
iface vmbr0 inet static
    address 203.0.113.1/24        # your real IPv4
    gateway 203.0.113.254
    bridge-ports eth0
    bridge-stp off
    bridge-fd 0

iface vmbr0 inet6 static
    address 2a01:xxxx:xxxx:xxxx::1/64   # your real /64 prefix, host address
    gateway fe80::1                      # ISP's link-local gateway

# vmbr1 — internal NAT bridge (no physical port)
auto vmbr1
iface vmbr1 inet static
    address 192.168.100.1/24
    bridge-ports none
    bridge-stp off
    bridge-fd 0
    post-up   echo 1 > /proc/sys/net/ipv4/ip_forward
    post-up   iptables -t nat -A POSTROUTING -s 192.168.100.0/24 -o vmbr0 -j MASQUERADE
    post-down iptables -t nat -D POSTROUTING -s 192.168.100.0/24 -o vmbr0 -j MASQUERADE
Apply with:
bashsystemctl restart networking
# or
ifreload -a

Step 2 — IPv4 DHCP for VMs via dnsmasq
Install and configure dnsmasq to hand out 192.168.100.x leases on vmbr1:
bashapt install dnsmasq
ini# /etc/dnsmasq.d/vmbr1.conf

interface=vmbr1
bind-interfaces

# IPv4 DHCP pool
dhcp-range=192.168.100.50,192.168.100.200,255.255.255.0,24h

# DNS
dhcp-option=6,1.1.1.1,8.8.8.8

# Optional: assign fixed IPs by MAC
# dhcp-host=aa:bb:cc:dd:ee:ff,192.168.100.10,myhostname
bashsystemctl enable --now dnsmasq
systemctl restart dnsmasq

Step 3 — Real IPv6 for VMs via SLAAC (Router Advertisements)
Your host has a real /64, so VMs can get real public IPv6 addresses automatically via SLAAC — no DHCPv6 needed (though you can add it).
Enable IPv6 forwarding and RA on vmbr0:
bash# /etc/sysctl.d/99-ipv6-forward.conf
net.ipv6.conf.all.forwarding = 1
net.ipv6.conf.vmbr0.accept_ra = 2   # accept RA even when forwarding
bashsysctl -p /etc/sysctl.d/99-ipv6-forward.conf
Install radvd to send Router Advertisements to VMs:
bashapt install radvd
conf# /etc/radvd.conf

interface vmbr0 {
    AdvSendAdvert on;
    MinRtrAdvInterval 30;
    MaxRtrAdvInterval 100;

    prefix 2a01:xxxx:xxxx:xxxx::/64 {
        AdvOnLink on;
        AdvAutonomous on;       # enables SLAAC — VMs self-configure an IPv6
        AdvRouterAddr on;
    };
};
bashsystemctl enable --now radvd
Each VM with SLAAC support (all modern Linux, Windows, BSD) will auto-generate a 2a01:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx address from its MAC.

Step 4 — VM network config in Proxmox
When creating a VM, attach two network interfaces:
InterfaceBridgePurposenet0vmbr0Real IPv6 via SLAACnet1vmbr1Private IPv4 via DHCP (192.168.100.x)