OpenVZ Forum


Home » General » Support » Routing in VPS?
Routing in VPS? [message #922] Wed, 18 January 2006 18:13 Go to next message
illc0mm is currently offline  illc0mm
Messages: 8
Registered: January 2006
Junior Member
Here's my scenario I have a OpenVZ box with two interfaces:

eth0: public internet 1.1.1.1
eth1: private intranet 10.1.1.1

I want to assign two IPs on my VPS like:

vps101: 1.1.1.2 (public) 10.1.1.2 (private)

However, when I try to connect to another server on the private network (10.1.1.3 for instance) it appears as though the connection is coming from 1.1.1.2 instead of the private address. Is there something I can do so that this is routed as the 10.1.1.2 IP instead of the 1.1.1.2 IP?

I know that 1.1.1.2 is the first assigned IP, however these need to appear properly when routed. HELP!

-illc0mm
Re: Routing in VPS? [message #935 is a reply to message #922] Thu, 19 January 2006 11:02 Go to previous messageGo to next message
vaverin is currently offline  vaverin
Messages: 708
Registered: September 2005
Senior Member
Do you want to change source IP if the destination address is in your private subnetwork? you should tune source NAT inside your VPS:

iptables -t nat -A POSTROUTING -d 10.1.1.0/24 -j SNAT --to-source 10.1.1.2

where
10.1.1.0/24 -- your private subnetwork
10.1.1.2 -- VPS private address
Re: Routing in VPS? [message #936 is a reply to message #922] Thu, 19 January 2006 12:45 Go to previous messageGo to next message
illc0mm is currently offline  illc0mm
Messages: 8
Registered: January 2006
Junior Member
Ah, so that's the best way? I just wanted to make sure I wasn't doing something wrong. I was using Xen before and with that you would create another virtual interface, just wanted to make sure I wasn't missing something.

Thanks!

-illc0mm
Re: Routing in VPS? [message #940 is a reply to message #936] Thu, 19 January 2006 19:57 Go to previous message
dev is currently offline  dev
Messages: 1693
Registered: September 2005
Location: Moscow
Senior Member

To tell the truth, I personally would recommend to use IP rules.
It is much better/faster/easier than using NAT.

I personally do the following for adding second IP address on my host.

#!/bin/bash

IP=217.67.117.132
GW=217.67.117.129
MASK=27

ip addr add $IP/$MASK dev eth0
ip rule add from $IP table 6
ip route add default dev eth0 via $GW table 6


Hope, it works for you


http://static.openvz.org/userbars/openvz-developer.png
Previous Topic: sharing file between ve's - openvz versus virtuozzo
Next Topic: Bug in vzsplit ?
Goto Forum:
  


Current Time: Sat Jul 13 19:22:10 GMT 2024

Total time taken to generate the page: 0.02270 seconds