Configuring NAT and Network for LXC Containers in Proxmox VE

Proxmox VE is a powerful platform for managing virtual machines and containers. Sometimes, LXC containers require internet access, and configuring NAT (Network Address Translation) on the Proxmox host is the way to achieve this. In this guide, we’ll set up NAT for an LXC container using a custom bridge and ensure persistent connectivity.


Step 1: Add a NAT Rule on the Proxmox Host

To enable internet access for the 192.168.50.0/24 subnet used by the LXC container, add a NAT rule:


Step 2: Save the NAT Rule for Persistence

NAT rules are not persistent by default. To save the rule:


Step 3: Enable IP Forwarding

For NAT to work, IP forwarding must be enabled on the Proxmox host.


Step 4: Verify Routing on the Host

Ensure the host has the correct routing setup:

Check the routing table:
ip route
Expected output:
default via <your-gateway-IP> dev vmbr0 proto kernel onlink

192.10.10.0/24 dev vmbr0 proto kernel scope link src <your-host-IP>


Step 5: Configure the LXC Container


Step 6: Enter the Container and Configure DNS

Test connectivity:
ping 1.1.1.1


Conclusion

Following these steps, your LXC container is now configured with internet access via NAT. This setup ensures persistent NAT rules and proper routing on the Proxmox host, allowing your container to seamlessly communicate with external networks. Additionally, you’ve configured DNS resolution inside the container to resolve domain names effectively.

By using Proxmox VE’s flexibility, you can expand this setup for multiple containers or further isolate networks for advanced use cases.