iptables is a commonly used firewall software on Linux. The following vps detectives tell you about iptables installation, clear iptables rules, iptables only open specified ports, iptables shield specified ip, ip segments and unblock, delete added iptables rules The basic application of iptables. 1, install iptables firewall
If you do not install iptables need to be installed first, CentOS implementation: yum install iptables
Debian/Ubuntu implementation: apt-get install iptables 2, clear existing iptables rules iptables - F iptables -X iptables -Z 3. Open the specified port #Allow the local loopback interface (that is, run the machine to access the machine) iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT # Allow established or Related iptables -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT #Allow all native access to iptables -A OUTPUT -j ACCEPT # Allow access to port 22 iptables -A INPUT -p tcp – Dport 22 -j ACCEPT #Allow access to port 80 iptables -A INPUT -p tcp –dport 80 -j ACCEPT #Allow FTP ports 21 and 20 iptables -A INPUT -p tcp –dport 21 -j ACCEPT iptables -A INPUT -p tcp –dport 20 -j ACCEPT #If there are other ports, the rules are similar. Modify the above statement slightly. #Prohibit other unallowed rules from accessing iptables -A INPUT -j REJECT iptables -A FORWARD -j REJECT 4, shield IP # If you just want to block the IP, then "3, open the specified port" can be skipped directly. #Screening a single IP command is iptables -I INPUT -s 123.45.6.7 -j DROP #封The entire segment is from 123.0.0.1 to 123.255.255.254 command iptables -I INPUT -s 123.0.0.0/8 -j DROP #封The IP segment is the command from 123.45.0.1 to 123.45.255.254 iptables -I INPUT -s 124.45.0.0/16 -j DROP #封IP segment is the command from 123.45.6.1 to 123.45.6.254 is iptables -I INPUT -s 123.45 .6.0/24 -j DROP 4. View the added iptables rules iptables -L -n
v: Display details, including the number of matching packets and the number of matching bytes per rule x: in v On the basis of this, automatic unit conversion (K, M) is prohibited. vps Detective n: only shows the IP address and port number, does not resolve ip to domain name 5, deletes the added iptables rule
marks all iptables by serial number Display, execute: iptables -L -n –line-numbers
For example, to delete the rule with sequence number 8 in INPUT, execute: iptables -D INPUT 8 6. Startup and rule saving of iptables
CentOS may exist after installing iptables, iptables does not boot from boot, you can execute: chkconfig & Ndash;level 345 iptables on
Add it to the boot.
CentOS can be executed: service iptables save save rules.
In addition, it is more important to note that iptables on Debian/Ubuntu does not save rules.
You need to follow the steps below, let the NIC close is to save the iptables rules, load iptables rules at startup:
Create /etc/network/if-post-down.d/iptables file, add The following content: #!/bin/bash iptables-save > /etc/iptables.rules
Execute: chmod +x /etc/network/if-post-down.d/iptables Add execute permission.
Create the /etc/network/if-pre-up.d/iptables file and add the following: #!/bin/bash iptables-restore < /etc/iptables.rules
Execute: chmod +x /etc/network/if-pre-up.d/iptables Add execute permission.
More iptables can be used to execute: iptables –help or online search for iptables parameters.
Devil-Linux is a special Linux distribution for firewalls and routers. The goal of Devil-Linux is to
Use httpry to sniff HTTP traffic under Linux Tutorial Sometimes you want to sniff HTTP traffic for
Everyone knows that shell script is like a batch file (.bat) in the early DOS era. The simplest fun
Just as Hong Kong is still engaged in tug-of-war on the issue of electronic textbooks for bookseller
The device is currently in use
Talking about the media player under Linux (on)
Linux kernel service routines and system call interface
The method of teaching you whether to judge whether the Linux system is hacked is
Detailed Linux operating system using Windows partition
FTP user and apache user permissions under LINUX
The configuration of the news reader under Linux
Deploy SSH application on Linux operating system
How to build l2tpd vpn server with centOS5.5
Correcting misunderstandings and misconceptions about Linux by Chinese people
Make Windows XP operating system more secure multiple methods
Experience sharing of 7-layer soft load under Windows (4)
How does Win8 change the online status of the message application?
CentOS6.4 yum command to install php5.2.17
Microsoft released Windows 8.1 Developer's Guide
Win8.1 Update 0x80070002 and 0x80070003 error solution
Windows XP Easily implement OS backup and restore
Input method can not be switched? Input method recovery method summary