How to turn anything into a router
25 points by deejayy
25 points by deejayy
i used to use a PC as a router, then I wanted to be able to run on UPS as long as possible during a power outage, so I changed to using a consumer grade wifi AP/router. It is certainly less fun.
Has anyone done something similar with NixOS? And how can I connect this to my ISP?
I'm sure someone has. ;-)
Connecting it to your ISP generally just means plugging the WAN port into the modem that lets you talk your ISP's network, whether it's coax cable or fiber or something else, and convincing said modem to give you an IP address. I've usually seen this done by just running a DHCP client on the WAN interface, but occasionally with odd restrictions or configuration gotchas to work around -- Stuff like the ISP always expecting the same MAC address at your address and having to clear and refresh it when you take their router offline and plug in your own, or their modem also having a router built in so I need to go into its settings and toggle a "passthrough" switch that tells it not to do that. Not huge blockers, but stuff that takes a bit of fiddling. There's an infinite array of possible configurations out there though, and all in all I've somehow ended up with relatively friendly ISPs in the US.
OpenWRT might be useful to you if you've never seen it before.
There's various flakes kicking around to do a "nixos router", there didn't seem to be one that's massively more popular than the others.
As for ISP connection, depends on the technology your uplink uses, and also what's customary in your country. Here in the UK if you're on DSL you'd need a dedicated modem, or an all-in-one consumer router that could be put into bridge mode. Almost all ISPs talk PPPoE over that, but Sky do IPoE.
For UK FTTP, the ISP supplies an ONT that spits out (possibly VLAN-tagged) ethernet. Again, most ISPs using the incumbent infra provider Openreach will do PPPoE, whereas most altnets do IPoE.
Current router for the main server is a NetBSD G4 Mac mini with 1GB of RAM. Other than a kernel hack to automatically restart after a power failure, it's a vanilla install. A couple USB Ethernet interfaces supplement the built-in Ethernet. I kept everything on separate device classes (ure0, axe0, gem0) to make it easier to track, and turned on all the acceleration features those devices had to offer. For a fairly busy system the load average remains very low.
NetBSD is awesome. Any core reasons for choosing Net over OpenBSD for the router? Genuinely curious.
Just familiarity. Used NetBSD since 1.5. I have a Lemote here I'm thinking of turning into an OpenBSD toy box though.
Had this on my mind recently. I'm trying to build a decentralised CCTV solution in my flat block and I was thinking I could use a mini pc as a router and run frigate and home assistant on it at the same time.