การจัดการไฟร์วอลล์: `ufw`, `firewalld`, `iptables`
เรียนรู้การกำหนดค่าและจัดการไฟร์วอลล์เพื่อป้องกันระบบ Linux จากการเข้าถึงโดยไม่ได้รับอนุญาต
การจัดการไฟร์วอลล์: `ufw`, `firewalld`, `iptables` เป็นบทเรียน Linux Command Line Mastery ฟรีบน CoddyKit นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Linux Command Line Mastery และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Linux Command Line Mastery มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
What's a Firewall?
A firewall acts as a security guard for your computer or network. It controls incoming and outgoing network traffic by analyzing data packets and deciding whether to allow or block them based on a set of predefined rules.
Think of it as a filter that protects your system from unauthorized access and malicious threats.
Introducing UFW
UFW, which stands for "Uncomplicated Firewall," is a user-friendly front-end for iptables, the complex default firewall utility in Linux. It's designed to make firewall management much simpler, especially for users on Debian-based systems like Ubuntu.
UFW simplifies common tasks like opening or closing ports.
UFW Status & Control
Before making changes, it's good practice to check UFW's current status. You can also easily enable or disable it.
Try running these commands:
sudo ufw status
sudo ufw enable
sudo ufw disableUFW: Allow Services
UFW allows you to open ports for common services by their name, which is very convenient. For example, to allow SSH or HTTP traffic, you just use the service name.
Let's try allowing SSH and HTTP:
sudo ufw allow ssh
sudo ufw allow http
sudo ufw status verboseUFW: Allow Custom Ports
Sometimes you need to open a specific port that isn't a named service. You can do this by specifying the port number and the protocol (TCP or UDP).
Here's how to allow port 8080 for TCP and 53 for UDP:
sudo ufw allow 8080/tcp
sudo ufw allow 53/udp
sudo ufw status verboseIntroducing Firewalld
Firewalld is another popular firewall management tool, often found on Red Hat-based systems like CentOS and Fedora. Unlike UFW, Firewalld is a dynamic firewall manager.
It uses zones to define different trust levels for network connections, allowing you to apply rules based on where the connection originates.
Firewalld Status & Zones
With Firewalld, you can check its status and explore the various zones it uses. Zones like public, home, or internal have different default rules.
Check the status and active zones:
sudo systemctl status firewalld
sudo firewall-cmd --get-active-zones
sudo firewall-cmd --get-zonesFirewalld: Manage Services
To manage services with Firewalld, you specify the zone and the service name. Changes are temporary by default; use --permanent to make them stick after a reboot, then --reload to apply.
Let's add HTTP service to the public zone permanently:
sudo firewall-cmd --zone=public --add-service=http --permanent
sudo firewall-cmd --reload
sudo firewall-cmd --list-services --zone=publicFirewalld: Manage Ports
Similar to services, you can open or close specific port numbers in a Firewalld zone. Remember to specify the protocol (TCP or UDP) and use --permanent for lasting changes.
Here's how to open port 8080 for TCP permanently:
sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent
sudo firewall-cmd --reload
sudo firewall-cmd --list-ports --zone=publicFirewall Commands Check
Time for a quick check! Which of the following statements about firewall management in Linux are true?
Recap: Firewall Essentials
In this lesson, we explored how to manage firewalls on Linux systems to enhance security. We covered two main tools:
- UFW (Uncomplicated Firewall): A simple interface for
iptables, popular on Debian/Ubuntu, allowing easy control over services and ports. - Firewalld: A dynamic firewall manager used on RHEL/CentOS systems, which organizes rules into zones for flexible security policies.
Understanding these tools is crucial for securing your Linux server or workstation.
คำถามที่พบบ่อย
บทเรียน “การจัดการไฟร์วอลล์: `ufw`, `firewalld`, `iptables`” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “การจัดการไฟร์วอลล์: `ufw`, `firewalld`, `iptables`” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Linux Command Line Mastery ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Linux Command Line Mastery มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “การจัดการไฟร์วอลล์: `ufw`, `firewalld`, `iptables`”
เรียนรู้การกำหนดค่าและจัดการไฟร์วอลล์เพื่อป้องกันระบบ Linux จากการเข้าถึงโดยไม่ได้รับอนุญาต คุณปฏิบัติ Linux Command Line Mastery ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Linux Command Line Mastery หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Linux Command Line Mastery บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน
บทเรียน “การจัดการไฟร์วอลล์: `ufw`, `firewalld`, `iptables`” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Linux Command Line Mastery นี้ได้ไหม
ได้ บทเรียน Linux Command Line Mastery ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- การวินิจฉัยเครือข่าย: `traceroute`, `nslookup`, `dig`
- การจัดการไฟร์วอลล์: `ufw`, `firewalld`, `iptables`
- การจัดการคีย์ Secure Shell
- การจับและตรวจสอบปริมาณการรับส่งข้อมูลด้วย tcpdump