Public IP on KVM

Waldek

New Member
Jan 13, 2017
4
2
1
39
Hello,

i'm trying to setup a public IP on my VM and i can't get it to work.

My host interfaces file is:

auto lo
iface lo inet loopback
iface eth0 inet manual

auto vmbr0
iface vmbr0 inet static
address xxx.xxx.131.201
netmask 255.255.248.0
gateway xxx.xxx.128.1
bridge_ports eth0
bridge_stp off
bridge_fd 0

there's only one network interface on host: eth0.

I have also a public IP address:

address xxx.xxx.139.247
netmask 255.255.255.255

which i want to set on my VM.
My VM interfaces file is:

auto lo
iface lo inet loopback

auto ens18
iface ens18 inet static
address xxx.xxx.139.247
netmask 255.255.255.255
gateway xxx.xxx.128.1

but this isn't working.

I can connect to host machine using both addresses with configuration:
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address xxx.xxx.131.201
netmask 255.255.248.0
gateway xxx.xxx.128.1

auto eth0:1
iface eth0:1 inet static
address xxx.xxx.139.247
netmask 255.255.255.255
gateway xxx.xxx.128.1

I've tried different configurations, read a lot of threads with similar problems and still don't know how to configure this properly.

Thank you for your help.
 
Last edited:
Maybe i'll explain a little more what i trying to achieve:
I have a dedicated server with public IP on which i want to host 3 KVMs.

Code:
root@server:~# pveversion
pve-manager/3.1-3/dc0e9b0e (running kernel: 2.6.32-23-pve)

For now i have interfaces file with 4 IPs:
Code:
auto eth0
iface eth0 inet static
        address xxx.xxx.131.201
        netmask 255.255.248.0
        gateway xxx.xxx.128.1

auto eth0:1
iface eth0:1 inet static
        address xxx.xxx.139.247
        netmask 255.255.255.255
        gateway xxx.xxx.128.1

auto eth0:2
iface eth0:2 inet static
        address xxx.xxx.137.129
        netmask 255.255.255.255
        gateway xxx.xxx.128.1

auto eth0:3
iface eth0:3 inet static
        address xxx.xxx.142.40
        netmask 255.255.255.255
        gateway xxx.xxx.128.1
and i'm able to connect to the host using any of them.

Code:
root@server:~# ifconfig
eth0  Link encap:Ethernet  HWaddr 00:25:90:c1:ff:ea
  inet addr:xxx.xxx.131.201  Bcast:xxx.xxx.135.255  Mask:255.255.248.0
  inet6 addr: xxxx::xxx:xxxx:xxxx:xxxx/64 Scope:Link
  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  RX packets:5425 errors:0 dropped:0 overruns:0 frame:0
  TX packets:2504 errors:0 dropped:0 overruns:0 carrier:0
  collisions:0 txqueuelen:1000
  RX bytes:406582 (397.0 KiB)  TX bytes:215557 (210.5 KiB)

eth0:1  Link encap:Ethernet  HWaddr 00:25:90:c1:ff:ea
  inet addr:xxx.xxx.139.247  Bcast:xxx.xxx.139.247  Mask:255.255.255.255
  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

eth0:2  Link encap:Ethernet  HWaddr 00:25:90:c1:ff:ea
  inet addr:xxx.xxx.137.129  Bcast:xxx.xxx.137.129  Mask:255.255.255.255
  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

eth0:3  Link encap:Ethernet  HWaddr 00:25:90:c1:ff:ea
  inet addr:xxx.xxx.142.40  Bcast:xxx.xxx.142.40  Mask:255.255.255.255
  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

lo  Link encap:Local Loopback
  inet addr:127.0.0.1  Mask:255.0.0.0
  inet6 addr: ::1/128 Scope:Host
  UP LOOPBACK RUNNING  MTU:16436  Metric:1
  RX packets:114 errors:0 dropped:0 overruns:0 frame:0
  TX packets:114 errors:0 dropped:0 overruns:0 carrier:0
  collisions:0 txqueuelen:0
  RX bytes:60540 (59.1 KiB)  TX bytes:60540 (59.1 KiB)

venet0  Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
  inet6 addr: fe80::1/128 Scope:Link
  UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1
  RX packets:0 errors:0 dropped:0 overruns:0 frame:0
  TX packets:0 errors:0 dropped:3 overruns:0 carrier:0
  collisions:0 txqueuelen:0
  RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

root@server:~#

I'm trying to create 3 KVMs:
KVM1 using xxx.xxx.139.247 as public IP
KVM2 using xxx.xxx.137.129 as public IP
KVM3 using xxx.xxx.142.40 as public IP

The question is how to setup interfaces file on host and vm?
 
Last edited:
Ok, finally got it working:

Host:
Code:
auto eth0
iface eth0 inet static
  address xxx.xxx.131.201
  netmask 255.255.248.0
  gateway xxx.xxx.128.1

auto vmbr0
iface vmbr0 inet static
  address xxx.xxx.131.201
  netmask 255.255.248.0
  bridge_ports none
  bridge_stp off
  bridge_fd 0
  bridge_maxwait 0

  up ip route add xxx.xxx.139.247/32 dev vmbr0

VM:
Code:
auto eth0
iface eth0 inet static
  address xxx.xxx.139.247
  netmask 255.255.255.255
  pointopoint xxx.xxx.131.201
  gateway xxx.xxx.131.201
  dns-nameservers 8.8.8.8 8.8.4.4
 
Unless Proxmox is working as a firewall (but I'd seriously consider setting up a Proper firewall VM for this) then I would NOT give Proxmox a Public IP address!

Bridge the internet physical interface to your vmbr0 and attach the VMs to that. Or what I would do is setup a Firewall VM and setup one IP as the interface IP and the other 2 as one to one NAT to your VMs inside a 'DMZ' which actually have Private IPs
 
Unless Proxmox is working as a firewall (but I'd seriously consider setting up a Proper firewall VM for this) then I would NOT give Proxmox a Public IP address!

Bridge the internet physical interface to your vmbr0 and attach the VMs to that. Or what I would do is setup a Firewall VM and setup one IP as the interface IP and the other 2 as one to one NAT to your VMs inside a 'DMZ' which actually have Private IPs


According to my knowledge this is the best practice, but I have no much knowledge how to setup step by step and low level architecture wise.

Could you please share a good resource (Tutorial) may be a video or a web ?
 
  • Like
Reactions: mucua

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!