Linux multiple IP's on virtual interfaces

Discussion in 'Installation/Configuration' started by blocker, Dec 2, 2011.

  1. blocker

    blocker Member

    Hello,

    here is the scenario: I have a box with 3 IP adresses, configured as virtual interfaces

    192.168.0.1 eth0
    192.168.1.2 eth0:0
    192.168.0.3 eth0:1

    i have also apache with ip based vhosts:

    this one is bound to the IP which is configured on eth0:0
    <VirtualHost 192.168.1.2:80>
    ....................................
    </VirtualHost>

    the problem is that when a connection FROM the vhost 192.168.1.2:80 is made to external host, the connection goes trough 192.168.0.1 eth0 and not trough 192.168.1.2 eth0:0, as i wish to...

    whit SNAT i achieved to rewrite the default outgoing IP of the server but that is still not enough, since also in this case i have only one default outgoing IP

    iptables -t nat -A POSTROUTING -o eth0 -s 192.168.0.1 -j SNAT --to 192.168.0.2

    this way all the traffic goes trough 192.168.0.2 eth0:0, and the server remains reachable on all 3 IP's

    what i want to achieve is, every apache IP based vhost to go out trough its specific IP


    any thoughts and help are much appreciated!
     

Share This Page