iptables basics 08-03-2019, 12:58 PM
#1
IPTABLES BASICS
Iptables is a basic component of linux, mainly used in firewall applications, such as prohibiting an IP access, or prohibiting some ports to improve the security of the website.
In general, the system will be installed by default. If it is not installed, you can install it yourself.
INSTALLING
centos:
debian
USAGE
view if iptables running
clear all current rules
save the current rule ( note that there is no space between -s )
list showing current rules
cut out a single ip address
see the entire segment ( class a address ) from 192.0.0.1 to 192.255.255.254, then add the following rules:
the ip segment ( type b address ) is from 192.168.0.1 to 192.168.255.254, then add the following rules.
the ip segment ( c class address ) from 192.168.200.1 to 192.168.200.254, then add the following rules.
show current rules by row list
delete the 15th rule
Iptables is a basic component of linux, mainly used in firewall applications, such as prohibiting an IP access, or prohibiting some ports to improve the security of the website.
In general, the system will be installed by default. If it is not installed, you can install it yourself.
INSTALLING
centos:
Code:
$ yum install iptablesdebian
Code:
$ apt install iptablesUSAGE
view if iptables running
Code:
$ service iptables -statusclear all current rules
Code:
$ iptables -Fsave the current rule ( note that there is no space between -s )
Code:
$ iptables-savelist showing current rules
Code:
$ iptables -L -ncut out a single ip address
Code:
$ iptables -A INPUT -s 123.45.67.89 -j DROPsee the entire segment ( class a address ) from 192.0.0.1 to 192.255.255.254, then add the following rules:
Code:
$ iptables -I INPUT -s 192.0.0.0/8 -j DROPthe ip segment ( type b address ) is from 192.168.0.1 to 192.168.255.254, then add the following rules.
Code:
$ iptables -I INPUT -s 192.168.0.0/16 -j DROPthe ip segment ( c class address ) from 192.168.200.1 to 192.168.200.254, then add the following rules.
Code:
$ iptables -I INPUT -s 192.168.200.0/24 -j DROPshow current rules by row list
Code:
$ iptables -L -n --line-numbersdelete the 15th rule
Code:
$ iptables -D INPUT 15
![[+]](https://sinister.li/images/modern/collapse_collapsed.png)


