Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to make sure my clients outgoing ip address uses the dedicated ip they are assigned.

For example,

site123.com has an ip of 123.123.123.2(eth0:1) (resolves fine when incoming)

but it is using my main server ip 123.123.123.1 (eth0) when it makes outgoing requests

How can I go about changing this?

I am using centOS on the dedicated server.

share|improve this question

3 Answers 3

By default, everything will go out the default route, which is associated with the default eth0 ip. You can change the eth0 and eth0:0 ips and then change the default route....

If you only want it for some things, then you need to use the iproute2 package and use ip route command to specify certain routing rules. http://linux-ip.net/html/tools-ip-route.html is a good place to see the nitty gritty.

This is also called "source based routing". This used with "tc" command (traffic shaping) will accomplish what you want...It can be done, but it's very difficult for the novice administrator on a linux server with hundreds of ips.

However, some programs like wget etc, will allow you to specify the network interface to use, so you can specify -i eth0:0 for instance.

Good luck!

share|improve this answer
cd /etc/sysconfig/network-scripts/

Your interface config scripts will be named "ifcfg-eth0", "ifcfg-eth1", etc. Edit the one for the appropriate interface, changing the "GATEWAY" setting. For example, on my box "ifcfg-eth0" looks like this:

DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
IPADDR=74.201.152.166
NETMASK=255.255.255.255
GATEWAY=10.255.255.1

In your case, remove the "GATEWAY" line from your "ifcfg-eth0" file and move it to "ifcfg-eth0:1" (changing the gateway address to whatever is correct for that NIC). Then restart your networking:

/etc/init.d/network restart
share|improve this answer
    
there are no files for ifcfg-eth0:1, only ifcfg-eth0 should i create this file? –  james Feb 16 '10 at 18:27

I would expect changing the default route on your CentOS to the aliased interface 'eth0:1' should make it work as you want.

The reason for correct incoming resolution has nothing to do with your CentOS configuration;
it is controlled by the external name lookup resolution for your 'site123.com' domain name.
It resolves to '123.123.123.2' so you get incoming connections there.


Update: Section 13.2.4: Alias and Clone Files, in Interface Configuration Files page of CentOS deployment guide refers this Network Configuration page for Device Aliases.

share|improve this answer
    
thanks, any idea where i would make this change? –  james Feb 16 '10 at 0:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.