LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   two NICs on same subnet and ssh independently (https://www.linuxquestions.org/questions/linux-networking-3/two-nics-on-same-subnet-and-ssh-independently-543633/)

powah 04-05-2007 03:04 PM

two NICs on same subnet and ssh independently
 
I want to set my computer which has two NICs on the same subnet (for some reason).
I want to ssh eth0 and eth1 independently (if eth0 cable is unplugged, ssh to eth0 fail; if eth1 cable is unplugged, ssh to eth1 fail), so I use iproute2 to configure it.

# ip route add default via 172.20.11.10 dev eth0 tab 1
RTNETLINK answers: Network is unreachable
# ip route add default via 172.20.11.10 dev eth1 tab 2
RTNETLINK answers: File exists

Please help to fix this problem.

The setup are:
# ifconfig
eth0 Link encap:Ethernet HWaddr 00:00:50:98:38:AE
inet addr:172.20.11.242 Bcast:172.20.255.255 Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:171 errors:0 dropped:0 overruns:0 frame:0
TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:24983 (24.3 Kb) TX bytes:458 (458.0 b)
Interrupt:11 Base address:0x7000

eth1 Link encap:Ethernet HWaddr 00:00:50:98:38:AF
inet addr:172.20.11.199 Bcast:172.20.255.255 Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:229 errors:0 dropped:0 overruns:0 frame:0
TX packets:62 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:31971 (31.2 Kb) TX bytes:8351 (8.1 Kb)
Interrupt:9 Base address:0x9000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:560 (560.0 b) TX bytes:560 (560.0 b)

# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
172.20.0.0 * 255.255.0.0 U 0 0 0 eth1
172.20.0.0 * 255.255.0.0 U 0 0 0 eth1
127.0.0.0 * 255.0.0.0 U 0 0 0 lo
default 172.20.11.10 0.0.0.0 UG 0 0 0 eth0

# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME="rose"
GATEWAY=172.20.11.10

# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
GATEWAY=172.20.11.10
IPADDR=172.20.11.242
NETMASK=255.255.255.0

# cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=static
GATEWAY=172.20.11.10
IPADDR=172.20.11.199
NETMASK=255.255.255.0
DEFAULT=no

macemoneta 04-05-2007 04:02 PM

You are trying to statically assign the same IP address to multiple active Ethernet interfaces at the same time. This won't work - you will generate an ARP storm (each interface claiming to associate its MAC with the IP).

"(for some reason)" - If you tell us what you are trying to accomplish, we may be able to help you.

kcorupe 04-05-2007 04:23 PM

I'm assuming your trying to create some kind of fault tolerance. which would not make sense on the same machine, you would want to revert to another machine.

what macemoneta said is correct, you can't have two nics sharing one ip.

macemoneta 04-05-2007 04:32 PM

If the purpose is for fault tolerance (in this case, just a NIC or cable failure), you can use NIC bonding.

lazlow 04-05-2007 04:34 PM

You can bond the two nics together. I cannot remember which mode. There is a fault mode, round robin (takes turns), aggregate (both act as one but requires special router/switch features) and three other modes I cannot remember.

powah 04-09-2007 12:56 PM

Quote:

Originally Posted by macemoneta
You are trying to statically assign the same IP address to multiple active Ethernet interfaces at the same time. This won't work - you will generate an ARP storm (each interface claiming to associate its MAC with the IP).

"(for some reason)" - If you tell us what you are trying to accomplish, we may be able to help you.

One reason is to increase the bandwidth of a server equipped with two full duplex interfaces which are on the same subnet.

I plan to do:
ip route del default
route add default gw 172.20.11.10 dev eth1
route add default gw 172.20.11.10 dev eth0

ip route add 172.20.11.0/24 dev eth0 table 2
ip route add 0/0 via 172.20.11.10 dev eth0 table 2
ip rule add from 172.20.11.242 table 2
ip rule add to 172.20.11.242 table 2

ip route add 172.20.11.0/24 dev eth1 table 3
ip route add 0/0 via 172.20.11.10 dev eth1 table 3
ip rule add from 172.20.11.199 table 3
ip rule add to 172.20.11.199 table 3

echo 1 > /proc/sys/net/ipv4/conf/eth0/arp_filter
echo 1 > /proc/sys/net/ipv4/conf/eth1/arp_filter

However, "SIOCADDRT: Network is unreachable" error occurred.
Please help.
Thanks.

# ip route
172.20.11.0/24 dev eth1 scope link
127.0.0.0/8 dev lo scope link
default via 172.20.11.10 dev eth1

# route add default gw 172.20.11.10 dev eth0
SIOCADDRT: Network is unreachable


All times are GMT -5. The time now is 07:14 AM.