Operating System - Linux
1821828 Members
3635 Online
109638 Solutions
New Discussion юеВ

need help on 2 ethernet card different IP on same subnet

 
SOLVED
Go to solution
remer
Advisor

need help on 2 ethernet card different IP on same subnet

Hi,

i would like to seek help regarding my linux server.

i have a linux server with to nic configured with different IP.
eth0 (10.130.16.21) and eth1 (10.130.16.22).

my first question is how can i setup the two nic as depended to each other?

every time i pull the physical cable on eth1 i can still access both IP, and with regards to the routing once i pulled the the physical cable on eth0 both IP are being unaccessible.

is there a problem with my routing table?

here's the routing table:
<>
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
10.130.16.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.130.16.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
0.0.0.0 10.130.16.1 0.0.0.0 UG 0 0 0 eth0

<>
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.130.16.0 * 255.255.255.0 U 0 0 0 eth0
10.130.16.0 * 255.255.255.0 U 0 0 0 eth1
169.254.0.0 * 255.255.0.0 U 0 0 0 eth1
default 10.130.16.1 0.0.0.0 UG 0 0 0 eth0

btw, here my server config and os config:
Server Model: HP ProLiant DL385 G2
Linux Version: Red Hat Enterprise Linux AS release 4 (Nahant Update 6)


thanks in advance.
5 REPLIES 5
Steven E. Protter
Exalted Contributor
Solution

Re: need help on 2 ethernet card different IP on same subnet

Shalom,

This is pretty simple.

in /etc/sysconfig/network-scripts

ifcfg-eth0
ifcfg-eth1

Configure them exactly the same except one is eth0 one is eth1 and assign the IP addresses as you wisn.

If this is not working its probably not the OS. A network router could make this difficult, or one of the IP addresses could already be in use elsewhere.

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
Matti_Kurkela
Honored Contributor

Re: need help on 2 ethernet card different IP on same subnet

I must ask: what is your goal?

If you feel you must have two NICs is fault-tolerance or extra bandwidth, you should learn about "bonding": two or more NICs can be bonded together to form a single "super-interface". In the simplest fault tolerance modes, all traffic will be automatically switched to the other NIC if the original NIC loses link or can no longer contact a specified MAC address. This is the active/passive, or "fail-over" mode.

For extra bandwidth, there is "active/active" mode, or link aggregation according to IEEE 802.3ad standard. Your network switch must support this and be configured to allow this to be used. There are other load balancing modes which won't necessarily require switch support, but may have other requirements or limitations.

The standard way to add multiple IP addresses in the same subnet for one host is using IP aliases: in some Unixes, that is the only way to do it.

Usually, unless the application specifically bind()s the outgoing socket to a particular source IP address, the system will choose the source address by finding the NIC that is "closest" to the destination according to the routing table. The standard routing table is pre-sorted, and the first matching entry is used. This happens at the IP level, so it has no concept of a "session": each packet is treated as an individual entity.

This is why your system seems to prefer eth0: note that eth0 is listed as the first network in the routing table, and the default gateway is listed only with eth0. In effect, anything going out to the 10.130.16.* segment goes out primarily through eth0, and anything going to other network segments through the gateway will be sent out from eth0 _only_.

Linux _can_ handle multiple NICs in the same subnet, but the required configuration is quite a bit more advanced than "normal".

First, you must set some sysctl settings to non-default values. These are located in /proc/sys/net/ipv4/conf/eth0 and /proc/sys/net/ipv4/conf/eth1, respectively for each NIC.

You must set arp_filter to 1: the default value is 0. You should also review the documentation of arp_announce and arp_ignore settings and set them according to your requirements.

These settings can be changed by commands like "echo 1 > arp_filter", but the changes made in this way are not persistent: when the system is rebooted, the changes are lost. You can use /etc/sysctl.conf file and the "sysctl" command to make the changes persistent across reboots.

The network sysctl settings are documented in Linux kernel documentation. This documentation is available in the kernel-doc package:
if you've registered the system to RedHat Network, execute "up2date --install kernel-doc" to install the documentation, then read "/usr/share/doc/kernel-doc-/Documentation/networking/ip-sysctl.txt"

The second step would be to implement advanced routing, or "policy routing".
You should read Linux Advanced Routing HOWTO:
http://lartc.org/howto/
(Note: a solid understanding of IP networking fundamentals is essential. Creating a routing policy and applying it requires some careful thinking.)

MK
MK
Patrick Terlisten
Honored Contributor

Re: need help on 2 ethernet card different IP on same subnet

Hello,

two physical NICs with ip-addresses in the same not won't work. If you need two addresses in the same subnet, use ip-aliases. If you need more bandwidth or redundandy, choose bonding. Take a look at the bonding howto:

http://www.cyberciti.biz/howto/question/static/linux-ethernet-bonding-driver-howto.php

Best regards,
Patrick
Best regards,
Patrick
Andrew Cowan
Honored Contributor

Re: need help on 2 ethernet card different IP on same subnet

Remer,

Another possible slant on this. If you needed to have to Ethernet cards in the same logical subnet, you can split it on your host. Eg.

Main subnet 192.168.1/24 Default gateway 192.168.1.1

Eth0: 192.168.1.63/25
Eth1: 192.168.1.64/25

Using this arrangement only Eth0 can see the default gateway, however you can set up static routes so that Eth1 can route through another host e.g. 192.168.1.65/24.

This is typically how clusters such as HACMP do IP Address Takeover or swapping.

Dennis Heidner
New Member

Re: need help on 2 ethernet card different IP on same subnet

If you are trying to do make the NIC's operate as one - i.e you are bonding them together, then the process is little different than just configuring the network cards. You need to have network bonding driver installed.

http://www.kernel.org/pub/linux/kernel/people/marcelo/linux-2.4/Documentation/networking/bonding.txt