Docsity

Ubuntu Linux Networking Commands: A Comprehensive Guide, Lecture notes of Computer Security

Toggle sidebar
bg1
Complied and Researched By Dr. Fred Wauyo
1. Alternative Workarounds
If you cannot upgrade immediately, try these temporary solutions:
1. Use Old Ubuntu Repositories (Temporary Fix)
1. Open the sources list file:
Bash
sudo nano /etc/apt/sources.list
2. Find any lines containing archive.ubuntu.com or security.ubuntu.com and replace them with:
deb http://old-releases.ubuntu.com/ubuntu kinetic main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu kinetic-updates main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu kinetic-security main restricted universe multiverse
3. Save and exit (Ctrl + X, then Y, then Enter).
4. Update package lists:
bash
sudo apt update && sudo apt upgrade -y
5. Try installing net-tools again:
bash
sudo apt install net-tools
2. Use IP instead of ifconfig (Recommended)
Since ifconfig is deprecated, it's better to use the ip command:
• View IP addresses:
bash
ip a

Partial preview of the text

Download Ubuntu Linux Networking Commands: A Comprehensive Guide and more Lecture notes Computer Security in PDF only on Docsity!

Complied and Researched By Dr. Fred Wauyo

1. Alternative Workarounds If you cannot upgrade immediately , try these temporary solutions: 1. Use Old Ubuntu Repositories (Temporary Fix)

  1. Open the sources list file: Bash sudo nano /etc/apt/sources.list
  2. Find any lines containing archive.ubuntu.com or security.ubuntu.com and replace them with: deb http://old-releases.ubuntu.com/ubuntu kinetic main restricted universe multiverse deb http://old-releases.ubuntu.com/ubuntu kinetic-updates main restricted universe multiverse deb http://old-releases.ubuntu.com/ubuntu kinetic-security main restricted universe multiverse
  3. Save and exit ( Ctrl + X , then Y , then Enter ).
  4. Update package lists: bash sudo apt update && sudo apt upgrade - y
  5. Try installing net-tools again: bash sudo apt install net-tools 2. Use IP instead of ifconfig (Recommended) Since ifconfig is deprecated, it's better to use the ip command:
  • View IP addresses: bash ip a
  • Bring up/down an interface: bash sudo ip link set eth0 up sudo ip link set eth0 down Before installing Apache, I recommend upgrading to Ubuntu 24.04 LTS , which is still supported. To do this, run: bash sudo apt update && sudo apt upgrade - y sudo do-release-upgrade After upgrading, you can install Apache normally.
  1. If you cannot upgrade immediately , follow these steps: Step 1: Update Sources to Old Releases
  2. Open the sources list file: bash sudo nano /etc/apt/sources.list
  3. Replace all occurrences of archive.ubuntu.com and security.ubuntu.com with old- releases.ubuntu.com. The modified lines should look like this: deb http://old-releases.ubuntu.com/ubuntu kinetic main restricted universe multiverse deb http://old-releases.ubuntu.com/ubuntu kinetic-updates main restricted universe multiverse deb http://old-releases.ubuntu.com/ubuntu kinetic-security main restricted universe multiverse
  4. Save and exit ( Ctrl + X , then Y , then Enter ). Step 2: Update Package Lists Run: bash sudo apt update && sudo apt upgrade - y Step 3: Install Apache Now install Apache: bash
  1. Open a web browser (Firefox, Chrome, etc.).
  2. Type the following in the address bar and press Enter : http://localhost http://127.0.0. You should see the default Apache2 Ubuntu welcome page with the message "It works!" Step 3: Find Your Server's IP Address (For Remote Access) If you want to access the Apache page from another device on the network, find your Ubuntu system’s IP address: ip a Look for an IP address in the format 192.168.x.x or 10.x.x.x (depending on your network). Then, open a browser on another device and enter: http://<your-server-ip> For example: http://192.168.1. Step 4: Allow Apache Through the Firewall (If Needed) If you're unable to access the page, check if the firewall is blocking Apache: sudo ufw allow 'Apache Full' sudo ufw enable sudo ufw status This allows HTTP traffic on port 80. Step 5: Restart Apache (If Changes Were Made) If you made any changes, restart Apache to apply them: sudo systemctl restart apache Troubleshooting
  • If the page does not load, check if Apache is listening on port 80: bash

