IPTables Firewall Interview Questions and Answers - Cloud Network

Networking | Support | Tricks | Troubleshoot | Tips

Buymecoffe

Buy Me A Coffee

Wednesday, October 16, 2019

IPTables Firewall Interview Questions and Answers



 Q :- What is Filter Table & Explain about the chains ?
Ans :-
Filter is default table for iptables. So, if you don’t define you own table, you’ll be using filter table. Iptables filter table has the following built-in chains.

INPUT chain – Incoming to firewall. For packets coming to the local server.
OUTPUT chain – Outgoing from firewall. For packets generated locally and going out of the local server.
FORWARD chain – Packet for another NIC on the local server. For packets routed through the local server.

Q :- What is NAT table ?
Ans :- Iptables NAT table has the following built-in chains.
PREROUTING chain – Alters packets before routing. i.e Packet translation happens immediately after the packet comes to the system (and before routing). This helps to translate the destination ip address of the packets to something that matches the routing on the local server. This is used for DNAT (destination NAT).
POSTROUTING chain – Alters packets after routing. i.e Packet translation happens when the packets are leaving the system. This helps to translate the source ip address of the packets to something that might match the routing on the destination server. This is used for SNAT (source NAT).
OUTPUT chain – NAT for locally generated packets on the firewall.

Q :- What is Mangle table ?
Ans :- Iptables Mangle table is for specialized packet alteration. This alters QOS bits in the TCP header. Mangle table has the following built-in chains.
PREROUTING chain
OUTPUT chain
FORWARD chain
INPUT chain
POSTROUTING chain

Q :- What is Raw table ?
Ans :- Iptables Raw table is for configuration exemptions. Raw table has the following built-in chains.
PREROUTING chain
OUTPUT chain

Q :- What is IPTABLES RULES ?
Ans :-  Following are the key points to remember for the iptables rules.
Rules contain a criteria and a target.
If the criteria is matched, it goes to the rules specified in the target (or) executes the special values mentioned in the target.
If the criteria is not matched, it moves on to the next rule.
Target Values



Following are the possible special values that you 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 user space.
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.

Q :- What is the difference between service and process?
Ans :-  A process is any piece of software that is running on a computer.
For Example:- your anti-virus software runs in the background as a process, which was automatically started when the computer booted. Some processes start when your computer boots, others are started manually when needed.

Some processes are services that publish methods to access them, so other programs can call them as needed. Printing services would be an example of a service type of process, where your email program can just call the print services process to say it wants to print, and the service does the actual work.

Q :- What is Command to check if SELinux is enabled or not?
Ans :- sestatus

Q :- What are the basic elements of firewall ?
Ans :-
A firewall should be able to filter packets (drop/pass them) based on certain rules specified by the user. The rules may be used to identify an incoming packet to the computer or outgoing packet from the computer, it can be based on target port number/ip add , traffic from a particular Network card etc…

The firewall rules can be in a tabular form (saved on the disk) from where the firewall software can read them and implement it.

Iptables firewall on Linux is a great example

Q :- What are the Linux-based security tools?
Ans :-
Selinux
Firewall
iptables
Tcp-wrappers

Q :- What are the Different services is used for different protocols
Ans :-  iptables applies to IPv4.
ip6tables applies to IPv6.
arptables applies to ARP.
ebtables applies to Ethernet frames..

Q :- How many Tables are there at present.
Ans :- Filter,  NAT & Mangle

Q :- Name the Main Files in IPTables ?
Ans :-
/etc/init.d/iptables – (init script to start | stop | restart and save rulesets).
/etc/sysconfig/iptables – (where Rulesets are saved).
/sbin/iptables – (binary).

Q :- At present, How many chains are there ?
Ans :- INPUT : Default chain originating to system.
OUTPUT : Default chain generating from system.
FORWARD : Default chain packets are send through another interface.
RH-Firewall-1-INPUT : The user-defined custom chain.

Q :- To start IPTables on system boot ?
Ans :- # chkconfig --level 345 iptables on
# service iptables save
# iptables -L -n -v (Options “-L” (List ruleset), “-v” (Verbose) and “-n” (Displays in numeric format)).

Q :- How to view crond status? If it’s show service is not found ?
Ans :- Service crond restart

Q :- How to see unallocated hard disk space on linux ?
Ans :- df -h

Q :- How do u find remote machine operating system and version?
Ans :- nmap -A –v 192.168.1.100

Q :- How do you port scanning with netstat command ?
Ans :- netstat –an

Q :- Linux system monitoring Tools ?
Ans :-  top – Process Activity Command
vmstat – System Activity, Hardware and System Information
w – Find out Who Is Logged on And What They Are Doing
Uptime – Tell How Long the System Has Been Running
ps – Displays the Processes


free – Memory Usage
iostat – Average CPU Load, Disk Activity
sar – Collect and Report System Activity
mpstat – Multiprocessor Usage
pmap – Process Memory Usage

Q :- How do find all failed login attempts via ssh?
Ans :- tail -f /var/log/secure | grep Failed

