Linux Network Configuration and Secure Remote Access: IP, Netplan, SSH, and UFW
This guide walks through checking Linux network status with the ip and ping commands, setting a static IP using Netplan, installing and using SSH for secure remote login (including key‑based authentication), transferring files with scp, and configuring the uncomplicated firewall (UFW) while avoiding common pitfalls.
1. View Network Status
ip command
The legacy ifconfig tool has been superseded; the modern ip utility is now standard for network inspection.
ip addr # view IP addresses
ip route # view gateway/route tableping
Use ping to test network connectivity. ping baidu.com If a domain name fails to ping but its IP (e.g., 1.1.1.1) responds, the issue is typically DNS.
2. Configure IP Address (Netplan)
Ubuntu manages network settings with Netplan . Configuration files reside in /etc/netplan/, commonly named 01-netcfg.yaml.
Static IP example:
network:
version: 2
renderer: networkd
ethernets:
enp3s0:
dhcp4: no
addresses:
- 192.168.1.100/24
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 1.1.1.1]Apply the changes with: sudo netplan apply Desktop users typically configure the network via Settings → Network, avoiding manual file edits.
3. SSH Remote Login
SSH (Secure Shell) is the standard for Linux remote management.
Install SSH Server: sudo apt install openssh-server Check service status: sudo systemctl status ssh Connect from another machine: ssh [email protected] Using key‑based authentication (as described in the SSH Key chapter) is recommended for long‑term remote management because it is more secure and eliminates password entry.
4. File Transfer (SCP)
SSH includes built‑in file transfer capabilities, removing the need for FTP.
Upload: scp local_file.txt user@remote_ip:/home/user/ Download:
scp user@remote_ip:/home/user/remote_file.txt .5. Firewall (UFW)
Ubuntu ships with UFW (Uncomplicated Firewall), which is straightforward to use.
sudo ufw enable # enable firewall
sudo ufw allow ssh # allow SSH (port 22)
sudo ufw allow 80/tcp # allow HTTP
sudo ufw status # view statusNote: Ensure allow ssh is configured before enabling the firewall, or you may lock yourself out of the server.
If you only want LAN access to SSH, use a more restrictive rule:
sudo ufw allow from 192.168.1.0/24 to any port 22 proto tcpSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Ubuntu
Focused on Ubuntu/Linux tech sharing, offering the latest news, practical tools, beginner tutorials, and problem solutions. Connecting open-source enthusiasts to build a Linux learning community. Join our QQ group or channel for discussion!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
