Overview of Linux Network Services¶
In our daily use of computers or mobile phones to access the internet, we interact with various network services, such as visiting webpages, downloading files, and sending emails. Behind these services lies the powerful support provided by the Linux system when acting as a server. Linux network services refer to programs running on Linux servers that are specifically responsible for providing certain network functions, such as domain name resolution, file transfer, and web services. Learning about Linux network services helps us understand the underlying logic of network communication and better manage and maintain servers.
DNS Service: The “Translator” Between Domain Names and IP Addresses¶
What is DNS?¶
When we browse the internet, we are accustomed to using user-friendly URLs like “www.baidu.com,” but computers can only recognize numeric IP addresses (e.g., 14.215.177.38). The role of DNS (Domain Name System) is to translate “easy-to-remember domain names” into “IP addresses that computers can understand,” much like a phonebook maps “names” to “phone numbers.”
How DNS Works¶
Imagine you want to contact a friend named “Xiaoming.” You first ask the phonebook (DNS server) for “Xiaoming’s phone number,” and the phonebook will find the corresponding number (IP address), allowing you to call him. Specifically:
1. When you enter “www.baidu.com” in your browser, the system first checks the local cache (for any previously visited records);
2. If the cache is empty, it sends a query request to the DNS server configured locally (e.g., your home router or DNS provided by your ISP);
3. The DNS server will find the corresponding IP address through “recursive query” or “iterative query” and return it to your device;
4. Once your device receives the IP address, it can connect to the server hosting the target website.
DNS Configuration in Linux¶
On Linux clients (e.g., Ubuntu, CentOS), the DNS configuration file is /etc/resolv.conf, which records the DNS server addresses that the local device will query. For example:
nameserver 8.8.8.8 # Google's DNS server
nameserver 114.114.114.114 # Common domestic DNS server
After modifying this file, restart the network service (e.g., systemctl restart network) to apply the new DNS settings.
FTP Service: The “Courier” for File Transfer¶
What is FTP?¶
FTP (File Transfer Protocol) is a tool specifically designed for transferring files over the network, such as downloading materials from a server or uploading your own files to a server. It is more efficient than ordinary “copy-paste” operations, especially for large-scale file transfers.
How FTP Works¶
FTP relies on two core “channels”:
- Control Connection (Port 21): Responsible for transmitting commands (e.g., “I want to upload a file” or “I want to download a file”);
- Data Connection (Port 20 or Random Port): Responsible for actually transferring file content.
For example, if you want to download a video from a server, the process is:
1. You use an FTP client (e.g., the ftp command or FileZilla) to connect to the server and enter your account credentials (or log in anonymously, e.g., on public download sites);
2. You use the control connection to tell the server, “I want to download video.mp4”;
3. The server “delivers” the file content to your device via the data connection.
FTP Implementation in Linux¶
The most commonly used FTP server software in Linux is vsftpd (Very Secure FTP Daemon), which is secure and stable. After installation, the core configuration file is /etc/vsftpd/vsftpd.conf, where you can control FTP behavior by modifying this file (e.g., allowing anonymous login, user permissions, etc.).
- Anonymous FTP: Allows access by anyone, commonly found on open-source software download sites (e.g., official mirrors of some Linux distributions);
- User FTP: Requires account credentials, often used for internal corporate file sharing.
Common Issues and Troubleshooting¶
DNS Troubleshooting¶
- Unable to access websites: Check if the DNS server addresses in
/etc/resolv.confare correct (e.g., they may reset during network outages); - Domain name resolution failure: Use the
nslookup www.baidu.comcommand to manually query DNS. If it returns “Server failure,” the DNS server may be down; try switching to another DNS (e.g., 8.8.8.8).
FTP Troubleshooting¶
- Connection timeout: Check if the vsftpd server is running (
systemctl status vsftpd) and if the firewall allows port 21 (firewall-cmd --list-ports); - Insufficient permissions: If uploading files fails, verify that the vsftpd configuration file allows user writes (
write_enable=YES).
Summary and Practical Recommendations¶
Linux network services are the cornerstone of internet operations, with DNS and FTP being among the most fundamental services. By understanding their roles and configurations, you can better manage servers and troubleshoot network issues.
Practical Suggestions:
1. On your Linux system, use nslookup to test DNS resolution (e.g., query the IP of www.qq.com);
2. Try connecting to a public FTP server using the ftp command (e.g., ftp ftp.linux.org with anonymous login) to experience the file transfer process.
The core of network services is “solving connectivity and communication.” By hands-on practice and observation, you will discover the power of Linux!