> IP Tables
Learning about IP Tables enables us to control data that flows into and out of our computer.
Essentially a firewall functions as a filter blocking restricted content and allowing trustworthy communications.
We can establish firewall rules with the help of IP Tables. This is exactly what will be covered by the following.
Viewing IP Tables
Navigate to the terminal in your Linux distribution by typing “iptables -L”. You can view the rules and regulations in place. (Note that you will require root privileges to run this)
If you see results as such, this is the default view hence there are no rules set on your computer
Chains
From the above picture, you could see 3 different chains.
- INPUT → All incoming traffic to your computer
- FORWARD → This happens in routers, mostly functional when setting up firewall policies in routers.
- OUTPUT → All outgoing traffic from your computer
Blocking Traffic
This shows that all incoming traffic is allowed as the policy is set to ACCEPT.
Suppose we need to block an IP address that is from a malicious or suspicious user.
We can do this by :
- -A → Specifies to append or add a rule to the chain
- -s → source of the device IP
- INPUT chain is selected
- DROP → All traffic from this device is blocked
- -j → Specifies what action should be taken, in this case, it is DROP traffic from the said IP address
Blocking a service
By using this code we can block anyone in the network who tries to communicate using port 25 (SMTP / email service)
We can now check how the IP tables look
Allowing traffic to a network
The following command enables us to allow traffic from this IP address
However, this person will not be able to communicate with our device, this is because the earlier command we specified blocked all traffic from the network. If we now check the IP Table using “iptables -L”.
We can see the rules applied, the first rule precedes the lower hence the list follows a chronological order in filtering networks to enable “192.168.0.66” to communicate with us we need to put it at the top to do this we use replace the -A with -I. Both these append and add rules to the table however -I add the rule to the top of the list.
Deleting a rule
If we want to delete the 3rd rule from the INPUT list we should specify as such, the -d, connotes for deletion.

Comments
Post a Comment