ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Sample Working IPTables

    IT Discussion
    iptables linux firewall security
    2
    4
    1.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • scottalanmillerS
      scottalanmiller
      last edited by

      Here is a sample, simple working IPTables file from CentOS 5:

      # cat /etc/sysconfig/iptables
      *filter
      :INPUT ACCEPT [0:0]
      :FORWARD ACCEPT [0:0]
      :OUTPUT ACCEPT [0:0]
      -A INPUT -s 1.0.0.0/255.0.0.0 -j DROP
      -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
      -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
      -A INPUT -p icmp -j ACCEPT
      -A INPUT -i lo -j ACCEPT
      -A INPUT -j REJECT --reject-with icmp-host-prohibited
      -A FORWARD -j REJECT --reject-with icmp-host-prohibited
      COMMIT
      

      This line:

      -A INPUT -s 1.0.0.0/255.0.0.0 -j DROP
      

      Is an example of how to block a range you don't want to access your machine.

      1 Reply Last reply Reply Quote 2
      • dafyreD
        dafyre
        last edited by dafyre

        What if we wanted to simply default to DROP or REJECT for anything that doesn't have a specific rule?

        Or is that what the last two -j REJECT lines are for?

        1 Reply Last reply Reply Quote 0
        • dafyreD
          dafyre
          last edited by

          Scratch that... I was able to figure it out.

          The configuration that you posted by default denies everything but SSH.

          Thanks!

          scottalanmillerS 1 Reply Last reply Reply Quote 0
          • scottalanmillerS
            scottalanmiller @dafyre
            last edited by

            @dafyre said:

            Scratch that... I was able to figure it out.

            The configuration that you posted by default denies everything but SSH.

            Thanks!

            Correct 🙂

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post