How to Set Up a Linux Server Subnet with 192.168.0.X IP Range – A Step-by-Step Guide

Linux terminal displaying network configuration for setting up a subnet with 192.168.0.X IP range.

Setting up a Linux server subnet with a 192.168.0.X IP range is essential for creating a structured and secure local network. Whether you're managing a home network, small business, or enterprise environment, configuring a subnet allows for better traffic control, security, and efficient resource allocation.

In this guide, we will walk through the step-by-step process of setting up a Linux server subnet, including IP assignment, subnet masking, DHCP setup, and firewall rules to ensure a properly functioning and secure network.


Understanding Subnetting and 192.168.0.X IP Range

The 192.168.0.X IP range belongs to the private Class C address space (192.168.0.0/24). This range is commonly used in local area networks (LANs) and is not routable on the public internet.

By subnetting this range, you can divide the network into smaller segments, improve security, and manage device communication efficiently.

🔹 Example Network Setup Using 192.168.0.X:

  • Router/Gateway: 192.168.0.1
  • Linux Server: 192.168.0.10
  • Client Devices (PCs, IoT, etc.): 192.168.0.20 – 192.168.0.50

Step 1: Configure the Network Interface on the Linux Server

To assign a static IP address within the 192.168.0.X subnet, follow these steps:

For Debian/Ubuntu-based Systems

1️⃣ Open the network configuration file:

bash
sudo nano /etc/netplan/00-installer-config.yaml

2️⃣ Add or modify the following configuration:

yaml
network: ethernets: eth0: dhcp4: no addresses: - 192.168.0.10/24 gateway4: 192.168.0.1 nameservers: addresses: - 8.8.8.8 - 8.8.4.4 version: 2

3️⃣ Apply the configuration:

bash
sudo netplan apply

For RHEL/CentOS-based Systems

1️⃣ Open the interface configuration file:

bash
sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0

2️⃣ Modify the file with these values:

ini
DEVICE=eth0 BOOTPROTO=none ONBOOT=yes IPADDR=192.168.0.10 NETMASK=255.255.255.0 GATEWAY=192.168.0.1 DNS1=8.8.8.8 DNS2=8.8.4.4

3️⃣ Restart the network service:

bash
sudo systemctl restart NetworkManager

Step 2: Setting Up a DHCP Server (Optional)

If you want automatic IP assignment within the subnet, install and configure a DHCP server on your Linux machine.

Installing DHCP Server on Ubuntu/Debian

bash
sudo apt install isc-dhcp-server -y

Configuring DHCP Server

Edit the configuration file:

bash
sudo nano /etc/dhcp/dhcpd.conf

Add the following settings:

plaintext
subnet 192.168.0.0 netmask 255.255.255.0 { range 192.168.0.100 192.168.0.200; option routers 192.168.0.1; option domain-name-servers 8.8.8.8, 8.8.4.4; default-lease-time 600; max-lease-time 7200; }

Restart the DHCP service:

bash
sudo systemctl restart isc-dhcp-server

Now, devices on the network will receive IP addresses automatically within the 192.168.0.100 – 192.168.0.200 range.


Step 3: Configuring the Firewall for Subnet Access

For better security, set up firewall rules to control access to and from the subnet.

Using UFW (Uncomplicated Firewall) on Ubuntu/Debian

bash
sudo ufw allow from 192.168.0.0/24 to any port 22 proto tcp sudo ufw allow from 192.168.0.0/24 to any port 80 proto tcp sudo ufw enable

Using Firewalld on CentOS/RHEL

bash
sudo firewall-cmd --permanent --zone=trusted --add-source=192.168.0.0/24 sudo firewall-cmd --permanent --add-service=ssh sudo firewall-cmd --reload

Step 4: Enabling Packet Forwarding for the Subnet

If you need devices in the subnet to communicate with the internet, enable IP forwarding.

1️⃣ Open the sysctl configuration file:

bash
sudo nano /etc/sysctl.conf

2️⃣ Enable packet forwarding by adding:

plaintext
net.ipv4.ip_forward=1

3️⃣ Apply the changes:

bash
sudo sysctl -p

Step 5: Assigning Static IPs to Specific Devices

To assign a permanent IP to a device, modify the DHCP server configuration and bind the IP address to a MAC address:

plaintext
host mypc { hardware ethernet 00:1A:2B:3C:4D:5E; fixed-address 192.168.0.50; }

Restart the DHCP server:

bash
sudo systemctl restart isc-dhcp-server

This ensures that mypc always gets the 192.168.0.50 IP address.


Step 6: Testing the Subnet Configuration

To verify that everything is working correctly:

Check IP Address:

bash
ip a

Ping a Device on the Subnet:

bash
ping 192.168.0.1

Check DHCP Lease Assignments:

bash
cat /var/lib/dhcp/dhcpd.leases

Verify Internet Access:

bash
curl -I google.com

If all tests pass, your Linux server subnet with 192.168.0.X IP range is successfully configured! 🚀


Conclusion

Setting up a Linux server subnet using the 192.168.0.X IP range improves network efficiency, security, and manageability. By configuring static IPs, DHCP services, firewall rules, and packet forwarding, you ensure a smooth and secure networking environment.

🔹 Best for Small Networks: Static IP Assignment
🔹 Best for Large Networks: DHCP Configuration
🔹 Best for Security: Firewall Rules & Packet Filtering

By following this guide, you can build a robust subnet for your home, office, or enterprise while keeping it efficient and secure.

💡 Need help with troubleshooting? Drop your questions in the comments!

Post a Comment

0 Comments