Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Recommended Posts

Posted

I've got 3 network cards in my debian box, ive got two that are on the same subnet which are 192.168.2.1/255.255.252.0 and 192.168.2.10/255.255.252.0

 

When i send traffic to 192.168.2.10 it goes through the 192.168.2.1 card, i presume this is some sort of routing issue.

 

How can i fix it so that the traffic for each ip goes through the correct network card for it?

 

Thanks

Jack

Posted

This is actually the correct behavior, the problem is down to the arp replies coming from any interface on the box before you get to ping it.

 

You can change the way it works by setting some options in /etc/sysctl.conf (example from a load balancer, but it's the same principle):

 

#========================================================================
# UltraMonkey requirements below
#

# Enable configuration of arp_ignore option
net.ipv4.conf.all.arp_ignore = 1

# When an arp request is received on eth0, only respond if that address is
# configured on eth0. In particular, do not respond if the address is
# configured on lo
net.ipv4.conf.eth0.arp_ignore = 1

# Ditto for eth1, add for all ARPing interfaces
net.ipv4.conf.eth1.arp_ignore = 1

# Enable configuration of arp_announce option
net.ipv4.conf.all.arp_announce = 2

# When making an ARP request sent through eth0 Always use an address that
# is configured on eth0 as the source address of the ARP request.  If this
# is not set, and packets are being sent out eth0 for an address that is on
# lo, and an arp request is required, then the address on lo will be used.
# As the source IP address of arp requests is entered into the ARP cache on
# the destination, it has the effect of announcing this address.  This is
# not desirable in this case as adresses on lo on the real-servers should
# be announced only by the linux-director.
net.ipv4.conf.eth0.arp_announce = 2

# Ditto for eth1, add for all ARPing interfaces
net.ipv4.conf.eth1.arp_announce = 2

# Enables packet forwarding
net.ipv4.ip_forward = 1

#
# UltraMonkey requirements above
#========================================================================

 

/sbin/sysctl -p

will apply the changes.

Posted

Dead right there.

 

arp is ethernet technology while TCP/IP is a layer of abstraction above it. TCP/IP packets get sent down to the Ethernet layer which has no knowledge of the TCP/IP layer. Therefore as far as packets on your hardware network cards are concerned either card is a perfectly acceptable way into the device's TCP/IP stack where they then get routed to the correct address.

 

Loadbalancing is what you need and the linux Kernel is great at and the instructions above should get you going.

 

A machine can never successfully have 2 default gateways. You can specify 2 in Linux but only 1 will work. Default gateway is the default route to send a packet if you don't know the exact destination of that packet so there can be only 1. TCP/IP on LAN networks or internet follows a simple rule. It looks at the IP address, Splits it into Network address and Device address using the subnet mask and then asks itself the question. Do I know where that network is? If its does it send the packet out that interface to its intended recipient. If it doesn't it sends it to its defined default gateway which then makes the same choice.

 

To use TCP/IP to send packets over particular interfaces requires a routing table and the interfaces have to be on different TCP/IP networks. The routing table can be an automatically generated one like the internet or in simpler LAN networks a static routing table manually configured.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...