^

Proxmox Bridge and Nat Interfaces Example

Article 118 in Networking

2021-01-27 05:46:00 from bugfish
Proxmox Bridge and Nat Interfaces Example
Networking / Proxmox
Last Review on: 2021-07-31 10:13:20 | Hits: 120

This script is for a proxmox host to set up 2 bridges.

1 provides static ip 4 and 6 to vservers
1 provides NAT routed connection

 

Start of /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug enp1s0f0
iface YOURMAINNETWORKADAPTER inet manual

This Bridge is for vServer with an OWN ipv4 or ipv6 address.

auto vmbr0
iface vmbr0 inet static
        address         YOURIPV4FORHOST
        netmask         YOUURSUBNET
        gateway         YOURGATEWAY
        bridge_ports   YOURMAINNETWORKADAPTER
        bridge_stp      off
        bridge_fd       0

iface vmbr0 inet6 static
        address V6ADDRESS
        netmask V6GATEWAY

        up ip -6 route add V6GATEWAY dev vmbr0
        up ip -6 route add default via V6GATEWAY dev vmbr0
        down ip -6 route del default via V6GATEWAY dev vmbr0
        down ip -6 route del V6GATEWAY dev vmbr0

Bridge for NAT Clients to connect to and get Internet Connection. Will not be reachable with static ip from outside, you will need to setup port forwarding.
But this will last to have your vservers have internet without own ipv4

auto vmbr1
iface vmbr1 inet static
        address 192.168.137.1
        netmask 255.255.255.0
        network 192.168.137.0
        broadcast 255.255.255.255
        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.137.0/24' -o vmbr0 -j MASQUERADE
    post-down iptables -t nat -D POSTROUTING -s '192.168.137.0/24' -o vmbr0 -j MASQUERADE

This code will setup all adapters you need to configure proxmox hosts.

I do not guarantee the reliability of the information given here, the code described on this page is executed at your own risk and in the event of damage or other unforeseeable consequences I am in no way responsible or liable.
Comment Section
Currently 0 Upvotes!
captcha image

System - 2021-01-27 05:46:01
We appreciate comments on our site!

Theme
1
This Website is using Session Cookies for Site Functionality and AWStats.