Binding 2 NICs (MAC addresses) to 2 IP Addresses in same Subnet RedHat EL4.0
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Binding 2 NICs (MAC addresses) to 2 IP Addresses in same Subnet RedHat EL4.0
Hi,
I want to use simple configuration.
I want to bind IP1 with eth0 (MAC1) and IP2 with eth1 (MAC2),
I am RH Linux 4.0, with kernal 2.6
The issue in such a configuration is that, only one interface remains active at a time. AS Linux is assigning same MAC address to both IP addresses, i have verified it using arping.
Here eth0 and eth1 are connecting to different switches, IP1 and IP2 are in the same subnet.
I want ping results in such a way
using eth0 interface
ping IP1 should work
ping IP2 should not work
using eth1 interface
ping IP1 should not work
ping IP2 should work
Just a note: you musta specify "RHEL" as "RH Linux" is different and you don't want to have loads of people telling you to upgrade.
Quote:
The issue in such a configuration is that, only one interface remains active at a time.
I'm sorry, you want only one interface active at a time, OR you don't want this, but that's what you get? Which is it?
How are you configuring the interfaces?
What does ifconfig say?
Technically, if you have two nics on one machine, and one is set to static IP1 and the other to static IP2, then you can ping them both. If you want one to be unpingable, either take the interface down, or block ping requests.
> I'm sorry, you want only one interface active at a time, OR you don't want this, but that's what you get? Which is it?
This is what I get, I want both interfaces to be ACTIVE
I am configuring static entries in /etc/sysconfig/network-scripts/ifcfg files
> Technically, if you have two nics on one machine, and one is set to static IP1 and the other to static IP2, then you can ping them both. If you want one to be unpingable, either take the interface down, or block ping requests.
I agree both should be pingable, but through their own interface, and same MAC address should not be assigned to both IPs, as both have different NIC
I want ping results in such a way, when both interfaces are active
using eth0 interface
ping IP1 should work
ping IP2 should not work
using eth1 interface
ping IP1 should not work
ping IP2 should work
they NICs should already have different MAC addresses..
you can verify with the command ifconfig -a the hardware mac address for each interface will be listed.
ifconfig shows the correct mapping of the NICs to MAC addresses
It is about the MAC address assignment to IP Address, I have already explained that when I arping from remote side to IP1 and IP2, then I get response for both of IP addresses with same MAC address.
Why don't we start again, by having you provide some more info... ifconfig -a
route -n
arp -n
Might help us get a clearer picture of what it is exactly that you are doing.
I'm unclear on whether these two NICs are on the same network, on different networks, etc.. I don't understand why you are using two NICs in the first place.. Are you routing, bridging, binding, other ? A clearer understanding of what you are trying to accomplish, why and how would help us help you..
Providing eth1 and eth0 connect to the same network (which I assume they do) you need to setup a routing table such as -
ip route add default via gateway.com src eth0.eth0.eth0.eth0 dev eth0 # replace with ip in octets
ip route add default via gateway.com src eth1.eth1.eth1.eth1 dev eth1 # replace with ip in octets
Its possible at the moment one of the routes that is selectable is to send the packet out via eth0 even if the device the IP is attached to is eth1 since the route is valid.
I assume at the moment its something like
ip route add default via eth0.eth0.eth0.eth0
You can mimic this behaviour by adding a GATEWAY= assignment to the ifcfgs script dont assign the gateway in /etc/sysconfig/network .
Linux does reply on ARP on all NIC by default, if you have two NIC on separate lan then you never see this and it doesn't change anything. An arp reply on WAN and LAN for a request on LAN doesn't do anything to WAN and there is a credible reason apparently but I forget however it is listed somewhere in the kernel documentation , I think in /usr/src/linux/Documentation/networking/ip-sysctl.txt. Also in that same document it mentions arp_filter which is used when you want to have two NIC on the same subnet, it says so right in the doc, arp_filter should be set to 1 but not for just one device but for all devices which is either /proc/sys/net/ipv4/conf/all/arp_filter or "sysctl -w net.ipv4.conf.all.arp_filter=1" sans the quotes or net.ipv4.conf.all.arp_filter=1" in /etc/sysctl.conf. Also another one too look at is arp_ignore which I would set to 1. 2 sounds good but tends to cause problems in most boxes with 2+ NIC on a subnet.
Also, just so we are all clear, having an arp reply with the wrong mac causes sheer hell because machines only focus on the first MAC they see and if you are sending data to the wrong MAC then you are sending data to the wrong IP address. Additionally, when I started seeing this problem I had groups of "gurus" on #iptables in freenode telling me the kernel does not do arp replies on all interfaces. Well it is documented in the text file I just listed and I think the reason why is also in there too so routing has nothing to do with it.
Now that I have my own arp worked out and hopefully that helps you as well, I need to figure out how to create a situation where a IP only replies off the NIC that is assigned that IP despite having two NIC with route to host.
I think delerluxs command may have just helped me with my second issue since it seems to specify the device that the IP has to leave from after what I just RTFM'd
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.