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 have a server that I needs to change its IP address. For DNS propagation I need to have both new and old IP addresses on the server for a little while (72 hours). But when ever I ifup eth1 (NIC with new IP) the old IP will lose connection to the world (I cannot even ping it). Both IPs have their own Gateway. I just did it on windows 2008 without any problem and both IPs work, but on my Linux server I failed because of my lake of knowledge.

The Server has CentOS 6.2

share|improve this question
    
Why do both IPs have their own gateway? There should be some router that has the machine's connection to the Internet, right? If these two IPs are from two different providers, then you need source-based routing will have to configure it. –  David Schwartz Dec 24 '12 at 12:05
1  
@DavidSchwartz Read it - he is supposedly switching providers and want all requests to the old IP to go back to the old provider, while all requests to the new IP should have the packets returning to the new provider. –  TomTom Dec 24 '12 at 12:21
    
@TomTom: I don't see any mention of switching providers or multiple providers. Where are you getting that from? If he is, then he needs source-based routing (policy routing). Otherwise, his provider will drop his packets based on their source. –  David Schwartz Dec 24 '12 at 12:22
    
I'm changing the transmission provider and I have two fiber one for each subnet and I don't have any router. –  ImanGh Dec 24 '12 at 12:30
    
@TomTom is completely right. –  ImanGh Dec 24 '12 at 12:32

1 Answer 1

up vote 4 down vote accepted

You need to set up source base routing.

If your 2 IPs are ip0 and ip1 with routes gw0 and gw1: when a connection is made to ip0, you want to route it via gw0; and when it is made on ip1, via gw0. Your default route will be either via gw0 and gw1, depending on which gateway you want your traffic to go for connection initiated by your server.

I cannot test it, but from this blog post, it seams that you need to:

  • Create 2 new routing tables:

Use those 2 commands:

echo -e "100\tOld_IPS" >> /etc/iproute2/rt_tables
echo -e "200\tNew_IPS" >> /etc/iproute2/rt_tables
  • Add routing rules to those tables:

Use those 2 commands, changing your IPs:

echo "default table Old_IPS via $gw0" >> /etc/sysconfig/network-scripts/route-eth0
echo "default table New_IPS via $gw1" >> /etc/sysconfig/network-scripts/route-eth1
  • Add the source routing for each table:

Use those 2 commands, changing your IPs:

echo "from $ip0 table Old_IPS" >> /etc/sysconfig/network-scripts/rule-eth0
echo "from $ip1 table New_IPS" >> /etc/sysconfig/network-scripts/rule-eth1

Then restart your network using /etc/init.d/network restart (be careful not to cut yourself access to your server).

Once you are happy with the setting, you can change your default gateway from gw0 to gw1.

share|improve this answer
    
It works, Thank you @jfgagne –  ImanGh Dec 24 '12 at 15:47

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.