sudo netstat - tulnp | grep apache or bash sudo ss - tulnp | grep apache

  • If Apache is not running, reinstall it: bash sudo apt reinstall apache2 - y
  • If you see a 404 error , the default Apache page might be missing. Try reinstalling: bash sudo apt install --reinstall apache2 - y Installing Software When you need to install a package using apt, you must use sudo because modifying system- wide software requires superuser privileges. Example: Install the VLC Media Player bash sudo apt install vlc - y
  • This installs VLC on your system.
  • The - y flag automatically answers "yes" to installation prompts.

Alternative: Use ss - tulnp for modern Ubuntu versions.

4. Check Routing Table (route) bash route - n - Shows the kernel routing table. - - n prevents resolving IP addresses to hostnames for faster output. Alternative: Use ip route show. 5. View Active ARP Table (arp) bash arp - a - Displays ARP (Address Resolution Protocol) cache. Alternative: Use ip neigh. 6. Enable or Disable a Network Interface bash sudo ifconfig eth0 up # Enable interface sudo ifconfig eth0 down # Disable interface 7. Assign a Static IP Address bash sudo ifconfig eth0 192.168.1.100 netmask 255.255.255. - Temporarily assigns 192.168.1.100 to eth0. Use /etc/netplan/ for permanent changes in newer Ubuntu versions. 8. Test Network Connectivity (ping) bash ping google.com

  • Sends ICMP packets to check network connectivity.
  • Example: Ping a specific IP: bash ping 8.8.8. 9. Check Open Ports (netstat or ss) bash netstat - ant or bash ss - ant
  • Lists active TCP connections and listening ports. 10. Display DNS Information (nslookup and dig) bash nslookup google.com
  • Resolves domain names to IP addresses.
  • Alternative: bash dig google.com 11. Find the Default Gateway bash route - n | grep 'UG'

sudo nmap - sn 192.168.1.0/

  • Scans the local network for active hosts. 15. Trace Network Route (traceroute) bash sudo apt install traceroute - y traceroute google.com
  • Shows the path packets take to reach a destination. 8. Find Hostname from IP (nslookup or dig) bash nslookup google.com or bash dig google.com
  • Resolves domain names to IP addresses. 9. Display DNS Server Information bash cat /etc/resolv.conf
  • Shows the configured DNS servers.

Port & Connection Monitoring

10. Check Open Ports (ss and netstat) bash ss - tulnp or bash netstat - tulnp - Lists all open TCP & UDP ports. 11. Show All Established Connections bash ss - s - Displays summary statistics of active connections. 12. Check Listening Services bash netstat - plnt - Shows which ports are actively listening. 13. Scan Network for Open Ports (nmap) bash sudo nmap - p 1-65535 localhost - Scans all 65,535 ports on the local system.

bash nmcli dev wifi connect "WiFi_Name" password "WiFi_Password"

  • Connects to a Wi-Fi network from the terminal. **Network Services & Performance Monitoring
  1. Check Internet Speed (speedtest-cli)** bash sudo apt install speedtest-cli - y speedtest-cli
  • Runs a speed test from the command line. 19. Display Live Network Usage (iftop) bash sudo apt install iftop - y sudo iftop
  • Shows real-time bandwidth usage. 20. Monitor System Performance (htop and top) bash htop or bash top
  • Monitors CPU and memory usage.

Advanced Network Security & Troubleshooting

21. Block an IP Using UFW (Firewall) bash sudo ufw deny from 192.168.1. - Blocks all traffic from IP 192.168.1.50. 22. Check Active Firewall Rules bash sudo ufw status - Displays current firewall rules. 23. Flush All Firewall Rules bash sudo iptables --flush - Resets all firewall rules. 24. Find MAC Address bash ip link show eth or bash ifconfig eth0 | grep ether - Displays the MAC address of an interface. 25. Enable Packet Forwarding bash sudo sysctl - w net.ipv4.ip_forward=