Setting up a Home Router: Difference between revisions

From Alpine Linux
(Adjusted intro to reflect intended change in direction.)
m (AlpinePhil moved page User:AlpinePhil/Router to Setting up a Home Router: Moving a draft howto out into the real world)
 
(7 intermediate revisions by the same user not shown)
Line 5: Line 5:


As such this HowTo will indicate the relevant pieces of software, and link to the corresponding documentation. It will also contain some more general guidance.
As such this HowTo will indicate the relevant pieces of software, and link to the corresponding documentation. It will also contain some more general guidance.
{{Note|Throughout this HowTo, it is presumed that you have a router provided by your ISP via which you can get an internet connection}}


== Before You Start ==
== Before You Start ==
Line 19: Line 17:
* CIDR (Notation of the form 192.168.1.0/24)
* CIDR (Notation of the form 192.168.1.0/24)


==Enable Routing and Set Up Routes==
The clue is in the name that routing is at the heart of what a router does.
To enable routing, you will need to add a line
<code>net.ipv4.ip_forward=1</code> to the file /etc/sysctl.conf and then run
<code>sysctl -p</code> with administrative privileges.
If you have subnets managed by their own routers in your network, you may need to add [[How to configure static routes|static routing]].
Dynamic routing is an advanced topic which goes beyond the range of this HowTo.
==Configuring Network Interfaces==
Generally speaking, routers are in charge of their own IP addresses, as such you will need to understand how to [[Configure Networking#Static address configuration|configure static IP addresses on the interfaces]].
==Connecting to the Internet - pppd==
{{Warning|If you are planning on connecting your router directly to the internet, you should have a firewall in place. See next section.}}
If you are looking to connect your router directly to the internet without using the router from your ISP, then you will need to configure pppd. The documentation for pppd can be found [https://linux.die.net/man/8/pppd here].


=== You should have done ===
On a practical note, it is helpful to download pppd and your firewall of choice using your ISPs provided router and configure them prior to connecting your home-made router to the internet directly.


Ensure to [[Configure Networking|Connect your router to your ISP router]]. This howto will presume throughout that this connection is set up on the interface eth0.
==Firewalls==


=== You should ===
Firewalls At the time of writing, there are three main firewall options available of which the author is aware:


Design your network address layout
* [[Uncomplicated Firewall|ufw - the uncomplicated firewall]]
* [https://wiki.nftables.org/wiki-nftables/index.php/Main_Page nftables]
* IPTables is also an option - but be advised that it is an older piece of software with a somewhat arcane syntax. It has been superseded by nftables.


== Setting up your router ==
==DHCP Server==
There are two options for your router, depending on whether you wish to use statically or dynamically assigned addresses for your network.


Statically assigned addresses are generally only suitable for networks where there are a very limited number of computers connecting to the router. Moreover, they are unsuitable for situations in which computers which you do not control will need access to your network, for example if you are setting up a router including a wireless interface.
A DHCP server is responsible for assigning dynamic IP addresses to computers attached to your network.


=== Setting up a network with statically assigned addresses ===
If your network is small enough, and the constituent computers do not change regularly, you might consider sticking with static (manually) assigned IP addresses. However, beyond a certain size and/or if you have changing members of your network (for example, house guests using your wi-fi), then DHCP becomes quite important.


The only DHCP server that the author was able to install and operate from the default repositories at the time of writing was [https://dnsmasq.org/docs/dnsmasq-man.html dnsmasq.]
=== Setting up a network with dynamically assigned addresses ===


== Extension: Adding routes to subnets ==
==Hosting Wi-Fi==


== Optional Next Steps ==
See [[How to setup a wireless access point]].


* Set up a firewall on your router
[[Category: Networking]]
* Set up pppd on your router to manage an ISP connection directly
* Set up hostapd to set up a wireless network

Latest revision as of 20:06, 23 September 2025

This material needs expanding ...

To include information on ipv6

This HowTo is written to indicate the basics necessary to get a simple router set up for a network. Unlike most HowTos, this will not form an exhaustive list of instructions, as a home router is not one piece of software, and not every piece of software listed here will be relevant to your specific requirements. Moreover, the individual pieces of software themselves, in particular firewalls, require configuration which requires documentation in their own right.

As such this HowTo will indicate the relevant pieces of software, and link to the corresponding documentation. It will also contain some more general guidance.

Before You Start

You should know

This article presumes that you are familiar with the fundamentals of IP networks. In particular you should have a good understanding of the terms:

  • IP Address
  • Address Mask
  • Subnet
  • CIDR (Notation of the form 192.168.1.0/24)

Enable Routing and Set Up Routes

The clue is in the name that routing is at the heart of what a router does.

To enable routing, you will need to add a line net.ipv4.ip_forward=1 to the file /etc/sysctl.conf and then run sysctl -p with administrative privileges.

If you have subnets managed by their own routers in your network, you may need to add static routing.

Dynamic routing is an advanced topic which goes beyond the range of this HowTo.

Configuring Network Interfaces

Generally speaking, routers are in charge of their own IP addresses, as such you will need to understand how to configure static IP addresses on the interfaces.

Connecting to the Internet - pppd

Warning: If you are planning on connecting your router directly to the internet, you should have a firewall in place. See next section.


If you are looking to connect your router directly to the internet without using the router from your ISP, then you will need to configure pppd. The documentation for pppd can be found here.

On a practical note, it is helpful to download pppd and your firewall of choice using your ISPs provided router and configure them prior to connecting your home-made router to the internet directly.

Firewalls

Firewalls At the time of writing, there are three main firewall options available of which the author is aware:

DHCP Server

A DHCP server is responsible for assigning dynamic IP addresses to computers attached to your network.

If your network is small enough, and the constituent computers do not change regularly, you might consider sticking with static (manually) assigned IP addresses. However, beyond a certain size and/or if you have changing members of your network (for example, house guests using your wi-fi), then DHCP becomes quite important.

The only DHCP server that the author was able to install and operate from the default repositories at the time of writing was dnsmasq.

Hosting Wi-Fi

See How to setup a wireless access point.