0% found this document useful (0 votes)
56 views4 pages

NXLD46 Linux As A Router

Linux can be used as a powerful router for a small home or office network. By installing an additional network interface card and Linux distribution, and configuring IP forwarding, NAT, firewall rules, and DNSmasq, an old PC can function as a router to eliminate the need for a separate hardware router purchase. The configuration process takes only a few simple steps and commands to set up routing between the network interfaces and provide network address translation and DHCP services for other devices on the local area network.

Uploaded by

celosc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views4 pages

NXLD46 Linux As A Router

Linux can be used as a powerful router for a small home or office network. By installing an additional network interface card and Linux distribution, and configuring IP forwarding, NAT, firewall rules, and DNSmasq, an old PC can function as a router to eliminate the need for a separate hardware router purchase. The configuration process takes only a few simple steps and commands to set up routing between the network interfaces and provide network address translation and DHCP services for other devices on the local area network.

Uploaded by

celosc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Linux as a Router

Here is good news for you, if you have an old PC hardware. Dont throw it away. It can eliminate the
need of purchasing a router for your small network.
A Linux system could work as a powerful router in small network. You only have to install a Linux Distro
on your PC/Laptop and install an extra NIC if you only have one. It only takes two minutes to configure a
Linux machine as a router. This blog show you how to configure Linux as a router in few simple steps.

Prerequisites
1.
2.
3.
4.
5.

A Linux system with two or more interfaces.


Internet Connection.
IP tables basic knowledge. (need not to be a geek)
Another system on LAN for testing.
Dnsmasq. (if a DHCP is not working in your LAN environment)

Topology

Figure 1 Topology

Linux as a Router
Steps
1. Configuring ip address
edit network connection setting from the setting menu

Figure 2 Config IP

address

Figure 3 Config IP

address

2. Enable ip forwarding
Run this command in terminal
sudo echo 1 /proc/sys/net/ipv4/ip_forward
This will give output as
1 /proc/sys/net/ipv4/ip_forward
To make the change permanent so after next boot you don't have to enable ip forwarding again. Edit
/etc/systcl.conf
and uncomment the line
net.ipv4.ip_forward=1

Linux as a Router

Figure 4

3. For enabling NATing issue the command:


sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
4. Configuring firewall to allow inbound and outbound transit traffic by the follwoing commands:

sudo iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT


sudo iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
5. Configuring dnsmasq
Dnsmasq is a lightweight dns cum dhcp/tftp server and it is easily configurable. Just uncomment the line
#dhcp-range=192.168.0.50,192.168.0.150,12h
Here u can change the range with your choice of subnet, no need to change other things dnsmasq will
automatically provide default router and DNS server ip address as the ip of machine it is running on.

Linux as a Router
(NOTE: if you have a DHCP serer already in your environment you need not to follow this step just
configure your DHCP to provide gateway ip address as the ip address of LAN facing interface of Linux
machine or set "option 3 " as the ip address of Linux machine.)
6. Test the connectivity to internet on test pc

Figure 5

(NOTE: The interface used here i.e. eth0 & eth1 could be different on your machine i.e. the machine can
be connected to internet via a PPP (point to point) or wireless connection, so make change in
configuration according to your need.)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy