DNS Resolution Principle and Linux Server Configuration Practice

This article introduces the principles, Linux configuration, and setup methods of DNS (Domain Name System). DNS, often referred to as the "phone book" of the Internet, translates domain names (e.g., baidu.com) into IP addresses, enabling domain-name-to-IP mapping. Its resolution process consists of six steps: local cache query (checking the hosts file), local DNS server query, root domain server query, top-level domain server query, authoritative domain server query, and finally returning the IP address to the operating system. In Linux, local DNS configuration is implemented through two key files: `/etc/hosts`, acting as a local "mini-address book" with the highest priority; and `/etc/resolv.conf`, which specifies DNS servers (e.g., 114.114.114.114), though it may be dynamically overwritten. Taking BIND as an example for DNS server setup, the steps include installing the software, configuring the main file `/etc/named.conf`, creating forward and reverse zone data files, starting the service, and testing. Common issues include configuration syntax errors, firewall blocking the 53 port (DNS default port), and inability for other devices to resolve names. Troubleshooting involves checking configurations, logs, and permissions. DNS is fundamental to network communication. Mastering its principles and configuration allows efficient management of domain name resolution services.

Read More
Setting IP Addresses on Linux Servers: A Beginner's Guide

The IP address of a Linux server is the foundation for device communication (like a "house number"). IPv4 consists of 4 groups of numbers ranging from 0 to 255 (e.g., 192.168.1.100) and is used to locate devices. IP configuration supports two methods: dynamic (via DHCP, automatic acquisition for temporary testing) and static (manual specification for production environments). To view the IP address: Use `ip addr` (recommended) or `ifconfig` (requires installation on some systems). Identify the network interface name (e.g., eth0/ens33) and the assigned IP address. For static configuration (CentOS example): Confirm the network interface name, modify `/etc/sysconfig/network-scripts/ifcfg-ens33`, set `BOOTPROTO=static`, specify `IPADDR`, `NETMASK`, `GATEWAY`, and `DNS`, then restart the network service with `systemctl restart network` and verify the IP. For dynamic configuration: Change the configuration file's `BOOTPROTO=dhcp`, restart the network, and verify. For Ubuntu, use Netplan; configuration files are located in `/etc/netplan/`, apply changes with `netplan apply`. Common issues: IP conflicts, incorrect gateway/DNS settings. Troubleshoot using tools like `ping`.

Read More
A Step-by-Step Guide to Configuring Linux Firewall (iptables)

This article introduces the configuration of Linux firewall (iptables) with the core objective of protecting server security. iptables is a packet filtering tool that manages traffic through tables (primarily filter), chains (INPUT/OUTPUT/FORWARD), and rules (match conditions + actions). Before configuration, existing rules should be checked (`iptables -L -n`) and cleared (`-F`/`-X`). Key steps include: allowing traffic on the local loopback interface (lo), setting default policies (DROP for inbound, ACCEPT for outbound), opening necessary ports (e.g., SSH, 80/443 for web services), and finally saving the rules (using `service iptables save` for CentOS and installing `iptables-persistent` for Ubuntu). Security considerations: prioritize rule order, apply the principle of least privilege, avoid directly exposing port 22 to the public internet, and regularly audit rules. Common operations include viewing, deleting, and clearing rules. By following these steps, a basic firewall can be quickly configured to meet the security needs of most servers.

Read More
Essential for Beginners: A Detailed Explanation of Linux User Permission Management

Linux permission management is the core of security and collaboration in multi-user systems, aiming to protect system security (preventing misoperations and malicious behaviors) and enable division of labor and collaboration (different users obtaining permissions as needed). Core concepts include three types of users (ordinary users, system users, root), user groups (for unified permission management), and file/directory permissions divided into three categories: owner, group, and others. Each category corresponds to three operations: read (r), write (w), and execute (x) (e.g., a directory requires x permission to be entered). To view permissions, use `ls -l`. To modify permissions, use `chmod` (numerical method: r=4, w=2, x=1; e.g., 754 represents rwxr-xr--; symbolic method: `+/-/=` to add/remove/set permissions, e.g., `u+x` adds execute permission to the owner). Ownership or group can be changed via `chown`/`chgrp`. Common issues to note: Files cannot be modified mostly due to permission or ownership problems; directories cannot be accessed without x permission; ordinary users use `sudo` to escalate privileges. Security recommendations: Minimize root usage, do not grant write permissions to others, and regularly check permissions. Master `ls -l`, `chmod`, and `chown`.

Read More
Beginner's Guide to Nginx: From Installation to Reverse Proxy Configuration

