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 am trying to set up four IPs on two Ethernet ports. I figured I will assign one to each and then create aliases for the remaining two.

This is what I did with my limited networking knowledge:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        address 90.70.200.200
        netmask 255.255.255.192
#       network
#       broadcast
        gateway 90.70.200.254

auto eth0:0
iface eth0:0 inet static
        address 90.70.200.239
        netmask 255.255.255.192

auto eth1
iface eth1 inet static
        address 90.70.200.240
        netmask 255.255.255.192

auto eth1:0
iface eth1:0 inet static
        address 90.70.200.241
        netmask 255.255.255.192

The setup works only partially. I can ping all IPs from the outside but cannot reach the outside world through any but that of eth0. And I do want to be able to do that.

Two notes: I did not touch the original eth0 configuration, and the provisioning guys only provided me with the IPs and netmask, so I presumed I do not need to add anything else.

The use case: Cluster of workers hitting the Amazon Product Advertising API through multiple IPs.

What am I doing wrong?

share|improve this question
    
Everything works fine outbound if I simply alias eth0 for the additional three IPs. Makes me wonder what I'm missing in the above configuration. –  hakanensari Feb 8 '11 at 19:04
    
How are you testing this? What are you expecting? Some kind of automatic load balancing through both interfaces? Why 4 IPs? –  rems Feb 8 '11 at 19:56
    
I test using curl. I pass the the interface name using --interface and then hit back my own machine's web server and see the IP in its log. –  hakanensari Feb 8 '11 at 19:56
    
Added use case above. –  hakanensari Feb 8 '11 at 19:56
    
You need some kind of source based routing setup to make this work. Simply adding IP addresses to network interfaces is not enough since it will only enable the server to accessed by more than one address. See the answer by Craig Sadler on how to do this correctly. However I am not really sure what you expect to accomplish exactly. You might want to read up on source based routing (and IP routing in general), for example: wlug.org.nz/SourceBasedRouting or linux-ip.net/html/adv-multi-internet.html or blog.gauner.org/blog/2011/01/24/… –  daff Feb 8 '11 at 20:33

1 Answer 1

I had the same issue and I found this from a debian posting. It has worked well for me.

auto eth0 
iface eth0 inet static
    address 90.70.200.200
    netmask 255.255.255.192
    broadcast 90.70.200.255
    gateway 90.70.200.254
         # the "up" lines are executed verbatim when the interface is brought up
    up ip addr add 90.70.200.239 brd 90.70.200.255 dev eth0 label eth0:0
    up ip addr add 90.70.200.240 brd 90.70.200.255 dev eth0 label eth0:1
share|improve this answer
    
This is the correct way nowadays to set multiple IP addresses on one network interface card. However it seems OP needs a more complicated routing setup because he wants to access the outside world from all IP addresses, not just the "main" address which has the gateway defined. In your case "ip route" would show an entry for the default gateway and a corresponding entry for the 90.70.200.192/26 network that has "src 90.70.200.200" set, meaning connections to the outside, via the default gateway, will appear to be, and are indeed, coming from the main address 90.70.200.200. –  daff Feb 8 '11 at 20:14

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.