Use iptables in CentOS to restrict access from specific IP addresses only

Source: Internet
Author: User

We often need to impose some security restrictions when configuring the linux server, such as only allowing specific IP address segments to access the specified port. For example, I have a server with dual-IP addresses that can be accessed from both internal and external networks, but some applications do not allow access from external users. Therefore, some special restrictions must be imposed on the port, for example, to allow only users in the 192.168.1.x CIDR block to access port 389 of the server, we can add the following settings in the server's iptables:

 
 
  1. -A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp-s 192.168.1.0/24 -- dport389-j ACCEPT

Use-s to specify the source address. Here, only machines in the 192.168.1.x network segment can access the specified port 389 (specified through-dport), and then restart the firewall.

 
 
  1. Service iptables restart

Then, we can smoothly access port 389 through the Intranet, and machines in the external network or outside the network segment will not be able to access the port, thus achieving the desired effect, security restrictions are imposed.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.