Welcome to the Linux Foundation Forum!

Question on network policy for lab 6.1



In the last part of lab 6.1 we create a networkpolicy to only allow Ingress from Cidr on port TCP 80.

This is confirmed working because from the second node (IP, I can no longer curl the node's internal IP (, nor the external IP from the master node from my laptop. And it still works to curl the pod's IP on port 80 from the second and master node.

However what I don't understand is that I can still curl the master node's internal IP when I'm on the master node itself ( This does not work like I said from the second node. If I remove the network policy it again also works from the second node.

Also in the logs of the webserver container of the pod, I can see incoming connection from I don't understand how this is possible since CIDR ingress is limited to I first thought the master node would use another NIC because it also has IP from the tunl0 interface, but then my logs still show successful connection from If this was true, my second node, with tunl0 interface having ip should also be able to get in.

What am I missing here? This is my 'allclosed.yaml':

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
 name: deny-default
 podSelector: {}
 - Ingress
 - from:
   - ipBlock:
   - port: 80
     protocol: TCP
# - Egress


  • serewicz
    serewicz Posts: 1,000


    It seems like with the NetworkPolicy in place you can still connect locally, but not from a remote system. Without tracing the traffic in detail this would indicate that the local connection is not being ingested in the same manner and thus bypassing the policy, in a similar manner that using the loopback interface does not actually use a full NIC, and remains in the node itself.

    If you have two windows up are you seeing the incoming connection at the same time as you curl from an exterior instance? I'm wondering if you are seeing previous attempts, not ones where the policy was in place. I would agree that with the policy in place there should be no request to the container. If you indeed see traffic immediately , and the policy is in place please let me know and I will try to investigate further.


  • nbuekers


    thanks for getting back. I have 2 connections to my node1, one doing a $watch on the logs, and the other doing the curl. When I do the new curl, I do see the new log in the other window. Is this what you are referring to?

  • serewicz
    serewicz Posts: 1,000


    Yes. You should see traffic in the log window. This can be useful for troubleshooting issues and to see activity as the requests come in.



Upcoming Training