We are in the process of migrating this forum. A new space will be available soon. We are sorry for the inconvenience.

Possible to add extra IP in ProxMox KVM VPS


WebHostingNeeds
2015-12-11, 03:35 AM
Thanks HTMLtag. That was the problem, got it working now.

HTMLtag
2015-12-11, 02:53 AM
In the OVH control panel, you need the MAC address to be the same for both IPs to use aliasing.
There is an option for "use existing mac".

The way you're doing it, you can't do IP aliasing. Since you have 2 different MAC addresses, you can add 2 virtual adapters on the same bridge and network that way. It would be eth0 and eth1 instead of eth0 and eth0:x. For each adapter, set the unique MAC address. When defining the 2 networks, make sure eth0 is for the right IP.

It's probably easier to just remove one Virtual Mac and do aliasing with 2 ips sharing the same mac in OVH CP.

Btw, if using Ubuntu, I'd recommend using VirtIO on your network adapter config, if you're not.

WebHostingNeeds
2015-12-10, 11:36 PM
Thanks HTMLtag, i switched IP in /etc/network/interfaces. Rebooted. I did not change Virtual-Mac.

After reboot, still i am able to ping to IP 167.114.176.3 (VM is configured with this IPs vMAC). This IP is now on eth0:1

But can't ping to IP binded to eth0.

Now i shutdown VPS, changed vMAC for network interface to that of IP 167.114.176.0, rebooted VPS, now i can ping to IP ending with 0, not the one ending with 3.

It may be some routing issue, i will read your post few times so i can understand everything properly, it will take me some time to digest

HTMLtag
2015-12-10, 04:01 PM
I just did my Debian 8 test.
It worked fine, I didn't need a 2nd route cmd.

I defined a netmask and broadcast in my eth0:1 config.
I tried it without and everything worked fine also.

I decided to use a failover ip from 2 different geolocations, US and Canada.
No problem.

/etc/network/interfaces:
Code:
source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#allow-hotplug eth0
#iface eth0 inet dhcp


auto eth0
iface eth0 inet static
        address IP1
        netmask 255.255.255.255
        broadcast IP1
        dns-nameservers 8.8.8.8 8.8.4.4

        post-up route add HOST.254 dev eth0
        post-up route add default gw HOST.254
        post-down route del HOST.254 dev eth0
        post-down route del default gw HOST.254

auto eth0:1
iface eth0:1 inet static
        address IP2
        netmask 255.255.255.255
        broadcast IP2
There is nothing in /etc/network/interfaces.d/

ip addr:
Code:
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether MACADDR brd ff:ff:ff:ff:ff:ff
    inet IP1/32 brd IP1 scope global eth0
       valid_lft forever preferred_lft forever
    inet IP2/32 brd IP2 scope global eth0:1
       valid_lft forever preferred_lft forever
    inet6 IPV6/64 scope link
       valid_lft forever preferred_lft forever
ifconfig:
Code:
ifconfig
eth0      Link encap:Ethernet  HWaddr MACADDR
          inet addr:IP1  Bcast:IP1  Mask:255.255.255.255
          inet6 addr: fe80::ff:fe0a:6de6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:44691 errors:0 dropped:0 overruns:0 frame:0
          TX packets:954 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2780763 (2.6 MiB)  TX bytes:88699 (86.6 KiB)

eth0:1    Link encap:Ethernet  HWaddr MACADDR
          inet addr:IP2  Bcast:IP2  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:65536  Metric:1
          RX packets:11 errors:0 dropped:0 overruns:0 frame:0
          TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:880 (880.0 B)  TX bytes:880 (880.0 B)
route -n:
Code:
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         HOST.254   0.0.0.0         UG    0      0        0 eth0
HOST.254   0.0.0.0         255.255.255.255 UH    0      0        0 eth0

HTMLtag
2015-12-10, 02:42 PM
Running the route command should be sufficient.
Just to verify, you do have them assigned to the same virtual mac in OVH.

When I have a break from work today, I'll deploy a Debian VM in my environment and test.
It should be similar enough to Ubuntu.

