[SOLVED] WEB375 LAB 7 CONFIGURE IPTABLES IN LINUX: The purpose of this iLab is to configure an iptables firewall in Linux. Use the IP addresses that exist when you start Linux.
Virtual Machine Login Information for PLABFED01 and PLABFED02
Username: Student
Password: Password
Username: root
Password: Password
Lab Diagram
During your session, you will have access to the following lab configuration.
WINCONSOLE PLABFED01 PLABFED02
The Linux servers also connect to a private network. The IP address of PLABFED01 is 192.168.240.11 and. The IP address of PLABFED01 is 192.168.240.12.
[SOLVED] WEB375 LAB 7 CONFIGURE IPTABLES IN LINUX: Connecting to your iLab
In this module, you will be working on the following equipment to carry out the steps defined in each exercise.
Each exercise will detail which console you are required to work on to carry out the steps.
To start simply click on the named Server from the device list (located on the left hand side of the screen) and click the “Power on” button from the Tools bar. In some cases, the devices may power on automatically.
During the boot-up process, an activity indicator will be displayed in the Name tab.
If the remote console is not displayed automatically in the main window (or pop-up), click the Connect icon located in the Tools bar to start your session.
If the remote console does not appear, please try the following option.
In the event this does not resolve your connectivity problems, please visit our Help and Support pages for additional resolution options.
iptables Firewall Configuration Step by Step
General information
[SOLVED] WEB375 LAB 7 CONFIGURE IPTABLES IN LINUX: This Linux-based firewall is controlled by two programs.
IPTables main files are as follows.
At present, there are four total chains.
Packet-Matching Rules
Target Meanings
[SOLVED] WEB375 LAB 7 CONFIGURE IPTABLES IN LINUX: TASK A: Configure iptables Firewall
We are going to configure the iptables. Log in to the PLABFED01 as root and type the following commands.
Note: The # symbol before each command is the prompt of the root account. Do not type it.
Step 1: To use the iptables service, disable firewalld by typing the following commands.
#systemctl disable firewalld
#systemctl stop firewalld
Step 2: Make sure to install iptables by typing the following commands.
#yum -y install iptables-services
#rpm –q iptables
[SOLVED] WEB375 LAB 7 CONFIGURE IPTABLES IN LINUX: Step 3: To install the system-config-firewall tool, type the following commands.
#yum -y install system-config-firewall
Step 4: To execute the system-config-firewall tool, type the following command.
#system-config-firewall
A Firewall Configuration window will pop up.
To make sure that the rules set was set up, type the following command.
#ls /etc/sysconfig/iptables
If it says, “No such file or directory,” you have to execute the system-config-firewall tool in Step 4 again.
The file /etc/sysconfig/iptables is the default rule set.
[SOLVED] WEB375 LAB 7 CONFIGURE IPTABLES IN LINUX: Step 5: To turn on the firewall, type the following commands.
#systemctl start iptables
#systemctl enable iptables
Step 6: To check the status of the firewall, type the following command.
#systemctl status iptables
Note:The below commands are for reference.
[SOLVED] WEB375 LAB 7 CONFIGURE IPTABLES IN LINUX: TASK B: Practice Manipulating iptables
We are still logged in to the PLABFED01 as root, so type the following commands and observe the outputs.
Step 1: To display default rules with line numbers type the following command.
#iptables –line-numbers -n -L
Note: You can use line numbers to delete or insert new rules into the firewall.
Step 2: To display the status of the firewall, type the following command.
#iptables -L -n -v
Where -L: List rules
-v: Display detailed information
-n: Display IP address and port in numeric format
[SOLVED] WEB375 LAB 7 CONFIGURE IPTABLES IN LINUX: Step 3: To display INPUT or OUTPUT chain rules, type the following commands.
#iptables -L INPUT -n -v
#iptables -L OUTPUT -n -v –line-numbers
Step 4: You can use the iptables command itself to stop the firewall and delete all rules.
#iptables -F
#iptables -X
Where: -F: Deleting (flushing) all the rules
-X: Delete chain
Step 5: To delete a rule on line 4 and verify it, type the following commands.
#iptables –line-numbers -n -L
#iptables -D INPUT 4
#iptables –line-numbers -n -L
Step 6: To insert rule between 1 and 2, type the following commands.
#iptables -I INPUT 2 -s 202.54.1.2 -j DROP
#iptables –line-numbers -n -L
Step 7: To block an attacker’s IP address called 1.2.3.4, type the following commands.
#iptables -A INPUT -s 1.2.3.4 -j DROP
#iptables –line-numbers -n -L
[SOLVED] WEB375 LAB 7 CONFIGURE IPTABLES IN LINUX: Step 8: You can use the iptables command itself to stop the firewall and delete all the rules.
#iptables -F
Where -F: Deleting (flushing) all the rules
#iptables –line-numbers -n -L
Step 9: To stop the firewall, type the following command.
#systemctl stop iptables
Step 10: To restore firewall rules from the file /etc/sysconfig/iptables, type:
#systemctl restart iptables
Step 11: To save firewall rules in /etc/sysconfig/iptables, type the following command.
#iptables-save
Note 1): In this case, we did not add more rules because with the restart of iptables, the content of the file /etc/sysconfig/iptables does not change.
Note 2): If the file /etc/sysconfig/iptables is corrupted, just redo the TASK A Step 4, which will generate a new default rule file.
Note 3): To see more details on iptables’ options, type “man iptables.”
[SOLVED] WEB375 LAB 7 CONFIGURE IPTABLES IN LINUX: TASK C: Experiment Rules
These lab scenarios are focusing on using iptables to improve the security of PLABFED01 Linux server. We use the PLABFED02 Linux server for testing. This part of the lab will require you to switch back and forth between two Linux systems. So log in to each system, open a terminal window, and switch user to root. From there, you can use the mouse to select a system. See the example below.
Step 1: On PLABFED01: To restore the default firewall rules (restart), type the following command.
#systemctl restart iptables
The below is the listing of the default iptables rule set.
Step 2: On PLABFED01: Look at the INPUT chain; the rule on line 4 accepts the telnet connections.
Step 3: On PLABFED02: Check whether telnet connections to PLABFED01 are possible.
Step 4: On PLABFED01: We want to set up the iptables to reject telnet connections.
Step 5: On PLABFED02: Check whether telnet connections to PLABFED01 are still possible.
This concludes iLab 7.