OpenVZ Forum


Home » Mailing lists » Users » Access to private and public IP in VPS
Access to private and public IP in VPS [message #23146] Tue, 13 November 2007 14:54 Go to next message
Frederik is currently offline  Frederik
Messages: 5
Registered: November 2007
Junior Member
I have a hardware node with two network interfaces, one with a public IP 
address, one with a private IP address. Now I would like a VPS to also 
have a public IP address and a private IP address so both networks can be 
accessed directly. How should this be configured? Is it possible without 
using veth interfaces?

-- 
Frederik
Re: Access to private and public IP in VPS [message #23164 is a reply to message #23146] Wed, 14 November 2007 01:00 Go to previous messageGo to next message
efball is currently offline  efball
Messages: 41
Registered: September 2006
Location: Santa Rosa, California
Member
On Tue, Nov 13, 2007 at 02:54:30PM +0000, Frederik wrote:
 > I have a hardware node with two network interfaces, one with a public IP 
 > address, one with a private IP address. Now I would like a VPS to also 
 > have a public IP address and a private IP address so both networks can be 
 > accessed directly. How should this be configured? Is it possible without 
 > using veth interfaces?


I have a hardware node with two network interfaces, one with a public IP
address, one with a private IP address.  My VEs just have a private IP
address.  The firewall on the hardware node can route things so that the
VE can access both networks.  I use shorewall to setup my firewall and
it's pretty easy.

-- 

   E Frank Ball                efball@efball.com
Re: Access to private and public IP in VPS [message #23176 is a reply to message #23164] Wed, 14 November 2007 08:18 Go to previous messageGo to next message
Frederik is currently offline  Frederik
Messages: 5
Registered: November 2007
Junior Member
On Tue, 13 Nov 2007 17:00:11 -0800, E Frank Ball III wrote:

> On Tue, Nov 13, 2007 at 02:54:30PM +0000, Frederik wrote:
>  > I have a hardware node with two network interfaces, one with a public
>  > IP address, one with a private IP address. Now I would like a VPS to
>  > also have a public IP address and a private IP address so both
>  > networks can be accessed directly. How should this be configured? Is
>  > it possible without using veth interfaces?
> 
> 
> I have a hardware node with two network interfaces, one with a public IP
> address, one with a private IP address.  My VEs just have a private IP
> address.  The firewall on the hardware node can route things so that the
> VE can access both networks.  I use shorewall to setup my firewall and
> it's pretty easy.

The problem when doing it like this, is that you probably have to do DNAT 
on your HN to access a VE from the outside, isn't it? That's something I 
want to avoid.

-- 
Frederik
Re: Access to private and public IP in VPS [message #23206 is a reply to message #23146] Wed, 14 November 2007 09:51 Go to previous messageGo to next message
Arjan Schrijver is currently offline  Arjan Schrijver
Messages: 6
Registered: November 2007
Junior Member
I actually did this a few days ago.
Just add both the public and the private IP address to the VE using
these commands (don't use veth interfaces):

HN# vzctl set 100 --ipadd [publicip] --save
HN# vzctl set 100 --ipadd [privateip] --save

In the VE you should now have two ethernet devices: venet0 and venet0:1
To make it actually work, you have to add routes inside the VE to the
network that isn't available using the default route:

VE# route add -net [privatenetwork] netmask 255.255.255.0 gw [privateip]

So to explain the above command, you add the route to [privatenetwork]
(i.e. 192.168.1.0) using its own IP address as the gateway. You can add
this route to one of the startup scripts of your VE, so it gets added
when the VE boots.

Remember, this only works when your Hardware Node knows both networks
(in its routing table).

Regards,
Arjan


Frederik wrote:
> I have a hardware node with two network interfaces, one with a public IP 
> address, one with a private IP address. Now I would like a VPS to also 
> have a public IP address and a private IP address so both networks can be 
> accessed directly. How should this be configured? Is it possible without 
> using veth interfaces?
>
>
Re: Access to private and public IP in VPS [message #23226 is a reply to message #23206] Wed, 14 November 2007 14:01 Go to previous message
Frederik is currently offline  Frederik
Messages: 5
Registered: November 2007
Junior Member
On Wed, 14 Nov 2007 10:51:48 +0100, Arjan Schrijver wrote:

> I actually did this a few days ago.
> Just add both the public and the private IP address to the VE using
> these commands (don't use veth interfaces):
> 
> HN# vzctl set 100 --ipadd [publicip] --save HN# vzctl set 100 --ipadd
> [privateip] --save
> 
> In the VE you should now have two ethernet devices: venet0 and venet0:1
> To make it actually work, you have to add routes inside the VE to the
> network that isn't available using the default route:
> 
> VE# route add -net [privatenetwork] netmask 255.255.255.0 gw [privateip]

Thank you. The above route command was the missing link in my setup. I 
already tried using the private IP of the HN as the gw for that network, 
but that did not work. Using the VEs own private IP as the gw did indeed 
the trick.

-- 
Frederik
Previous Topic: How do I mount /tmp on VEs with noexec,nosuid options?
Next Topic: Problems with plesk + openvz
Goto Forum:
  


Current Time: Thu Jun 19 09:06:32 GMT 2025

Total time taken to generate the page: 0.04005 seconds