Setting Up the Network on a New Ubuntu Server
Step 1: Update and Upgrade the System
First, ensure your system is up to date:
bash
sudo apt update
sudo apt upgrade -yStep 2: Configure the Firewall
Ubuntu comes with UFW (Uncomplicated Firewall) by default. Enable and configure it:
bash
sudo ufw enable
sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
sudo ufw statusStep 3: Set Up IP Tables
IPTables can be used for more advanced network configurations:
bash
sudo apt install iptablesCreate a basic IP tables configuration:
bash
sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT
sudo iptables -A INPUT -j DROPSave the IP tables configuration:
bash
sudo sh -c "iptables-save > /etc/iptables/rules.v4"Step 4: Configure Network Interfaces
Edit the network interfaces configuration file:
bash
sudo nano /etc/netplan/01-netcfg.yamlExample configuration:
yaml
network:
version: 2
ethernets:
eth0:
dhcp4: no
addresses:
- 192.168.1.100/24
gateway4: 192.168.1.1
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4Apply the configuration:
bash
sudo netplan applyStep 5: Additional Security Policies
Disable root login via SSH:
bash
sudo nano /etc/ssh/sshd_configSet PermitRootLogin to no:
plaintext
PermitRootLogin noRestart SSH service:
bash
sudo systemctl restart sshStep 6: CoreUtils and Additional Tools
Install coreutils and other useful tools:
bash
sudo apt install coreutils htop vimConclusion
Your Ubuntu server network is now configured with a firewall, IP tables, and additional security policies.