Operating System - HP-UX
1832004 Members
3534 Online
110034 Solutions
New Discussion

how to force the use of an IP address on a network with virtual IP

 
benoit Bruckert
Honored Contributor

how to force the use of an IP address on a network with virtual IP

Hi,
Here's my conf :
lan0 : IP 192.X.X.10
lan0:1 : IP 192.X.X.100
lan0:2 : IP 192.X.X.101
lan0:3 : IP 192.X.X.102

lan0:1, lan0:2 lan0:3 are used for virtual webserver hosting ! which mean that the firewall is NATing 100, 101 and 102.
This config is good for replying on some http requests.
But my trouble is :
If i open a connection to internet (outgoing) with this server, the source address used is 10, which is not NATed (nor allowed) ! Then no answer of course. What I want is forcing the use of lan0:1 for outgoing traffic (But I want to keep Lan0 with this IP to facilitate recovery with another server), by default lan0 is used !
I tried static routes to local host . IE :
route add 192.X.X.100 0
which is working for contacting the gateway directly ? but for default ?
And
route add net 192.X.X.0 netmask 255.255.255.0 192.X.X.100 0
But it doesn't work !
What can I do to force the use of lan0:1 instead of lan0 for outgoing traffic to the default route ?
Une application mal pansée aboutit à une usine à gaze (GHG)
7 REPLIES 7
Slawomir Gora
Honored Contributor

Re: how to force the use of an IP address on a network with virtual IP

Hi,

you have to set 192.X.X.100 to lan0 insted of lan0:1.

For outgoing packet kernel always gets first lan.
benoit Bruckert
Honored Contributor

Re: how to force the use of an IP address on a network with virtual IP

This is what I did for the moment, but I would prefer using lan0:1. Because I would like to build a kind of "home made" cluster, and using a virtual IP as main source address would help me a lot because I can ever communicate to each node with it's real address !
Une application mal pansée aboutit à une usine à gaze (GHG)
Tomek Gryszkiewicz
Trusted Contributor

Re: how to force the use of an IP address on a network with virtual IP

You can have only one gateway to the subnet - so the only way is to create one subnet for one virtual ip.

-Tomek
Sanjay_6
Honored Contributor

Re: how to force the use of an IP address on a network with virtual IP

rick jones
Honored Contributor

Re: how to force the use of an IP address on a network with virtual IP

If you want to force traffic to be sent with a given source IP address, your application must make a call to bind() to bind to that IP address.

There _may_ be some ways to setup routes that if you also set ip_strong_es_model you will get the source IP you want, but that is more of a sure thing when the remote contacts you (your system) rather than when you contact the remote.

The sure way when you contact the remote is to have the application call bind().

there is no rest for the wicked yet the virtuous have no pillows
Steven E. Protter
Exalted Contributor

Re: how to force the use of an IP address on a network with virtual IP

Virtual addressing lets you obtain more ip addresses, but the traffic really comes and goes from the main lan0.

Its still useful because it lets you set up lots of web servers with their own ip addresses for example.

I'd the lan0 addy if that does not disrupt other network traffic.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
benoit Bruckert
Honored Contributor

Re: how to force the use of an IP address on a network with virtual IP

Thanks for all the replies,
From what I can read the answer is not simple !
A simple route add doesn't work.
I don't manage all the software which may generate outbound traffic (like Bind, Squid, cvs, messaging), then using the bind() isn't allways possible !
I think I will then change my recovery script to change properly the lan0 config on each side which is more complicated but should work.
thank all !
Une application mal pansée aboutit à une usine à gaze (GHG)