Can you give examples of firewall actions?

085

Certainly! Here are some examples of common firewall actions along with scenarios where they might be applied:

1. Allow

  • Example: Allowing web traffic.
    • Rule: Allow incoming TCP traffic on port 80 (HTTP).
    • Scenario: You want users to access your website, so you create a rule to allow traffic on port 80.
    sudo ufw allow 80/tcp

2. Deny

  • Example: Denying SSH access.
    • Rule: Deny incoming TCP traffic on port 22 (SSH).
    • Scenario: You want to prevent remote access to your server via SSH for security reasons.
    sudo ufw deny 22/tcp

3. Drop

  • Example: Dropping unwanted traffic.
    • Rule: Drop incoming UDP traffic from a specific IP address.
    • Scenario: You notice suspicious activity from a particular IP and want to block it without notifying the sender.
    sudo iptables -A INPUT -s 192.168.1.100 -j DROP

4. Reject

  • Example: Rejecting specific traffic.
    • Rule: Reject incoming TCP traffic on port 23 (Telnet).
    • Scenario: You want to block Telnet access and inform users that the connection is rejected.
    sudo iptables -A INPUT -p tcp --dport 23 -j REJECT

5. Log

  • Example: Logging denied traffic.
    • Rule: Log all incoming traffic that is denied.
    • Scenario: You want to monitor attempts to access your server that are blocked by the firewall.
    sudo iptables -A INPUT -j LOG --log-prefix "Denied: "

6. Limit

  • Example: Limiting connection attempts.
    • Rule: Limit incoming connections on port 80 to 10 per minute from a single IP.
    • Scenario: You want to prevent denial-of-service attacks by limiting the number of requests from a single source.
    sudo iptables -A INPUT -p tcp --dport 80 -m conntrack --ctstate NEW -m limit --limit 10/minute -j ACCEPT

7. Redirect

  • Example: Redirecting HTTP traffic.
    • Rule: Redirect incoming traffic from port 80 to port 8080.
    • Scenario: You want to run a web application on a different port while still allowing users to access it via the standard HTTP port.
    sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

Conclusion

These examples illustrate how different firewall actions can be applied to manage network traffic effectively. Each action serves a specific purpose, helping to enhance security and control over your network environment. If you have any further questions or need more examples, feel free to ask!

0 Comments

no data
Be the first to share your comment!