LAB 24 ‐ Allow ICMP in Security List for Instances within Same Subnet - gautam-amitesh/OCI GitHub Wiki
I have two instances test-server-01 and bastion_server_01 in same public subnet 10.0.0.0/24 now we will test ping command with different security list settings.
Navigation
-
Create Security List
Navigation menu > Networking > Virtual cloud networks > VCN (hub-vcn) > Security -
Add Security List
Navigation menu > Networking > Virtual cloud networks > VCN (hub-vcn) > Subnets > public subnet (public subnet-hub-vcn) > Security >
Default (Stateful Egress Only)
When we create VCN and Subnet by default OCI provides a security list which helps us to login remotely via SSH but don't allow ICMP Type 8 and Type 0 due to which when we will ping it will not work.
-
First login to both instances and get the private IP of both instances which we will use for connection
hostname -i -
Now run the ping command on
bastion_server_01it successfully sent packet totest-server-01due to active egress rule for all, the packet arrives attest-server-01and its ingress rule drops the packet and the ping fails. -
Now run the ping command on
test-server-01you will see that now it works. Actually the ping didn't really worked but we have successfully exploited the firewall, due to active connection tracking when we run ping ontest-server-01it sent packet tobastion_server_01and expecting return traffic and then it receives the packet sent previously bybastion_server_01due to which we see that its working.
Enable Stateless in default Egress Rules for ICMP
When we enable stateless in default egress rules then we will see that even if we run ping in both terminal we will not see ping working.
-
To enable Stateless click on actions menu of particular egress rule and click edit then enable Stateless and click
Save changes -
Now lets test ping again first run in
bastion_server_01it fails -
Now try ping in
test-server-01which also fails because we fixed the loophole by enabling stateless
Enable Stateless Ingress & Stateless Egress Rules for ICMP
-
First lets remove all ingress and egress rules associated with ICMP to make the interface clean but don't touch the default TCP ingress rule
-
Now first add the ingress rule, Enable
Stateless, provide public subnet CIDR inSource CIDR, selectICMP, provide relevantDescription, and clickAdd Ingress Rules -
Now lets add the egress rule, Enable
Stateless, provide public subnet CIDR inDestination CIDR, selectICMP, provide relevantDescription, and clickAdd Egress Rules -
Now lets test ping again first run in
bastion_server_01it works -
Now try ping in
test-server-01which also works
Enable Stateful Ingress & Stateful Egress Rules for ICMP
-
We just need to edit both rules one by one to disable
Stateless -
Now lets test ping again first run in
bastion_server_01it works -
Now try ping in
test-server-01which also works
Stateful Ingress Only
-
We need to delete Egress rules for ICMP and as we already have Stateful Ingress for ICMP we don't need to do anything else
-
Now lets test ping again first run in
bastion_server_01it fails -
Now try ping in
test-server-01which also fails
Stateless Ingress Only
-
We need to enable Stateless in Ingress Rules for ICMP
-
Now lets test ping again first run in
bastion_server_01it fails -
Now try ping in
test-server-01which also fails