IPTABLES Interview Questions & Answers

  1. Question 1. What Is Iptables ?

    Answer :

    iptables is a user space application program that allows a system administrator to configure the tables provided by the Linux kernel firewall (implemented as different Netfilter modules) and the chains and rules it stores. Different kernel modules and programs are currently used for different protocols; iptables applies to IPv4, ip6tables to IPv6, arptables to ARP, and ebtables to Ethernet frames.

  2. Question 2. What Is The Configuration File Of Iptables In Linux ?

    Answer :

    /etc/sysconfig/iptables

  3. Linux Interview Questions

  4. Question 3. What Are Tables Used In Iptables ?

    Answer :

    • Nat Table
    • Mangle Table
    • Filter Table
  5. Question 4. How To Enable Iptables ?

    Answer :

    • # /etc/init.d/iptables start
    • # chkconfig iptables on
    • # iptables-save > /root/working.fw
  6. Linux Tutorial

  7. Question 5. How To Disable Iptables ?

    Answer :

    # service iptables save

    # service iptables stop

    # chkconfig iptables off

  8. Red Hat Linux Essentials Interview Questions

  9. Question 6. How Do I Save Iptables Rules Or Settings?

    Answer :

    Fedora Linux you can use following commands to save and restore firewall rules. To Save the rules to /etc/sysconfig/iptables file: # /etc/init.d/iptables save To restore the rules from /etc/sysconfig/iptables file: # /etc/init.d/iptables start If you are using Debian / Ubuntu Linux open /etc/network/interfaces: # vi /etc/network/interfaces Append the line to eth0 section: post-up iptables-restore Close and save the file. Reboot the system.

  10. Question 7. How To Restore Rules In Iptables ?

    Answer :

    #iptables-restore < /root/firewall.rules

    #iptables-save > /root/firewall.rules

  11. Red Hat Linux System Administration Interview Questions

  12. Question 8. How To List The Iptable Rules In Iptables ?

    Answer :

    # iptables –list

    #iptables -L

  13. Question 9. How To List The Nat Iptable Rules ?

    Answer :

    # iptables -t nat -L

    # iptables -t nat -L -n -v | grep ‘some-word’

    # iptables -t nat -L -n -v

  14. Samba Server Interview Questions

  15. Question 10. How To Delete Iptable Rules ?

    Answer :

    # iptables –flush

    # iptables –flush OUTPUT  //To delete particular CHAIN

  16. Question 11. Explain Filter Table In Iptables ?

    Answer :

    The filter table should be used exclusively for filtering packets. For example, we could DROP, LOG, ACCEPT or REJECT packets without problems, as we can in the other tables. There are three chains built in to this table. The first one is named FORWARD and is used on all non-locally generated packets that are not destined for our local host (the firewall, in other words). INPUT is used on all packets that are destined for our local host (the firewall) and OUTPUT is finally used for all locally generated packets.

  17. Linux File Systems Interview Questions

  18. Question 12. Some Basic Rules Of Iptables ?

    Answer :

    Interface level:

    Allow incoming packets at interface level

    # iptables -A INPUT -i lo -j ACCEPT

    # iptables -A INPUT -i eth0 -j ACCEPT

    Accept packets from trusted IP addresses:

    iptables -A INPUT -s 192.168.0.4 -j ACCEPT # change the IP address as appropriate

    Accept packets from trusted IP addresses:

    #  iptables -A INPUT -s 192.168.0.0/24 -j ACCEPT   //using standard slash notation

    #  iptables -A INPUT -s 192.168.0.0/255.255.255.0 -j ACCEPT // using a subnet mask

    Accept tcp packets on destination port 6881 (bittorrent):

    # iptables -A INPUT -p tcp –dport 6881 -j ACCEPT

    # Accept tcp packets on destination ports 6881-6890

     #  iptables -A INPUT -p tcp –dport 6881:6890 -j ACCEPT

  19. Linux Interview Questions

  20. Question 13. How To List All The Rules Applied On Your System And How To Flush All Iptables Rules ?

    Answer :

    To list the rules we have on our system use:

    # iptables -nL

    To flush (drop) all the rules we can use:

    # iptables –F

  21. Question 14. Rules For Ssh?

    Answer :

    Accept tcp packets on destination port 22 (SSH)

     # iptables -A INPUT -p tcp –dport 22 -j ACCEPT

    Accept tcp packets on destination port 22 (SSH) from private LAN

    # iptables -A INPUT -p tcp -s 192.168.0.0/24 –dport 22 -j ACCEPT

  22. Question 15. What Are The Target Values In Iptables?

    Answer :

    Following are the possible special values that we can specify in the target.

    ACCEPT :Firewall will accept the packet.

    DROP:Firewall will drop the packet.

    QUEUE : Firewall will pass the packet to the userspace.

    RETURN : Firewall will stop executing the next set of rules in the current chain for this packet. The control will be returned to the calling chain.

  23. BIND Name Server Interview Questions