MongoDB access control and iptables management

Source: Internet
Author: User
Tags mongodb iptables

There is only access to MongoDB IP restrictions, accurately speaking, firewall port access restrictions, with MongoDB no special relationship, to use other places can also be.

#首先, all requests to access Port 27017 will be denied.

Iptables-i input-p TCP--dport 27017-j DROP

#当然, you can't get out of the way and open a back door for yourself.
Iptables-i input-s 127.0.0.1-p TCP--dport 27017-j ACCEPT (for business logic needs, sometimes the server's public network IP authorization)

Finally, in order to debug their own aspects, you may also need to grant access to other IP, the 127.0.0.1 to the IP you want to authorize the implementation of the command again.

In this way, no IP other than the authorization will be able to access the MongoDB on the server.


Iptables Maintenance:

Iptables-l input--line-numbers lists all the rules for the input chain

IPTABLES-L-n Lists all rules, usually in conjunction with grep

iptables-d chain Rulenum [options] of which: chain is the meaning of the chain, is the input FORWARD the attributive rulenum is the number of the rule. Starting from 1.  You can use the Iptables-l INPUT--line-numbers to list the number of the rules for the specified chain. So, for example, to delete the rules for an INPUT chain above, you can do this: iptables-d INPUT 3 means to delete rule 3rd.

Related Article

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.