Nginx is a high-performance HTTP and reverse proxy server, lightweight and stable, suitable for scenarios such as website building and load balancing. Installation is divided into Ubuntu/Debian (`sudo apt install nginx`) and CentOS/RHEL (`sudo yum install nginx`). Verification is done with `nginx -v`. Start the service (`sudo systemctl start nginx`) and set it to start automatically (`sudo systemctl enable nginx`). Management commands include start/stop, restart, and reload configuration (`reload`). For core reverse proxy configuration: Create a site configuration file (e.g., `myapp.conf`) in `/etc/nginx/conf.d/`. Example configuration: The `server` listens on port 80, `server_name` is set to the domain name/IP, `location /` forwards to the backend port (e.g., `127.0.0.1:3000`) via `proxy_pass`, and passes Host and real IP through `proxy_set_header`. After configuration, check syntax with `nginx -t`, and `reload` to apply changes, then test access to the backend content. Notes: Open ports 80/443 in the firewall, ensure the backend service is running, and `proxy_pass` must start with `http://`/`https://`.

Read More
Setting up Apache on Linux Servers: Quick Deployment of Websites

### Apache Web Server Setup Guide Apache is an open-source, free, and mainstream web server suitable for Linux, Windows, and other systems, making it the first choice for beginners in website building. The setup process is as follows: **Prerequisites**: A Linux server (e.g., Alibaba Cloud CentOS/Ubuntu), basic command-line operation skills, and root/sudo privileges. **Installation**: For CentOS, use `sudo yum install httpd -y`; for Ubuntu, use `sudo apt install apache2 -y`. **Start and Enable Auto-Start**: On CentOS, run `sudo systemctl start httpd` and `enable` it for boot auto-start; Ubuntu uses `apache2` instead. Check the running status with `systemctl status` (success if it shows `active (running)`). **Firewall Configuration**: Open port 80 (default for HTTP). For CentOS: `firewall-cmd --add-port=80/tcp --permanent` and reload. For Ubuntu: `ufw allow 80/tcp`. **Website Deployment**: The website root directory is `/var/www/html`. Create `index.html` (e.g., with content "Hello, Linux Server!"). After restarting Apache, access the server IP via a browser. **Advanced**: Virtual hosts enable multi-site hosting, requiring configuration of `/etc

Read More
Understanding Linux SSH Service: A Complete Guide to Configuration and Usage

SSH is a secure remote management protocol for Linux servers, replacing insecure services like Telnet by ensuring data security through encrypted transmission. Its advantages include high security (default AES/RSA encryption), cross-platform compatibility, and rich features such as file transfer. It consists of the server-side `sshd` (listening on port 22) and the client-side `ssh`. Installation varies: for Ubuntu/Debian, install and start `sshd` via `apt`; for CentOS/RHEL, use `yum`. Verification involves checking service status and port availability. Basic client login is done with `ssh username@IP`. Passwordless login requires generating a key pair and copying the public key to the server. Server configuration is managed via `sshd_config`, allowing modifications such as changing the port, disabling direct root login, or password-based authentication. After configuration changes, restart the service. Common issues require checking service operation, port accessibility, and firewall settings. SSH is a must-have skill for system administrators, requiring mastery of installation, configuration, and basic usage.

Read More
Zero to Hero: A Guide to Installing Linux on a Server

This article introduces a Linux server installation guide suitable for beginners. Linux servers are secure, efficient, and ideal for high-concurrency tasks, making them fundamental for operations and maintenance. Before installation, the appropriate scenario should be chosen: either a local virtual machine (requiring software like VirtualBox and an Ubuntu Server ISO) or a cloud server (e.g., Alibaba Cloud ECS). Ubuntu Server 22.04 LTS is recommended. For local virtual machine installation: Create a virtual machine (with at least 2GB RAM and a 20GB dynamically allocated hard disk), mount the ISO for booting, select English for installation, use automatic partitioning, set a username and password, check the OpenSSH server option, and verify login after reboot. For cloud server installation: Create an instance on Alibaba Cloud (1 core, 2GB RAM, Ubuntu image) and connect via SSH (using keys for enhanced security). Post-installation verification includes executing `lsb_release -a` to check the version, using `ping` to test network connectivity, and running `sudo apt update` to verify permissions. Beginners should note password security, bridged networking for virtual machines, and installing tools like `vim`. Mastering minimal installation, remote connection, and permission management will enable smooth entry-level operations following the step-by-step instructions.

Read More
Essential for Beginners: 5 Basic Linux Server Commands

This article introduces 5 basic core commands for Linux servers to help beginners quickly get started. The `ls` command is used to view directory files, displaying the current directory by default. Common parameters include `ls -l` (detailed information), `ls -a` (including hidden files), and `ls [path]` (specifying a directory). The `cd` command switches directories: `cd [directory name]` enters a subdirectory, `cd ..` returns to the parent directory, `cd ~` goes to the home directory, and `cd /` navigates to the root directory. The `pwd` command directly displays the current path, preventing operational errors. `mkdir` creates directories: `mkdir [directory name]` creates a single-level directory, while `mkdir -p [multi-level]` builds nested directories. `df -h` checks disk space, with `-h` converting to human-readable units to view partition sizes and usage rates. These 5 "foundation" commands are fundamental for server management. Practicing parameters (e.g., `ls -l/a`, `mkdir -p`) and familiarizing with the "parameter + target" mode will help beginners gradually advance their skills.

Read More