Help me with adding static ip for vps

chrunchips123

New Member
Aug 15, 2019
4
0
1
25
I need to setup static IP for one of my vps. I have additional IP which is not in my dedicated server range. I have been searching internet for a while and I wasted few days for this. Still I didnt manage to make this to work. Can someone show me soem basic config for host and vm to do this? On my dedicated server I have config which look like this

12.23.34.45 - dedicated server ip
87.35.13.64 - new additional ip

Code:
auto lo
iface lo inet loopback

iface enp3s0 inet manual

auto vmbr0
iface vmbr0 inet static
        address  12.23.34.45/24
        gateway  12.23.34.254
        netmask 255.255.255.255
        bridge-ports enp3s0
        bridge-stp off
        bridge-fd 0

So if I am understanding this right I have to create new network bridge like this one:

Code:
auto vmbr1
iface vmbr1 inet static
        address  87.35.13.64
        gateway  12.23.34.254
        netmask 255.255.255.255

But do I need to create another network device like this one "enp3s0 " and connect vmbr1 to it? Or somehow connect it to vmbr0? Also I am not sure about gateway in vmbr1 is it right?

I know that for vps I just set static with vmbr1 settings but my main problem is with setting up host right.
Can someone help me with this? I don't really do networking stuff and I wasted so much time trying to make this to work.
 
The configs you posted look good so far. Have you tested them?

Two things I noticed:
  • You specify your netmask as /24 for vmbr0, which seems unlikely for a public static IP? You also override it further down with the "netmask" key...
  • If you want to create a bridge interface with an external IP, you have to specify a physical device (in your case enp3s0) as "bridge-ports" - this tells the system which physical interface packets will use to reach the gateway (or other devices in the same subnet, which falls flat in your /32 range).

Based on that, a full config with your example might look like this:

Code:
auto lo
iface lo inet loopback

iface enp3s0 inet manual

auto vmbr0
iface vmbr0 inet static
        address  12.23.34.45
        gateway  12.23.34.254
        netmask 255.255.255.255
        bridge-ports enp3s0
        bridge-stp off
        bridge-fd 0

auto vmbr1
iface vmbr1 inet static
        address  87.35.13.64
        gateway  12.23.34.254
        netmask 255.255.255.255
        bridge-ports enp3s0
        bridge-stp off
        bridge-fd 0

Let it be noted, that you can create new interfaces using the web GUI as well, which will take care of most of the above for you.


Edit: I forgot to mention about your gateway question: This should be a second IP that has been given to you by your provider, along with the IP itself. It seems unlikely that this would be the same for both public IPs, though not impossible.
 
The configs you posted look good so far. Have you tested them?

Two things I noticed:
  • You specify your netmask as /24 for vmbr0, which seems unlikely for a public static IP? You also override it further down with the "netmask" key...
  • If you want to create a bridge interface with an external IP, you have to specify a physical device (in your case enp3s0) as "bridge-ports" - this tells the system which physical interface packets will use to reach the gateway (or other devices in the same subnet, which falls flat in your /32 range).

Based on that, a full config with your example might look like this:

Code:
auto lo
iface lo inet loopback

iface enp3s0 inet manual

auto vmbr0
iface vmbr0 inet static
        address  12.23.34.45
        gateway  12.23.34.254
        netmask 255.255.255.255
        bridge-ports enp3s0
        bridge-stp off
        bridge-fd 0

auto vmbr1
iface vmbr1 inet static
        address  87.35.13.64
        gateway  12.23.34.254
        netmask 255.255.255.255
        bridge-ports enp3s0
        bridge-stp off
        bridge-fd 0

Let it be noted, that you can create new interfaces using the web GUI as well, which will take care of most of the above for you.


Edit: I forgot to mention about your gateway question: This should be a second IP that has been given to you by your provider, along with the IP itself. It seems unlikely that this would be the same for both public IPs, though not impossible.
Thank you for your reply. I managed to make this to work with default proxmox settings. I added only new Failover IP to host using "ip route add x.x.x.x dev vmbr0". Then in virutal machine i setup static with post-up/post-down. Unfortunately all the traffic now goes through main ip gateway. For some weird reasons my main ip end up with cloudflare ip block for specified website. Now if I add new IP it is insta blocked also. So I think its because of gateway. If I run some vpn its working fine. My provider told me that its not possible to hide my main ip gateway route so I end up with nothing.
 

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!