# Configure PC as router



## Alain De Vos (Jun 12, 2021)

I want to configure my PC as router.But I'm afraid two DHCP servers , one of my ADSL-modem and one of my PC will fight.
Can I configure a Linux client to give preference to a certain DHCP server.
Or by placing the DHCP server in other subnets.
But still then the client will send a request over the broadcast domain , no ?
The hub will forward DHCP-requests and to my PC-router and to my ADSL-modem and both will answer I think.
How is this mostly solved ?


----------



## zirias@ (Jun 12, 2021)

A _modem_ doesn't route and therefore doesn't have DHCP either. You probably have a device, that can do both then? Act as a "simple" modem as well as a router?

Then configure it as a simple modem, and on your software router, enable ppp(8) to establish the internet connection, install a DHCP server, and so on…


----------



## Alain De Vos (Jun 12, 2021)

My PPPOA ADSL-modem has integrated DHCP server, firewall, nat.
[ In a later configuration i plan to ppp through the adsl modem and receive a public IP-address, but it takes longer to startup, ppp-setup time]
PS : I found in a dhcp request you can place a "servername" string.


----------



## zirias@ (Jun 12, 2021)

Alain De Vos said:


> My PPPOA ADSL-modem has integrated DHCP server, firewall, nat.


If it is really a _modem_, you can disable all that. It makes no sense to have it twice.

You can of course have a second router (even doing NAT a second time) behind your other router, just use a different private network. But I don't see why someone would want to do that.


----------



## Lamia (Jun 12, 2021)

Simply change the configuration on the ADSL to bridge modem and get your PC to do the PPPOE authentication, DHCP, nat, etc.


----------



## Alain De Vos (Jun 12, 2021)

The telco provider more or less locked the modem.
But the provider allows to set a ppp connection through it, so you have the same effect. Indeed.


----------



## Lamia (Jun 12, 2021)

Alain De Vos said:


> The telco provider more or less locked the modem


Notwithstanding, several Telco modems still include the bridge mode option. I think it depends on your modem on purchase/rental.

Otherwise, you have very limited options.


----------



## Alain De Vos (Jun 12, 2021)

On one hand the modem is limited and locked.
On the other hand I had found I can setup 4 parallel ppp connections through it and receive 4 public routable IPv4-addresses.


----------



## Lamia (Jun 12, 2021)

Alain De Vos said:


> the other hand I had found I can setup 4 parallel ppp connections through it and receive 4 public routable IPv4-addresses.


You'll be paying for those public/static IP addresses with your provider. And for four PPP connections with the same credential, I really hope so.


----------



## Alain De Vos (Jun 12, 2021)

No additional price. The ppp dial-in credential is the same.
Offcourse the public addresses are changing, i think each 18hours.
The provider tells this is for security reasons ... Yes offcourse ...


----------



## Jose (Jun 12, 2021)

Alain De Vos said:


> Can I configure a Linux client to give preference to a certain DHCP server.


No*. DHCP broadcasts happen at the link layer. The only way to isolate these is with separate switches or VLANs.


Alain De Vos said:


> Or by placing the DHCP server in other subnets.


Subnets require an IP address. You can't subnet before the DHCP server gives you one.


Alain De Vos said:


> But still then the client will send a request over the broadcast domain , no ?
> The hub will forward DHCP-requests and to my PC-router and to my ADSL-modem and both will answer I think.
> How is this mostly solved ?


VLAN or separate hardware, as I said above.


Alain De Vos said:


> PS : I found in a dhcp request you can place a "servername" string.


This is for dynamic DNS. The DHCP server would insert that servername into your dynamic zone for the IP that it just handed out.

* You could mess around with the `--whitelist` and `--blacklist` options of dhcpcd(8). It might work. I've never tried it and never will.


----------



## im (Jun 13, 2021)

You can install your PCrouter behind the modem and build your own Internet access server with FreeBSD, nat, dns, DHCP, etc.
Your PC should have 2 network interfaces (or 1 interface with VLANs, and network swich with VLAN support).
I did the same many times without any issues.
DHCP traffic does not cross any router, except preconfigured cases like DHCP-relay.

Be patient about "Second NAT" - it will not affect the connection speed because of ADSL is slow by definition. 
Any PC, even outdated, can do routing and NATing 25Mbit/s easily.

If you want to have remote access to the PCrouter from Internet - you should have possibility to configure "port forwarding" on your modem.

You should not have two DHCP-servers within single unsplitted network, except  special cases.


----------



## Alain De Vos (Jun 13, 2021)

I'm a few 100 meters from the telco's backbone. ADSL or is it VDSL i don't know gives me download speed of 80Mbps.
It uses simple telephone cable but they use some sort of noise cancelation techniques between the different adsl connections.
I think i'll just tunnel trough the ADSL-router and get via tun  public ip-adres. All this traffic is tunneled and does not use IP encapsulation. Then I'll setup my own DHCP server and disable the one on the router.


----------



## Alain De Vos (Jun 15, 2021)

It seems the DHCP is an essential part of my Telco's setup. Without the internal DHCP server of the modem I lose my TV working and also the web interface to the modem itself.
Further I only have one network card. Could user-mode NAT work with it ?
Or add a plugin card in my PC with an addional network interface, or USB-to-IP if that exists.
They should work with freebsd.


----------



## im (Jun 15, 2021)

Alain De Vos said:


> Without the internal DHCP server of the modem I lose my TV working and also the web interface to the modem itself.


Are you configured static IP-address on TV and computer?
If you don't have any DHCP server in your network then you should to configure manually IPs of all devices.

The same situation is for web-access to modem.
Usually, if modem has no DHCP-server, then you should set some IP for your device. That IP must be in the same network as modem. After that usually web access works.



Alain De Vos said:


> Or add a plugin card in my PC with an addional network interface, or USB-to-IP if that exists.


I have used few USB-Ethernet adapters. Avoid cheap chinesse ones, because they are bad.
I prefer to have PCI or PCIex additional network adapters. Most of them works fine with FreeBSD.


----------



## Alain De Vos (Jun 15, 2021)

Fun detail. The telco can not re-enable the DHCP server remotely. I have to hand in my modem manually.


----------

