Firewall IPTABLES Interview Questions and Answer in Linux

IPTABLES linux firewall interview questions and answers in Linux

Here are some Firewall Iptables Interview questions .

Q1: – What is iptables ?

Ans: 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.

 Q2: – What is the configuration file of iptables in linux ?

Ans: /etc/sysconfig/iptables

Q3: – What are tables used in iptables ?

Ans: Nat Table

Mangle Table

Filter Table

Q4: How to Enable IPTABLES ?

Ans: # /etc/init.d/iptables start

# chkconfig iptables on

# iptables-save > /root/working.fw

Q5: How to disable IPTABLES ?

Ans: # service iptables save

# service iptables stop

# chkconfig iptables off

Q6: How To clear IP rules in IPTABLES use below commands:

Ans: # iptables -F

# iptables -X

# iptables -t nat -F

# iptables -t nat -X

# iptables -t mangle -F

# iptables -t mangle -X

# iptables -P INPUT ACCEPT

# iptables -P OUTPUT ACCEPT

Q7:  How Do I Save Iptables Rules or Settings?

Ans: 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.

Q8: How to restore Rules in IPTABLES  ?

Ans: #iptables-restore < /root/firewall.rules

#iptables-save > /root/firewall.rules

Q9: How to List the iptable Rules in IPTABLES ?

Ans: # iptables –list

#iptables -L

Q10: How to List the NAT iptable Rules ?

Ans: # iptables -t nat -L

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

# iptables -t nat -L -n -v

Q11: How to delete iptable rules ?

Ans: # iptables –flush

# iptables –flush OUTPUT  //To delete particular CHAIN

Q12: Explain filter table in iptables ?

Ans: 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.

Q13: Some basic Rules of IPTABLES ?

Ans: Interface level:

Allow incoming packets at interface level

Ans: # iptables -A INPUT -i lo -j ACCEPT

# iptables -A INPUT -i eth0 -j ACCEPT

Accept packets from trusted IP addresses

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

 Accept packets from trusted IP addresses

Ans: #  iptables -A INPUT -s -j ACCEPT   //using standard slash notation

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

Accept tcp packets on destination port 6881 (bittorrent)

 Ans: # 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

Q14: How To list all the rules applied on your system and how to flush all iptables rules ?

Ans: To list the rules we have on our system use:

# iptables -nL

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

# iptables –F

Q15: Rules for SSH:


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 –dport 22 -j ACCEPT

Q16: What are the target vaules in iptables ?

Ans: 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

Read Related Topics

2 thoughts on “Firewall IPTABLES Interview Questions and Answer in Linux

Leave a Reply

Your email address will not be published. Required fields are marked *