Q :- How to check iptables rpm ?
Ans :- # rpm -qa iptables

Q :- How to disable IPTABLES ?
Ans :-
# service iptables save
# service iptables stop
# chkconfig iptables off

Q :-  How to list all tables in iptables ?
Ans :- # cat /proc/net/ip_tables_names

Q :- Linux Network monitoring Tools ?
Ans :- netstat and ss – Network Statistics
iptraf – Real-time Network Statistics
tcpdump – Detailed Network Traffic Analysis
strace – System Calls

/Proc file system – Various Kernel Statistics
# cat /proc/cpuinfo
# cat /proc/meminfo
# cat /proc/zoneinfo
# cat /proc/mounts

Nagios – Server And Network Monitoring
Cacti – Web-based Monitoring Tool
Gnome System Monitor – Real-time Systems Reporting and Graphing

Q :- To clear IP rules 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

Q :- How to Enable IPTABLES ?
Ans :- # /etc/init.d/iptables start
# chkconfig iptables on
# iptables-save > /root/working.fw

Q :- How to check iptables service ?
Ans :-
# /etc/init.d/iptables stop
# /etc/init.d/iptables start
# /etc/init.d/iptables restart

Q :-  How to restore Rules ?
Ans :-
#iptables-restore < /root/firewall.rules
#iptables-save > /root/firewall.rules

Q :- How to restore iptables ?
Ans :-  # cp /etc/sysconfig/iptables  /etc/sysconfig/iptables.backup (coyping & taking backup)
# iptables-restore -c  /etc/sysconfig/iptables (restoring iptables)



Q :-  How to View the List of iptable Rules ?
Ans :-
# iptables --list
#iptables -L

Q :- How to clear tables in iptables
Ans :- # iptables -L

Q :- How to Delete iptable Rules ?
Ans :-
# iptables --flush
# iptables --flush OUTPUT  //To delete particular CHAIN

Q :- How to review current Rules ?
Ans :- #iptables -L or iptable -L -t filter

Q :- How to add a rule in iptables chain ?
Ans :-
# iptables -A INPUT -s 192.168.1.11 -p icmp  --icmp-type echo-request -j DROP
# iptables -A INPUT -s 192.168.1.12 -p icmp  --icmp-type echo-request -j REJECT
Target – Special target value
prot – Protocols. for example tcp, udp, icmp, etc.,
opt – Special options for that specific rule.
source – Source ip-address of the packet
destination – Destination ip-address for the packet

Q :- What is a command to display top 10 users who are using huge space?
Ans :- du -sh /home/* | sort -r | head -10

Q :- How to add a rules in specific location of iptables rules ?
Ans :-
# iptables -L INPUT
# iptables -I INPUT 1 -s 192.168.1.41 -p tcp --dport 80 -j REJECT
# iptables -L INPUT

Q :- How to delete a rule from list ?
Ans :-
# iptables -L INPUT
# iptables -D INPUT 2
# iptables -L INPUT

Q :- How do u extract files from iso cd images in linux ?
Ans :-
# mount –o loop disk1.iso /mnt/iso

Q :- How do you configure Linux system as a router ?
Ans :-
vim /etc/sysctl.conf
net.ipv4.ip_forward=1
system-config-network
eth0 192.168.1.120 eth0:1 172.24.0.1
255.255.255.0 255.255.0.0
172.24.0.1 192.168.1.120

That's it
----------------------------------------------------------------------------------------------------------------------
Providing on the Web, online library and learning platform for IT Professional Developers with a unique blend of original content, peer-to-peer advice from the largest community of IT.

For The Latest Technology & Topics...

Redhat Linux | Linux Howtos | Ubuntu | Linux News | Centos | Linux Mint | Fedora | Linux Commands | Interview Question & Answers | Lintu Tricks | Linux Commands | Debian | Cinnamon | Apache | MySQL | Databases | Oracle-db | Java | SQL | pgAdmin | DevOps | Scripting | Python | Jenkins | Amazon AWS | Programming | Videos for Developers | Security & Hacking | VMware | Desktop | Laptops | Servers | Networking | Cloud | Installation | Operating System | MS Office | Switches | Routers | Firewall | Open Source | Outlook,Thunderbird, Gmail Emails | Monitoring Tools | JavaScript | YouTube | Android | Smartphone | Facebook | WhatsApp | Snapchat | Instagram | WordPress | Virtualbox | Browsers | Software | Hardware | Internet | Maintenance & Optimization | Antivirus | News | Google Play Store Apps | Prices | SEO | PC Games | Mobile Games | iPhone | Microsoft Windows 7 | Windows 10 | Windows Server 2012/2016/2019 | Windows Tips & Tricks | Tutorials | Training | Troubleshooting | Guides | Tips and Tricks | Reviews | Technology | IT Support | IT News | Advice for Technology | Features | Cloud | Cloud Computing | Privacy & Security| Banks

Follow Cloud Network on Twitter, Facebook and Subscribe to our YouTube channel.