top of page

DIY Router With Ubuntu 14.04 LTS

  • Writer: Mahammad Rafi
    Mahammad Rafi
  • Jun 18, 2017
  • 2 min read

I have been using Ubuntu as my base machine for the past some years. Things have been learning from day to day since then. Recently, my thoughts have crossed the internals of routers and which turned out to be the idea of Ubuntu as a router.


You would be wondering why do we need Ubuntu as a router when we have ready-made one? Assume that, we are living in a town like Mumbai where ISP provide DSL connections to the whole apartment through a switch installed on the top of it. In that case, we don’t have to pay for router or something when we get connected like plugged in directly to the PC or laptop. This scenario makes to think “Linux as a router” if you love and explore the possibilities of Linux.

All we have to need is two LAN card or in my case, second one is WLAN as a Wireless Access Point. Wireless Access Point provide internet as well as IP address from the configured DHCP server which I have installed in my machine. Following are the needful.

DHCP ServerHostapdIPtable ConfigurationSwitch Linux as RouterConfigure Network

DHCP Server

sudo apt-get install dnsmasq
sudo vim /etc/dnsmasq.conf
interface=wlan0
dhcp-range=10.0.0.2,10.0.0.14,12h

Hostapd

sudo apt-get install hostapd
sudo vim /etc/default/hostapd.conf
DAEMON_CONF="/etc/hostapd/hostapd.conf"
sudo nano /etc/hostapd/hostapd.conf
auth_algs=1
beacon_int=50
channel=3
country_code=US
disassoc_low_ack=1
driver=nl80211
hw_mode=g
ht_capab=[HT40+][HT40-][SHORT-GI-40][RX-STBC1]
ieee80211d=1
ieee80211n=1
interface=wlan0
require_ht=0
rsn_pairwise=CCMP
ssid=YOURSSID
wmm_enabled=1
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_passphrase=YOURPASSPHASE

IPtables

sudo nano /etc/rc.local
iptables -t nat -A POSTROUTING \
-o wlan1 -j MASQUERADE
iptables -A FORWARD -m conntrack \
--ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD \
-i wlan0 -o wlan1 -j ACCEPT
exit 0

Switch Linux as router

sudo nano /etc/sysctl.conf
net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1

Configure Network

sudo nano /etc/network/interfaces
auto lo wlan0
iface lo inet loopback
#access point
iface wlan0 inet static
address 10.0.0.1
netmask 255.255.255.240
gateway 10.0.0.1
dns-nameservers 192.168.1.1
wireless-mode Master
sudo nano /etc/NetworkManager/NetworkManager.conf
[keyfile]
unmanaged-devices=mac:XX:XX:XX:XX:XX:XX

Comments


adult-apple-device-business-340152.jpg

Linux .....because life is too short for reboots

I am an avid fan of Linux and open source enthusiast so I make a  decision to meet people through Technical Live Blogger. I have been enjoying Linux for the past six years. Back in 2013, I stumbled upon an article about the Ubuntu live CD. That moment changed my life. I know that statements like that belong to those exaggerators but it is actually true. Within 24 hours of reading the article, I had turned my own desktop in Ubuntu one – a platform where I have explored many Linux things ever since. If you just want to say hello, do say "Hello" at md.rafi1615@gmail.com or visit the virtualworld.

  • LinkedIn Social Icon
  • Twitter Social Icon
  • Instagram Social Icon
  • Facebook Social Icon

© 2023 by Extreme Blog. Proudly created by Mahammad Rafi

bottom of page