All Projects → stanipintjuk → nixos-router

stanipintjuk / nixos-router

Licence: other
NixOS expression for creating a simple router

Programming Languages

Nix
1067 projects

Projects that are alternatives of or similar to nixos-router

nixos-raspberry-pi-cluster
A user-guide to create a Raspberry Pi (3B+, 4) cluster under NixOS and managed by NixOps
Stars: ✭ 69 (+115.63%)
Mutual labels:  nixos
nixos-configuration
A repo for my nixos configuration files
Stars: ✭ 20 (-37.5%)
Mutual labels:  nixos
nix-build-cache
Extends stdenv.mkDerivation based builds with a distributed build cache on Amazon S3.
Stars: ✭ 24 (-25%)
Mutual labels:  nixos
nix-configs
My Nix{OS} configuration files
Stars: ✭ 54 (+68.75%)
Mutual labels:  nixos
nix-config
A collection of my system configs and dotfiles
Stars: ✭ 35 (+9.38%)
Mutual labels:  nixos
impermanence
Modules to help you handle persistent state on systems with ephemeral root storage [maintainer=@talyz]
Stars: ✭ 401 (+1153.13%)
Mutual labels:  nixos
Arduino-STM32-Ethernet-LAN8720
Ethernet on STM32 using external PHY
Stars: ✭ 19 (-40.62%)
Mutual labels:  ethernet
nix-articles
Some articles about getting started with Nix programming & configuration
Stars: ✭ 134 (+318.75%)
Mutual labels:  nixos
EtherSia
Minimal IPv6 library for Ethernet controllers on Arduino
Stars: ✭ 54 (+68.75%)
Mutual labels:  ethernet
UPnP Generic
A simple library that implements port mappings to router using UPnP SSDP for Arduino boards, running on nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, RP2040-based boards, WT32_ETH01, Portenta_H7, etc. besides ESP8266/ESP32, using ESP WiFi, WiFiNINA, Ethernet W5x00, ESP8266/ESP32 AT-command WiFi, Portenta_H7 Murata WiFi or Vision-shield Ethe…
Stars: ✭ 14 (-56.25%)
Mutual labels:  ethernet
nix-xdg
[WIP] Nix overlay for making programs xdg compliant
Stars: ✭ 18 (-43.75%)
Mutual labels:  nixos
v-switch
Virtual Encrypted Switch across the network, using UDP + AES + TAP
Stars: ✭ 27 (-15.62%)
Mutual labels:  ethernet
crane
A Nix library for building cargo projects. Never build twice thanks to incremental artifact caching.
Stars: ✭ 348 (+987.5%)
Mutual labels:  nixos
dns.nix
A Nix DSL for DNS zone files
Stars: ✭ 69 (+115.63%)
Mutual labels:  nixos
ipv6-dhclient-script
IPv6 w/ dhclient configuration script (Debian/RedHat-based distros)
Stars: ✭ 68 (+112.5%)
Mutual labels:  dhcpd
nixconfig
My NixOS config
Stars: ✭ 67 (+109.38%)
Mutual labels:  nixos
dotfiles
For keeping all my Dotfiles update to date
Stars: ✭ 29 (-9.37%)
Mutual labels:  nixos
dotfiles
pls help
Stars: ✭ 301 (+840.63%)
Mutual labels:  nixos
dotfiles-nix
Configuration files for my NixOS machine, declared by home-manager
Stars: ✭ 137 (+328.13%)
Mutual labels:  nixos
nixvim
Configure Neovim with Nix!
Stars: ✭ 120 (+275%)
Mutual labels:  nixos

NixOS Router

NixOS expression for creating a simple router from your ethernet ports.

Why?

I am not networking a expert. I don't even know the true meaning of "a router" or a lot of details around NATs, I just wanted to enable internet access on my Raspberry Pi by connecting it to one of my ethernet ports on my PC. And guess what? It worked! So I might as well share my stuff :)

How do I use it?

  1. Have NixOS
  2. Clone this repo
  3. Add this to your imports:
  (import /path/the/cloned/repo/mkRouter.nix {
    internalInterface = "enp4s0"; # or w/e ethernet interface you want to connect your raspberry pi to
    externalInterface = "wlp0s20f0u8"; # or w/e interface you get your internet connection to your pc
  })

Now just run nixos-rebuild switch, plug in your Raspberry Pi (or any other device you want) into the ethernet port, and BOOM! Magic! (You might have to reboot your PC though)

What is the IP of my connected device?

It will probably be 192.168.2.10

If it isn't then you can run a ping sweep using nmap

nmap -sn 192.168.2.0-255

this will list all the pingable devices that you route your internet connection to.

If you don't want the ip address range to be 192.168.2.XXX then look at the next section

What configurations are available

I have added a few parameters that you can add along side internalInterface and externalInterface. All of these parameters have default values. There are some parameters

Parameter Explanation Default Value Type
ipRange The ip range of your subnet. Your interface (your "router") will be automatically assigned to XXX.XXX.XXX.1 192.168.2.0/24 String in the form XXX.XXX.XXX.0/24
maxLeaseTime maps to max-lease-time in dhcpd config 604800 String or Int
defaultLeaseTime maps to default-lease-time in dhcpd config 86400 String or Int
dnsServers A list of DNS Server IPs that you want your connected devices to use [ "8.8.8.8" "8.8.4.4" ] List of Strings

Wan't to yell?

You're welcome to make an issue or write to [email protected], or contact me on telegram https://t.me/StaniBanani

I am always open to yelling!

Creds

This NixOS expression was inspired .. by my need for having my Raspberry Pi close to my PC at all times ...

AND /u/poo_22 on reddit https://www.reddit.com/r/NixOS/comments/3unzet/help_i_am_having_trouble_setting_up_networking/

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].