Linux (redhat) server configuration, Chapter 3: Firewall configuration

I have been working on a Linux (redhat) server recently . Since I have not used a Linux system before , I recorded the ideas for solving the problems encountered in the operation steps for subsequent reference; this article is for the [linux (redhat) server configuration] series The third chapter of the article.

1. Open ports

      Open the firewall configuration file by command: vim etc/sysconfig/iptables. Then add the ports you want to open, such as:

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp --dport 4448 -s 192.168.0.254 -j ACCEPT
-A INPUT -p tcp --dport 4448 -s 192.168.1.55 -j ACCEPT
-A INPUT -p tcp --dport 4448 -j DROP
-A INPUT -m state --state NEW -m tcp -p tcp --dport 48480 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8443 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

2. Open the port to a specific IP

     The command is as follows:

-A INPUT -p tcp --dport 4448 -s 192.168.0.254 -j ACCEPT
-A INPUT -p tcp --dport 4448 -s 192.168.1.55 -j ACCEPT
-A INPUT -p tcp --dport 4448 -j DROP
The following code means that if port 4448 is developed to 192.168.0.254 and 192.168.1.55, other IPs will not be able to access port 4448.


carry out! ! ! ! !


Guess you like

Origin blog.csdn.net/nanxiaotiantian/article/details/54913592