# Set up FreeBSD machine as router/bridge between a computer and the network



## ada10 (Dec 21, 2021)

I recently installed and did the initial set ups for a FreeBSD virtual machine. My aim is to utilise it as a router/bridge in a network topology structured as follows: from a PC comes a request for a webpage, that is captured by the FreeBSD router (in order to use DummyNet as a test tool on it) and sent to the Internet. I searched online but wasn't able to find nothing up to date or still available. Do any of you have a guide/tutorial or even tips to follow? 
Thanks a lot in advance!


----------



## Zvoni (Dec 21, 2021)

I remember having done something similiar, but on Linux.
I wanted to use my Laptop, which was connected per WiFi to my Router/Internet,
as a "Gateway" for other Machines, connected in a LAN with its own switch, to reach the Internet.
See scenario below

```
192.168.2.0/24       192.168.3.0/24
                         ||                     ||
                         ||                     ||
Internet <-- Router --> WiFi  <-- Laptop --> Switch <-- PC
           |         |         |        |              |
       1.2.3.4/32    |  192.168.2.254   |      192.168.3.2
                     |                  |
                192.168.2.1       192.168.3.1
```
I remember having to setup a DHCP-Server (and DNS? Don't remember anymore) on the Laptop incl. IP-Forwarding and ipTables NAT-rules

Maybe as a starting point for you?


----------



## amilis (Jan 7, 2022)

I’am not sure I understand this..   what is you aim? 
You mention DummyNet, do you mean a testnet or a live net with a transparent bridge, or a TAP, or do you want to ”hide” the FW from the PCs? Or just a router firewall as the subject? But you also mention virtual machine.. 

Can you explain what you are trying to do to a headless like me?


Regardless, you may need a box infront of your FW as a transparent bridge, there you do you stuff on it. Or do a ”ugly” transparent bridge with another NICs in you FW in serial. 

Maybe you can use your firewall (depending of what you aim is) and use PF;
- send PC data to $int_if and RDR it to $loc.
- Pick you data from $loc and do you stuff?
- (Send you data/stuff) to $loc (or direct to $ext_if)
- Get you data from $loc and send it to $ext_if
- Normal nat on $ext_if

But..  it’s hard to say as I don’t understand you goal here.


----------

