Is there any example of how to set up a NAT network

Hi guys,
i follow the document and successful set up a bridge network, but i don’t know how to set up a NAT network. there is only a few topic about NAT network and the document is confusing for me. so i want to follow a NAT network example so i can follow it and solve this problem.
Thanks!

OpenNebula doesn’t perform NATing, you have to do so on your own while setting up the bridge. OpenNebula will only create the bridge automatically if it doesn’t exist when a VM requests a bridge port.

Hi,

I can share my existing setup reference as a example

Environment:
Host OS: UBUNTU 22.04
Opennebula Version: 6.6

KVM Host Setup (Follow Official Documents: KVM Node Deployment — OpenNebula 6.6.0 documentation

NAT Network Setup

Install DNSMasq

sudo su -c “apt -y install dnsmasq dnsmasq-base”

systemctl stop dnsmasq && systemctl status dnsmasq --no-pager

echo ‘[NetDev]
Name=nat-br0-nic
Kind=bridge’ > /etc/systemd/network/cloudbr0-nic.netdev

echo ‘network:
version: 2
renderer: networkd
ethernets:
nat-br0-nic: {}
bridges:
nat-br0:
addresses: [ 172.16.0.1/24 ]
interfaces: [ nat-br0-nic ]’ > /etc/netplan/cloudbr0.yaml

sudo netplan --debug generate && sudo systemctl restart systemd-networkd

echo ‘interface=nat-br0,lo
bind-interfaces’ > /etc/dnsmasq.conf

systemctl start dnsmasq && systemctl enable dnsmasq && systemctl status dnsmasq --no-pager

iptables -t nat -A POSTROUTING -s 172.16.0.0/24 ! -d 172.16.0.0/24 -j MASQUERADE

sudo sh -c “iptables-save > /etc/iptables.rules”

sudo sh -c “iptables-restore < /etc/iptables.rules”

netfilter-persistent save
iptables -t nat -L -n -v

Now Configure Network on Frontend

cat > vnet0.txt <<EOF
BRIDGE = “nat-br0”
BRIDGE_TYPE = “linux”
DESCRIPTION = “NAT Default Network”
DNS = “172.16.0.1 8.8.8.8 1.1.1.1”
GATEWAY = “172.16.0.1”
NETWORK_ADDRESS = “172.16.0.0”
NETWORK_MASK = “255.255.255.0”
OUTER_VLAN_ID = “”
PHYDEV = “”
SECURITY_GROUPS = “0”
VLAN_ID = “”
VN_MAD = “fw”
AR=[
TYPE = “IP4”,
IP = “172.16.0.2”,
SIZE = “250”
]
EOF

Hope this will help, Good Luck.

hey
While setting Up NAT in physical resources it works via vmware or vcenter might work.