Configuring firewalls in Linux can enhance your system's security by controlling the traffic that is allowed to enter or exit your network. Two popular tools for managing firewalls in Linux are iptables and firewalld. Here's a brief overview of how to configure both.
Iptables is a user-space utility program that allows a system administrator to configure the IP packet filter rules of the Linux kernel. Below is an example of how to set up basic iptables rules.
# Flush existing rules
iptables -F
# Allow loopback traffic
iptables -A INPUT -i lo -j ACCEPT
# Allow established sessions
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow SSH
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
# Drop all other inbound traffic
iptables -A INPUT -j DROP
# Save the rules
service iptables save
Firewalld is a dynamic firewall manager that supports both IPv4 and IPv6. It provides a more user-friendly interface and is often used as a replacement for iptables. Here’s how to set up basic rules in firewalld.
# Start and enable firewalld
systemctl start firewalld
systemctl enable firewalld
# Allow SSH service
firewall-cmd --permanent --add-service=ssh
# Allow HTTP and HTTPS services
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
# Reload firewalld to apply changes
firewall-cmd --reload
These configurations can help in securing your Linux system. Be sure to customize the rules according to your specific needs.
How do I avoid rehashing overhead with std::set in multithreaded code?
How do I find elements with custom comparators with std::set for embedded targets?
How do I erase elements while iterating with std::set for embedded targets?
How do I provide stable iteration order with std::unordered_map for large datasets?
How do I reserve capacity ahead of time with std::unordered_map for large datasets?
How do I erase elements while iterating with std::unordered_map in multithreaded code?
How do I provide stable iteration order with std::map for embedded targets?
How do I provide stable iteration order with std::map in multithreaded code?
How do I avoid rehashing overhead with std::map in performance-sensitive code?
How do I merge two containers efficiently with std::map for embedded targets?