If you swap the IP's, does the IP work?
I just want to make sure it's not blackholed or anything.

WebHostingNeeds
2015-12-10, 02:11 PM
Thanks HTMLtag for the reply. I run

Code:
route add 158.69.118.254 dev eth0:1
That added a new entry in routes table

Code:
root@maps:~# route add 158.69.118.254 dev eth0:1
root@maps:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         158.69.118.254  0.0.0.0         UG    0      0        0 eth0
158.69.118.254  0.0.0.0         255.255.255.255 UH    0      0        0 eth0
158.69.118.254  0.0.0.0         255.255.255.255 UH    0      0        0 eth0
root@maps:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 02:00:00:ea:50:11  
          inet addr:167.114.176.3  Bcast:167.114.176.3  Mask:255.255.255.255
          inet6 addr: fe80::ff:feea:5011/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:947987 errors:0 dropped:1730 overruns:0 frame:0
          TX packets:229523 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:436629283 (436.6 MB)  TX bytes:44251509 (44.2 MB)

eth0:1    Link encap:Ethernet  HWaddr 02:00:00:ea:50:11  
          inet addr:167.114.176.0  Bcast:167.114.176.0  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:65536  Metric:1
          RX packets:9308 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9308 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:3135729 (3.1 MB)  TX bytes:3135729 (3.1 MB)

root@maps:~# route add 158.69.118.254 dev eth0:1
SIOCADDRT: File exists
root@maps:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         158.69.118.254  0.0.0.0         UG    0      0        0 eth0
158.69.118.254  0.0.0.0         255.255.255.255 UH    0      0        0 eth0
158.69.118.254  0.0.0.0         255.255.255.255 UH    0      0        0 eth0
root@maps:~#
Still ping is not working.

Should i add it to /etc/network/interface ? If so, where i add ?

Current content of the file is

Code:
root@maps:~# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
	address 167.114.176.3
	netmask 255.255.255.255
	broadcast 167.114.176.3
	post-up route add 158.69.118.254 dev eth0
	post-up route add default gw 158.69.118.254
	pre-down route del 158.69.118.254 dev eth0
	pre-down route del default gw 158.69.118.254
auto eth0:1
    iface eth0:1 inet static
    address 167.114.176.0
	netmask 255.255.255.255
	broadcast 167.114.176.0
root@maps:~#

HTMLtag
2015-12-09, 03:55 PM
Maybe you should try adding routes for eth0:1 also.
You don't need to double up the default gateways, only the eth0:1 routes.
Code:
post-up route add 158.69.118.254 dev eth0:1
pre-down route del 158.69.118.254 dev eth0:1

WebHostingNeeds
2015-12-07, 04:30 PM
I need to add 2 IP in Proxmox KVM VPS running ubuntu.

I setup virtal mac for 2 IP address. I can only ping to main IP of the server.

Here is my config

Code:
root@maps:~# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
	address 167.114.176.3
	netmask 255.255.255.255
	broadcast 167.114.176.3
	post-up route add 158.69.118.254 dev eth0
	post-up route add default gw 158.69.118.254
	pre-down route del 158.69.118.254 dev eth0
	pre-down route del default gw 158.69.118.254
auto eth0:1
    iface eth0:1 inet static
    address 167.114.176.0

root@maps:~#
Ping only works on eth0 IP,

Code:
root@maps:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 02:00:00:ea:50:11  
          inet addr:167.114.176.3  Bcast:167.114.176.3  Mask:255.255.255.255
          inet6 addr: fe80::ff:feea:5011/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1427 errors:0 dropped:0 overruns:0 frame:0
          TX packets:186 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:76402 (76.4 KB)  TX bytes:20886 (20.8 KB)

eth0:1    Link encap:Ethernet  HWaddr 02:00:00:ea:50:11  
          inet addr:167.114.176.0  Bcast:167.114.255.255  Mask:255.255.0.0
          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:65536  Metric:1
          RX packets:73 errors:0 dropped:0 overruns:0 frame:0
          TX packets:73 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:5260 (5.2 KB)  TX bytes:5260 (5.2 KB)

root@maps:~#
Why secondary IP is not working ?