Create nat and shared network

tom.denet

New Member
Sep 10, 2020
1
0
1
25
Hello, guys I just installed proxmox on my Debian server but I can't figure out how to do a correct network configuration (I never liked networking and it also never liked me XD).

What I should like:
1)A network address translation (nat) interface. If I'm correct the VM and my server than share the same IP on my network.

current /etc/network/interfaces file for the network address translation (nat) interface on the server
Code:
source /etc/network/interfaces.d/*


auto lo

iface lo inet loopback


auto enx001cbeb69b4c

iface enx001cbeb69b4c inet static

address 192.168.0.185/24

gateway 192.168.0.1


# This is an autoconfigured IPv6 interface

#iface enx001cbeb69b4c inet6 auto


auto vmbr0

iface vmbr0 inet static

        address 10.140.79.1/24

        bridge-ports none

        bridge-stp off

        bridge-fd 0

        post-up   iptables -t nat -A POSTROUTING -s '10.140.79.0/24' -o enx001cbeb69b4c -j MASQUERADE

        post-down iptables -t nat -D POSTROUTING -s '10.140.79.0/24' -o enx001cbeb69b4c -j MASQUERADE


I configured the VM with IP address 10.140.79.2 . I think if i want to do this automatically I should install a DHCP server on my server. if someone has any experience in this please let me know.
current /etc/network/interfaces file for the network address translation (nat) interface on the VM:
Code:
source /etc/network/interfaces.d/*


auto lo

inface lo inet loopback

2) If it is possible I should also want an interface so that I can link the VM's to my real network (so an IP between 192.168.0.0-192.168.0.255) But I have no idea how to create that config if someone could help me with that.
subnet mask: 255.255.255.0
default gateway 192.168.0.1

Thanks in advance
Tom.denet
 
Hello, guys I just installed proxmox on my Debian server but I can't figure out how to do a correct network configuration (I never liked networking and it also never liked me XD).

What I should like:
1)A network address translation (nat) interface. If I'm correct the VM and my server than share the same IP on my network.

current /etc/network/interfaces file for the network address translation (nat) interface on the server
Code:
source /etc/network/interfaces.d/*


auto lo

iface lo inet loopback


auto enx001cbeb69b4c

iface enx001cbeb69b4c inet static

address 192.168.0.185/24

gateway 192.168.0.1


# This is an autoconfigured IPv6 interface

#iface enx001cbeb69b4c inet6 auto


auto vmbr0

iface vmbr0 inet static

        address 10.140.79.1/24

        bridge-ports none

        bridge-stp off

        bridge-fd 0

        post-up   iptables -t nat -A POSTROUTING -s '10.140.79.0/24' -o enx001cbeb69b4c -j MASQUERADE

        post-down iptables -t nat -D POSTROUTING -s '10.140.79.0/24' -o enx001cbeb69b4c -j MASQUERADE


I configured the VM with IP address 10.140.79.2 . I think if i want to do this automatically I should install a DHCP server on my server. if someone has any experience in this please let me know.
current /etc/network/interfaces file for the network address translation (nat) interface on the VM:
Code:
source /etc/network/interfaces.d/*


auto lo

inface lo inet loopback

2) If it is possible I should also want an interface so that I can link the VM's to my real network (so an IP between 192.168.0.0-192.168.0.255) But I have no idea how to create that config if someone could help me with that.
subnet mask: 255.255.255.0
default gateway 192.168.0.1

Thanks in advance
Tom.denet


Approach 2) would be the better solution is possible. Note that it works only if the router 192.168.0.1 accepts MAC addresses from virtual NICs in VMs. If so add your interface enx001cbeb69b4c to bridge vmbr0 and assign IP address 192.168.0.185 to it (instead off assigning to enx001cbeb69b4c, this is very important).

For solution 1) you have to enable routing in Proxmox host:
Code:
echo 1 > /proc/sys/net/ipv4/ip_forward

Whether DHCP or not is used is an independent question as well as how the IP address has to be assigned inside the VM. In case of DHCP for solution 1) you have of course to install a DHCP server in Promos host, if the existing router 192.168.0.1 offers DHCP you know probably already...