OpenVZ Forum


Home » General » Support » One NIC, Multiple Gateways
One NIC, Multiple Gateways [message #1475] Thu, 09 February 2006 08:16 Go to next message
blyoung is currently offline  blyoung
Messages: 6
Registered: February 2006
Junior Member
I have two gateways and one NIC. I want to be able to send some of the VPS to one gateway and some to another. I have been trying to accomplish this by altering the routing within the a particular VPS without success. The venet0 structure is different from what I am used to and I can't seem to find a way around or through the 191.255.255.1 interface.

Further illustration:
Host: 192.168.0.130, default route: 192.168.0.1
VPS101: 192.168.0.131
VPS102: 192.168.0.132
I want to make VPS102 route through 192.168.0.254 instead of 192.168.0.1 (the default configuration).

Am I going about this the wrong way? Is it even doable?

Thanks,
blyoung
Re: One NIC, Multiple Gateways [message #1631 is a reply to message #1475] Thu, 16 February 2006 12:34 Go to previous messageGo to next message
dev is currently offline  dev
Messages: 1693
Registered: September 2005
Location: Moscow
Senior Member

sure it is doable! but it has nothing to do with openvz actually.
You just need to setup src-based routing rules in host system. e.g.

# /sbin/ip rule add from $IP table $TBL
# /sbin/ip route add default dev eth0 via $GW table $TBL

where $IP is ip address which should use non-default GW.
$GW is gateway for this IP addr
$TBL - any free table number, I use numbers from 6 to ...
every next non-std GW will require another table number

read `man ip` for routing rules details.


http://static.openvz.org/userbars/openvz-developer.png
Re: One NIC, Multiple Gateways [message #1634 is a reply to message #1631] Thu, 16 February 2006 16:08 Go to previous messageGo to next message
blyoung is currently offline  blyoung
Messages: 6
Registered: February 2006
Junior Member
Thanks,

The documentation leads you to believe you can do it inside the VPS itself. With the virtual interface, I simply didn't think it was possible.

-Bryan
Re: One NIC, Multiple Gateways [message #4655 is a reply to message #1634] Thu, 20 July 2006 17:43 Go to previous messageGo to next message
kir is currently offline  kir
Messages: 1645
Registered: August 2005
Location: Moscow, Russia
Senior Member

This thread is summarised on wiki:Source based routing.

Kir Kolyshkin
http://static.openvz.org/userbars/openvz-developer.png
Re: One NIC, Multiple Gateways [message #29783 is a reply to message #1475] Thu, 24 April 2008 13:29 Go to previous message
mangust is currently offline  mangust
Messages: 39
Registered: April 2008
Location: USA
Member
i have problem going the way in Wiki.
I don't want to assign any IP address on external interface. I want to use all public addresses for VEs. And manage HN from private. I have:
[root@trinity ~]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:1E:4F:2D:F1:63  
          inet addr:192.168.1.52  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::21e:4fff:fe2d:f163/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:289 errors:0 dropped:0 overruns:0 frame:0
          TX packets:178 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:254155 (248.1 KiB)  TX bytes:33567 (32.7 KiB)
          Interrupt:169 Memory:f8000000-f8012100 

eth1      Link encap:Ethernet  HWaddr 00:1E:4F:2D:F1:65  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
          Interrupt:169 Memory:f4000000-f4012100 

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:3 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:299 (299.0 b)  TX bytes:299 (299.0 b)

sit0      Link encap:IPv6-in-IPv4  
          NOARP  MTU:1480  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

venet0    Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1
          RX packets:347 errors:0 dropped:0 overruns:0 frame:0
          TX packets:202 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:46953 (45.8 KiB)  TX bytes:44352 (43.3 KiB)
[root@trinity ~]# /sbin/ip rule add from 62.15.232.176/29 table 115
[root@trinity ~]# /sbin/ip route add default dev eth1 via 62.15.232.182 table 115
RTNETLINK answers: Network is unreachable
[root@trinity ~]# /sbin/ip route add 62.15.232.176/29 dev eth1
RTNETLINK answers: No such device
[root@trinity ~]# ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 00:1E:4F:2D:F1:65  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
          Interrupt:169 Memory:f4000000-f4012100 

[root@trinity ~]# ifconfig eth1 up
[root@trinity ~]# /sbin/ip route add 62.15.232.176/29 dev eth1
RTNETLINK answers: No such device
[root@trinity ~]# ifconfig eth1 inet 1.2.3.4
[root@trinity ~]# /sbin/ip route add 62.15.232.176/29 dev eth1
[root@trinity ~]# /sbin/ip route add default dev eth1 via 62.15.232.182 table 115
[root@trinity ~]# vzlist -a
      CTID      NPROC STATUS    IP_ADDR         HOSTNAME                        
         1         86 running   192.168.193.12  ServiceCT                       
       115          5 running   62.15.232.178   178.232.15.62.static.jazztel.es 
[root@trinity ~]# ping 62.15.232.178
PING 62.15.232.178 (62.15.232.178) 56(84) bytes of data.
64 bytes from 62.15.232.178: icmp_seq=1 ttl=64 time=0.041 ms



but still can't ping from outside Sad
i did something wrong? and why ip tell me story about "No such device"? i don't want to assign any address.

thanks
Previous Topic: mem leak
Next Topic: unfs3 in a ve and syslog errors
Goto Forum:
  


Current Time: Wed Apr 24 08:50:24 GMT 2024

Total time taken to generate the page: 0.01360 seconds