- From the Load balancer the request will go to private subnet, their WE CAN ADD SECURITY FOR PRIVATE SUBNET LAYER which is called NACL.
- If we don't add the security over there then it we have add the security
- EC2 instance level is called Security Group
- IN AWS SECURITY IS ALWAYS A SHARED RESPONSIBILITY that means AWS says we will give security by VPC, Security Group, NACL, API along with that we need help of devops or aws admins or systems enginner or network to be more secured.
- NACL is called last point of security in AWS.
- Before request reaching application we have NACL OR SG
- It serves at the instance level
- Bydefault aws gives the instance with vpc
- In Security groups we have 2 things inbound traffic and outbound traffic
- We user is trying to send request to the app'n present in EC2 then it is called INBOUND Traffic
- The application responses to the user is called OUTBOUND traffic.
- Ex: Amazon website, User trying to access amazon website and amazon website is tryping to access payment gateway like amazon pay or razorpay. User --> Amazon site is inbound Amazon webiste --> Amazonpay is outbound.
- We have to manage inbound and outbound security for the ec2 instance.
- AWS bydefault created security group for the instance and allows ALL THE PORT, Expect port 25
- AWS bydefault deny inbound traffic
- AWS does not allow outbound traffic for the PORT 25, Because it is mailing service
- AWS by default allow port 25, because of any spaming activites etc
- Security group is applied for EC2 instance level, where applied at the subnet level
- Ex: Devlopment team used EC2 instance with Jenkins server and for easy use they have allowed all the port instead of 8080
- If devops engineers DENY TRAFFIC using NACL in the subnet level, even EC2 level is allowed then also appn will not get any traffic
- If something is applied to subnet level bydefault it will be applied to all the instances with in the subnet
- NACL will add additonal layer of security
- We can also use NACL for automation
- Ex: If we have 10000 of EC2 instead of adding Security group, add NACL for the subnet then will be followed to all the EC2 instance present it is easy then using security groups.
- NACL == Deny traffic + Allow Traffic
- In security group we have only allow option
- ... lines represents virtual private cloud
- We have create virtual private cloud and provide IP ADDRESS RANGE, AWS bydefault will create Internet gateway, NACL, Route table
- additonal we will create EC2 instance and attach a security group for this EC2 instance
- VPC --> Select VPC and More (To get AWS secuirty as well like igw and others)
- Select ip range , 16,24,32 byefautl it is 16
- Select availability zones and endpoint as required
- Instance name --> key
- Edit network settings --> Select vpc that we have created
- subnet should be private that is industry pratice
- assign ip -- enable
- firewall -- use create group or exising group if you have alredy have it
NOTE:
- IN VPC --> Network ACLs --> Inbound rules --> priority matters
- Now from NACL all the traffic is allowed. So internet gateway forwards all the traffic to the route table to load balancer if we have load balancer
- Now router table will forward the traffic to the EC2 instance
- NACL is allowed now, But security group is blocking now.
- We can block specific ip address with 16,32,14 as well