Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set egress > ipBlock for multiple IPs and ports?

Here is a section of my network policy:

egress:
   -to:
     - ipBlock: 
         cidr: 10.0.0.0/32
     - ipBlock:
         cidr: 10.0.0.1/32
    ports:
     - protocol: TCP
       port: 5978

I have a doubt whether these IPs will be allowed to connect to the same port.

Basically, if we want to have a different port for a different IP, what can we do?

like image 274
Anonymous Avatar asked Oct 21 '25 17:10

Anonymous


1 Answers

I assume the snippet you shared is a portion of a NetworkPolicy.

If so, you can have multiple entries in the egress field, like this for example:

egress:
  - to:
    - ipBlock: 
        cidr: 10.0.0.1/32
    ports:
    - protocol: TCP
      port: 5978
  - to:
    - ipBlock: 
        cidr: 10.0.0.2/32
    ports:
    - protocol: TCP
      port: 1234
like image 88
whites11 Avatar answered Oct 23 '25 08:10

whites11



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!