# Routing between two NICs



## balanga (Oct 29, 2014)

My FreeBSD system has two NICs which I'm hoping to set up as a router between internal and external networks. The external NIC will just connect to my ADSL modem and the internal NIC to a switch. I want to run DHCPD on the internal NIC but route all Internet traffic from my LAN through my FreeBSD box. 

Any hints and tips as to achieve this would be most welcome.


----------



## DutchDaemon (Oct 29, 2014)

https://www.freebsd.org/doc/handbook/book.html#config-network-setup
https://www.freebsd.org/doc/handbook/book.html#firewalls
https://www.freebsd.org/doc/handbook/book.html#network-servers
https://www.freebsd.org/doc/handbook/book.html#network-dhcp
https://www.freebsd.org/doc/handbook/book.html#advanced-networking


----------



## balanga (Oct 30, 2014)

That's quite a lot to plough through and the scope for errors is immense, but I managed to get things working the way I wanted on OS/2 about 15 years ago so it ought to be easier with FreeBSD.

The big stumbling block at the moment is getting my ADSL modem/router to assign an external IP address to the LAN interface. It is assigned to the WAN interface, so I guess I need to find some way of using it in 'bridge' mode.


----------



## SirDice (Oct 30, 2014)

balanga said:


> That's quite a lot to plough through and the scope for errors is immense


It's the best way to learn. Learn, try, make mistakes, read more, try more.



> The big stumbling block at the moment is getting my ADSL modem/router to assign an external IP address to the LAN interface. It is assigned to the WAN interface, so I guess I need to find some way of using it in 'bridge' mode...


Yes, that would be preferred. Not all xDSL/Cable modems support this though.


----------



## kpa (Oct 30, 2014)

Could you elaborate a bit on what you posted on the other thread:



> I have five real IP addresses.



This can be read at least a couple of ways. First is that your ISP offers you five public IP addresses trough DHCP (often five totally unrelated addresses), this is a very common setup with consumer level internet connections. The other one is that you actually have a routed block of addresses from your ISP. Five addresses would mean a /29 (8 addresses) in CIDR speak, first and last addresses out of eight reserved and one used for the gateway leaving five for you to use as you like. This second setup is common on small business connections.

Which one is your case?


----------



## usdmatt (Oct 30, 2014)

I'm not sure he's talking about the same network in the two threads. In the other thread, his messages suggested that his router was already handling the public addresses correctly and routing them through to his computers (as the Windows laptop was apparently working on a public address). I'm under the impression that once he had the gateway set on the FreeBSD machine, that was working as well.

This thread sounds more like a standard home set up where he has a normal ADSL router/modem connecting via something like PPPoE or DHCP, and he wants to bridge the WAN of the router through to the LAN ports so he can use a FreeBSD machine as his router.

If it's all the same network then I'm confused.



> Not all xDSL/Cable modems support this though.


Being incredibly pedantic, but a *modem* is always "effectively" a bridge. An ADSL modem for example will have an RJ11 interface which negotiates an ADSL connection to the telephone exchange. It will then allow data to flow through its Ethernet port, over the ADSL connection, to an Ethernet network at the ISP's end, basically giving an Ethernet bridge from the internal side of the modem right through to the ISP. You then use a router/computer/whatever connected to the modems RJ45 port to create the Internet connection, usually with PPPoE (at least in the UK). If you order FttC/Infinity in the UK you actually get a BT vDSL modem provided, which is great, as you can connect the Ethernet on their modem to whatever kit you want and just run a PPPoE client.

It's when you have a combined router/modem that you have the problem. The router wan is internally connected to the modem, so you need to be able to bridge the LAN and WAN ports on the internal router in order to allow devices connected to the LAN ports on the back to talk directly to the modem. As mentioned many router/modem combos don't provide this function.


----------



## kpa (Oct 30, 2014)

usdmatt said:


> Being incredibly pedantic, but a *modem* is always "effectively" a bridge. An ADSL modem for example will have an RJ11 interface which negotiates an ADSL connection to the telephone exchange. It will then allow data to flow through its Ethernet port, over the ADSL connection, to an Ethernet network at the ISP's end, basically giving an Ethernet bridge from the internal side of the modem right through to the ISP. You then use a router/computer/whatever to create the Internet connection, usually with PPPoE (at least in the UK).



This depends on what actually goes in the ATM packets over the ADSL line. The easiest thing is of course to wrap ethernet frames in them which is the "bridging" you mentioned, that's the most common set up at least here in Finland. There are other options though like using the ATM link to transfer IP packets without the ethernet encapsulation.


----------



## usdmatt (Oct 30, 2014)

I'm just being awkward about the "modem" or "modem/router" terminology. If the OP had a DSL modem, then he likely would need an external device (such as his FreeBSD machine) to create the Internet connection anyway. It's because he has a combined router/modem that this needing to bridge comes into play.


----------



## balanga (Oct 31, 2014)

kpa said:


> Could you elaborate a bit on what you posted on the other thread:
> 
> 
> 
> ...




My ISP gave me a netmask of 255.255.255.248  - not sure how many actual addresses that covers - maybe it's 7. Netmasks are something I never fully got my head around...


----------

