Configuring an Old Server as a Home Router (Using Ubuntu)
This article provides a detailed guide on configuring an old server as a home router using Ubuntu. The server will act as a router, providing network connectivity to devices in your home.
Prerequisites
- Basic Linux knowledge
- An old server with minimal hardware requirements (1GB RAM, 2 cores, 20GB storage)
- A stable Internet connection
Steps
-
Install Ubuntu Server
Follow the official Ubuntu Server installation guide to install Ubuntu Server on your old server.
-
Update and Upgrade
After installation, open a terminal and run the following commands to update and upgrade the system:
sudo apt-get update sudo apt-get upgrade -
Install Networking Packages
Install the necessary networking packages:
sudo apt-get install isc-dhcp-server isc-dhcp-client bind9 dnsmasq iptables -
Configure Network Interfaces
Edit the
/etc/network/interfacesfile and configure the network interfaces:# Loopback interface auto lo iface lo inet loopback # Eth0 - LAN Interface auto eth0 iface eth0 inet static address 192.168.1.1 netmask 255.255.255.0 gateway 192.168.1.254 # Eth1 - WAN Interface auto eth1 iface eth1 inet dhcpSave and exit the file.
-
Configure DHCP Server
Edit the
/etc/dhcp/dhcpd.conffile and configure the DHCP range:subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.100 192.168.1.200; option routers 192.168.1.1; option domain-name-servers 8.8.8.8, 8.8.4.4; }Save and exit the file. Restart the DHCP server:
sudo systemctl restart isc-dhcp-server -
Configure DNS Server
Edit the
/etc/bind/named.conf.optionsfile:// named.conf.options options { directory "/var/cache/bind"; // If there is a firewall between you and nameservers you want // to talk to, you may need to fix the firewall to allow multiple // ports to talk. See http://www.kb.cert.org/vuls/id/800113 // If your ISP provided one or more IP addresses for stable // nameservers, you probably want to use them as forwarders. // Uncomment the following block, and insert the addresses replacing // the all-0's placeholder. // forwarders { // 0.0.0.0; // }; //======================================================================== // If BIND logs error messages about the root key being expired, // you will need to update your keys. See https://www.isc.org/bind-keys //======================================================================== dnssec-validation auto; auth-nxdomain no; # conform to RFC1035 listen-on-v6 { any; }; };Edit the
/etc/bind/db.localfile:$TTL 604800 @ IN SOA localhost. root.localhost. ( 1 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL ; @ IN NS localhost. @ IN A 127.0.0.1 localhost IN A 127.0.0.1Save and exit the files. Restart the DNS server:
sudo systemctl restart bind9 -
Configure DNSMasq
Edit the
/etc/dhcp/dhcp-options.conffile:option domain-name "yourdomain.com"; option domain-name-servers 8.8.8.8, 8.8.4.4;Save and exit the file.
-
Configure Firewall
Open the
/etc/sysctl.conffile and uncomment the following line:net.ipv4.ip_forward=1Save and exit the file. Apply the changes:
sudo sysctl -p /etc/sysctl.confInstall
iptables-persistentto save the firewall rules:sudo apt-get install iptables-persistentConfigure the firewall rules:
sudo iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE sudo iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT sudo iptables -A FORWARD -i eth1 -o eth0 -j ACCEPTSave the rules:
sudo service iptables-persistent save -
Reboot
Reboot the server:
sudo reboot
After rebooting, your old server should act as a home router, providing network connectivity to devices in your home.
References