Why would I use a PC/Laptop as a router & why not a dedicated  hardware router?

PC/Laptop hardware is often more powerful than an SoC (System-on-Chip) in a router, has much memory available, and many people have older PCs lying around that can be put to use as a router/firewall. Moreover we can overcome proprietary hardware dependency with this. To use PC/Laptop as a router we have many options available in the market, one of them is OpenWrt.

What is OpenWrt & why to use it on PC/Laptop?

OpenWrt is an embedded operating system based on the Linux kernel, mostly used to route network traffic, so it can be used as a router.

OpenWrt has 3500 optional software packages available which allows us a lot of customization through the use of packages to suit our needs, but with other options available in the market custom configuration is a hustle.

With OpenWrt router on a pc we can have the flexibility of upgrading the hardware & more software features can be added to the setup on a PC/Laptop as we can have the flexibility of more memory.

So let’s see how can we setup an OpenWrt Wifi Router on a PC/Laptop.

Installation Of OpenWrt

As of writing this post the latest OpenWrt release is  “chaos calmer 15.0x”

Boot into the laptop using a live linux OS like Ubuntu Live DVD and issue following command

Increase Root Partition Size

To increase root partition use same live linux OS like Ubuntu Live DVD that we have used in the above step, boot into your OpenWRT installed Laptop using it and then use “gparted” to increase the root partition size, make sure to have a backup of your existing OpenWRT installation if needed.

Note: To increase the root partition size you need to have free space after that partition.

Power Off and start the system after removing live OS

Configuration of interfaces

I’m using my inbuilt interfaces eth0 & wlan0, my interfaces layout is:-
Interface eth0:  by default it is connected to bridge “br-lan” & I’ve configured it to be part of my internal network
Interface wlan0: I’m using it for dhcp server and  Wifi Access-Point

There are multiple ways to choose the layout of interfaces, instead of using bridges, we can also work things out using uci.

 

For Web Interface

Install any other packages if required, especially drivers if needed.

Configuration Of DHCP Server

Configuration Of WiFi Router/Access-Point

The wireless UCI configuration is found in /etc/config/wireless.

Note: By default the wireless is OFF. You can turn it on in the /etc/config/wireless by changing disabled 1 to disabled 0

In UCI CLI you do this with:

Regenerate Configuration
To rebuild the configuration file, e.g. after installing a new wireless driver, remove the existing wireless configuration (if any) and use the wifi detect command with stdout redirected to the /etc/config/wireless file.

Wifi detect gives UCI configuration entries for all installed interfaces that do not have UCI entries in /etc/config/wireless. So you can remove /etc/config/wireless and run the above again to reset your wifi configuration.

Note: These iptables rules are not permanent, in case of restart they’re lost. We can put them in “/etc/firewall.user” they’ll get executed with each firewall (re-)start.

We can do many more things with this OpenWrt laptop-router like:

  • Wireless bridge, Wireless repeater, Wireless security: Packet injection
  • IPS (Intrusion Prevention System) with Snort
  • Stateful firewall, NAT and port forwarding through netfilter
  • IP tunneling, Network Monitoring and statistics through e.g. collectd, nagios, zabbix etc.