Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Linux iptables firewall settings     - How linux network security configuration (Linux)

- JavaScript Advanced Programming notes event capture and event bubbling (Programming)

- Linux CPU Monitoring Index (Linux)

- Oracle 11g upgrade PSU detailed steps (Database)

- Security Knowledge: redirection command application security (Linux)

- Vim useful plugin: EasyGrep (Linux)

- Spring declarative transaction management (Programming)

- CentOS and RHEL to install IPython 0.11 (Linux)

- Android Notification (Programming)

- Oracle Linux 6.4 installed Oracle 11gR2 + RAC + ASM (Database)

- Six Ways to view slides can be implemented Android (Programming)

- Lenovo E431 notebook CentOS system is installed wireless network card driver (Linux)

- Ubuntu use three methods to install Ruby (Linux)

- How to fix Not Enough Free Disk Space On / boot on Ubuntu (Linux)

- Usage of sudo (Linux)

- Win7 used Eclipse to connect the virtual machine in Ubuntu Hadoop2.4 (Server)

- CoreOS quick installation to get started on a PC (Linux)

- Usage logs Python library (Programming)

- C ++ handling text input (Programming)

- Android custom ViewPager create kaleidoscopic image transition effects (Programming)

 
         
  Linux iptables firewall settings
     
  Add Date : 2018-11-21      
         
         
         
  By operating in this tutorial, make sure you can use Linux native. If you are using a remote ssh, but can not directly operate the machine, then first add the following code. Of course, the worst result is that all the ports are not visit, not even landing ssh, but five minutes later, the timer will help you turn off iptables firewall.

[Root @ localhost ~] # crontab -uroot -e
 
* / 5 * * * * /etc/init.d/iptables stop ## timed 5 minutes off the firewall settings to prevent the error, leading to not be able to ssh login

First, speak few simple commands:

/etc/init.d/iptables save ## save the firewall rules, then if you do not save, then restart iptables rule will disappear
 
iptables -L -n ## view the current firewall rules

PS: Before adding a rule to use iptables -L -n look at the current rules, if the display does not rule, may be your iptables is not turned on. If after this time will cover add rules before saving rules. If you want to continue using the previous rules, first turn iptables service, this time you can see the previous rule, and then add in the previous basis.

Let's add two rules

iptables -A INPUT -p tcp --dport 22 -j ACCEPT ## add a rule input stream port 22 open
 
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT ## add a rule output stream port 22 open
 

After adding the above two rules, do not worry about not landing SSH, and want to learn more about using the command iptables --help

Focus here to talk about the difference between iptables inside dport and sport of:

dport: Destination port

sport: Source port

By way of example two INPUT, we distinguish at INPUT and sport inside dport

Example 1:

iptables -A INPUT -p tcp --dport 22 -j ACCEPT
 

This rule can be so described INPUT:

        1. This is an internal data into the local server from the outside.

        2. The purpose of the data packet (dport) address is 22, is to visit my local port 22.

        3. Allow the above data through behavior.

Example 2:

1
 
iptables -A INPUT -p tcp --sport 22 -j ACCEPT
 

This rule can be so described INPUT:

        1. This is an internal data into the local server from the outside.

        2. Source port packet is the (sport) 22, is the other side of the packet is sent over port 22.

        3. To allow more data behavior.

By way of example two OUTPUT, we distinguish under OUTPUT inside dport and sport

Example 1:

iptables -A OUTPUT -p tcp --dport 22 -j ACCEPT
 

This rule can be so described OUTPUT:

        1. This is a line from the inside out data.

        2. Objective out (dport) port is 22.

        3. To allow more data behavior.

Example 2:

iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT

This rule can be so described OUTPUT:

        1. This is a line from the inside out data.

        2. Source port packet is the (sport) 22, data is sent from the port 22 of the server.

        3. To allow more data behavior.

The default INPUT, OUTPUT, FORWARD ACCEPT all of

Do not add rule, the data for all ports comers ~

iptables -P INPUT DROP # If you do not accept the rules add port 22, do not run this command

If you run the above command, then the rule is added in addition to the INPUT DROP packets are dropped. . .

Similarly, there are these commands:

iptables -P OUTPUT DROP
iptables -P FORWARD DROP

Usually the INPUT is set to DROP. So we need to add some rules for the ACCEPT INPUT rules:

iptables -A INPUT -p tcp --dport 22 -j ACCEPT # ssh port open
iptables -A INPUT -p tcp --dport 80 -j ACCEPT # web service port open
iptables -A INPUT -p tcp --dport 21 -j ACCEPT # ftp service port open
 
iptables -A INPUT -p icmp -j ACCEPT # Allow icmp packet to pass, that is, to allow ping
iptables -A INPUT -i lo -p all -j ACCEPT # Allow loopback
 
##### If you have made other servers, which need to open ports, according to the writing on the line.

 Usually the OUTPUT is set to ACCEPT. So we need to add some rules for the OUTPUT DROP rules:

Close some ports
iptables -A OUTPUT -p tcp --sport 27444 -j DROP
iptables -A OUTPUT -p tcp --sport 27665 -j DROP
iptables -A OUTPUT -p tcp --sport 31337 -j DROP
     
         
         
         
  More:      
 
- How to deploy Icinga server (Server)
- Analysis of memory mapping process in Linux x86-64 mode (Linux)
- Linux processes in memory and memory cgroup statistics (Linux)
- Ceph cluster disk is no workaround for the remaining space (Server)
- Linux / CentOS 7.0 installation and configuration under Tomcat 8.0 (Server)
- CentOS 5.5 kernel upgrade installation iftop (Linux)
- MNIST presentation and database conversion (Database)
- Dom4j change XML coding (Programming)
- XtraBackup achieve non-stop use of master-slave synchronization service (Database)
- How to view information about the installed version of CentOS (Linux)
- Shell Scripting Interview Questions (Programming)
- CentOS6 installation configuration rsh (Server)
- Laravel configuration PhpStorm + Xdebug + Chrome settings Debug Environment (Server)
- Repair Maven project developed default Maven Plugin folder (Linux)
- Ubuntu 14.04 LTS NTFS partition can not access solution (Linux)
- VMware virtual machine to install CentOS 6.2 (Linux)
- Source MongoDB 3.2.1 installed on CentOS6.5 (Database)
- Linux non-root user uses less than 1024 ports (Linux)
- Java implementation of stacks and queues (Programming)
- About Samba certification process and permissions (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.