# Two LAN cards, weird behavior



## abdelilah (Jul 20, 2013)

Hi everyone,

I have FreeBSD 8.3 with two LAN cards, when enabling only one of them I can access the network perfectly, but once I configure the second one I lose connectivity instantly, here is my situation:

re0: 192.168.1.50/22 (default)
me0: 192.168.1.60/22

Could you please help me with this? My goal is to use them simultaneously.


----------



## kpa (Jul 20, 2013)

What's your goal with using two NICs in the same subnet? Load balancing? You can't have two NICs with overlapping subnets with FreeBSD because the network routes in the routing tables will conflict with each other.


----------



## ShelLuser (Jul 20, 2013)

abdelilah said:
			
		

> re0 : 192.168.1.50/22 (default)
> me0 : 192.168.1.60/22
> 
> Could you please help me witch this my goal is to use them simultaneously.


You most likely want to look into lagg(4).

Its a virtual network interface which can analyse your network data and then spread it across both NICs ("Network Interface Card"), the manual page has all the information.

As to the reason why your scenario above didn't work..

When it comes to networking you will need to tell your system _exactly_ what to do with your setup, this includes using 2 NICs. Don't expect a situation where you can simply request access to a website using NIC one and expect the results to automatically return on either NIC depending on their workload. A request going out on NIC one will always see the response also arriving there.

The keyword to all this is routing. Using the route command you can tell your system exactly which data it should sent over which network card. Also important: which NIC it should use for its default route; the route the machine should use when it can't contact anything directly.

And here a problem can appear; Internet access is usually established by using a default route. After all; it's impossible for your system to know everything about the whole Internet. But this also means that everything will be sent out through that one single route (so also one single NIC).

You can overrule this by manually adding a specific route to a certain host and then set it up so that it will use the other NIC, which will overrule the default route. But this still means that you'll have to set it up all manually.

A good source to read up on routing is the advanced networking chapter in the FreeBSD handbook.

And that is why your above setup didn't work. Both cards overlap on the same network and your machine most likely doesn't have a specific routing table setup to utilize both of them.

Hope this gives you some useful information.


----------



## abdelilah (Jul 20, 2013)

Thank you very much for clear explanation, I'm not a network expert but the reason which I want to use such setup is that because I have a router of which I don't have the password, the ISP just doesn't want to give it to us, the problem is that it is set up on 192.168.1.3/22 an I can't change that setting by myself and I don't want their lousy support to touch my setup.

The server with two LAN cards is an asterisk, to avoid jitter/crackles and bandwidth consumption by other clients I want to plug the router in the secondary LAN em0 and the primary re0 in the LAN network so Asterisk can communicate with the clients and the router directly, any idea how to do this, please, thank you in advance.

By the way the clients are also in 192.168.0.0/22.

Any idea how can I make this scenario work.


----------



## abdelilah (Jul 24, 2013)

It's solved by enabling 
	
	



```
gateway_enable="YES"
```
 in /etc/rc.conf, then by changing the addressing of the second card in 192.168.12.0/22.


----------

