npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

router-setup

v1.0.4

Published

NPM library to set up a quick and easy linux router

Downloads

10

Readme

router-setup

NPM library to set up a quick and easy linux router. This was originally written and tested for raspberry pi running debian. But it should work on any system as long as you have the packages installed.

Modules used

  • netplan-config
  • [hostapd-config] (https://www.npmjs.com/package/hostapd-config)
  • [dhcpd-multi] (https://www.npmjs.com/package/dhcpd-multi)
  • [iptabler] (https://www.npmjs.com/package/iptabler)

Note: Be sure to read the documentation for the above if you want to do custom configurations

Linux packages needed

You will need these installed on your system in order for everything to work.

  • Node.js and NPM (obviously)
  • netplan.io
  • isc-dhcp-server
  • hostapd
  • iptables

What it does

This library will set up your device as a router by doing the following:

  • Configures the WAN and LAN interfaces using netplan
  • Configures DHCP servers on the LANs where desired
  • Configures hostapd on the wireless LANs
  • Configures iptables rules to forward LAN traffic to WAN, and masquerade outgoing on WAN
  • Enables IPv4 forwarding

Note: IPv6 not currently supported Note: currently this library doesn't set up a DNS server on your router. If you want that, you will have to do it yourself.

Usage

const Router = require('router-setup');
 
const router = new Router({
  wan: {
    iface: 'eth0',
    def: {
        ip: '192.168.4.102',
        defaultGateway: '192.168.4.1',
        nameservers: ['192.168.4.1'],
        domain: 'guardian-angel.local'
    }
  },
  lans: [
    {
      iface: 'eth1',
      network: '192.168.5.0',
      dhcpServer: {
        beginIP: '192.168.5.2',
        endIP: '192.168.5.254',
        domain: 'guardian-angel.local',
        nameservers: ['8.8.8.8', '8.8.4.4']
      },
      ip: '192.168.5.1'
    },
    {
      iface: 'wlan0',
	  network: '192.168.6.0',
	  dhcpServer: {
	    domain: 'guardian-angel.local'
      },
      accessPoint: {
        ssid: 'FBI Surveillance Van',
        wpaPassphrase: 'supersecretpassword'
      }
    }
  ]
});

router.deploy().then(() => {
  console.log('deployed successfully');
});

Options fields

  • netplan (optional) - This is an optional custom netplan-config config object. See netplan-config module documentation for more details.
  • wan - This defines the WAN interface. It contains an iface field and a def field which represents a netplan-config interface definition. (Again, see netplan-config)
  • lans - This is a list of LANs that you will be serving internet to. The fields will be described in the section below.

LAN fields

  • iface - interface that is being served (required)
  • network - subnet that you are running on (required)
  • prefix - integer representing subnet prefix length (default is 24)
  • ip - the IP for the router on that interface. This will be the gateway IP for your clients. By default, it is the first IP in the subnet block.
  • accessPoint - If you are running a WiFi access point, this contains the ssid and wpaPassphrase for your wifi network. This is basically a config object for the hostapd-config module. See its documentation for more details.
  • dhcpServer - This is a config object for the dhcpd-multi module, see its documentation for details. By default, the DHCP range is from the second IP to the last IP in the subnet block.

Note: By default the nameservers list for dhcpServer is set to simply your configured router's IP. If you don't set this manually, then you have to make sure DNS is up and running on your router. Otherwise you better specify this manually.