Search code examples
mongodbamazon-web-servicesamazon-ec2aws-security-group

How should I set up my security groups so that hackers will not infiltrate so easily


So I have an EC2 instance on AWS and it runs Mongodb. I have been having issues with hackers for a few months now and I can't seem to figure out how to keep them out. Luckily, I don't have anything important on there.

I did notice that my security group on AWS is basically open to all. For example, my inbound rules:

Port 80, tcp, 0.0.0.0/0 Port 8080, tcp, 0.0.0.0/0 Port all, tcp, 0.0.0.0/0 Port 22, tcp, 0.0.0.0/0 Port 27017, tcp, 0.0.0.0/0 Port 443, tcp, 0.0.0.0/0

If i change the source is there a convention I should follow? How should I set the source? I am new to this as I did not set up my security groups. Just trying to figure out how I can keep out the hackers. They have been going at it for a while now.


Solution

  • The0.0.0.0/0 means that the port allows connection from anywhere on the internet.

    If you set the source, only the source (whether it's an IP or a range of ups) will be able to access the port.

    How are you going to set the source really depends on your needs.