advanced25 min studyLesson 217 in Engineering

Segmentation controls permitted connections at a boundary

Evaluate directional network policy, additive allow rules, enforcement prerequisites, and the separation between transport reachability and application authorization.

On this page

What you’ll understand

  • Compute a new connection's policy result from source egress and destination ingress.
  • Explain additive allow policy and selector scope in Kubernetes NetworkPolicy.
  • Test enforcement and necessary dependencies without equating segmentation with user authorization.

Segmentation reduces which workloads can initiate selected network connections. It can limit reachable attack surface, but its exact boundary depends on the enforcement system, selectors, directions, and protocols. A policy object that no component enforces is documentation rather than an active control. A permitted encrypted connection is also not permission for every application action. Build a small connection matrix, state the intended denials, and test the actual data path before claiming that a network has been isolated.

Direction and enforcement are part of the rule

Consider Kubernetes NetworkPolicy as one concrete policy model, assuming a network implementation that supports and enforces it. A selected pod can be isolated for ingress, egress, or both according to applicable policy. For a new pod-to-pod connection, the source's egress policy and the destination's ingress policy must both permit it when those directions are isolated. Permitting only the destination's ingress does not override a source egress restriction. Routing, listening services, and other controls must still make the allowed connection possible.

Standard NetworkPolicy allow rules combine additively within a direction. A broad allow in one applicable policy is not canceled by placing a narrower allow elsewhere. A default-deny style policy establishes isolation with no allowed peers for its selected direction; subsequent policies can add permissions. Understand selector composition as well: namespace and pod selectors within one peer can constrain the same peer together, while separate peer list items express alternatives. Test the resulting selected population, not just the visual appearance of a manifest.

Ps→d=Es(d,π)∧Id(s,π)P_{s\to d}=E_s(d,\pi)\land I_d(s,\pi)
For the stated enforced pod policy model, E_s and I_d are the effective directional allow predicates for a new connection with protocol/port tuple π. Non-isolated directions are represented as allowing. This policy result alone does not guarantee routing, service health, TLS identity, or application authorization.↔ Scroll wide equations horizontally.

Reachability permission is not identity or data permission

A layer-three/four rule can permit a source population to reach a destination port without understanding which user requested an object or what the encrypted request means. Mutual TLS can authenticate a workload on that connection, while application policy decides its actions and resource scope. These controls complement one another, but their evidence is not interchangeable. Demonstrating that an unrelated pod cannot connect to a database does not prove that an allowed frontend enforces tenant authorization correctly.

Necessary dependencies complicate minimal policies. Name resolution, telemetry, control-plane access, and certificate renewal may need scoped connectivity. Allowing an entire namespace or unrestricted egress merely to restore DNS can defeat the intended reduction. Conversely, blocking renewal can create an outage days after a seemingly successful segmentation change. Inventory the dependencies and test their actual addresses, ports, and identity boundaries. Established-connection behavior after a rule change can depend on the implementation, so explicitly test fresh connections rather than assuming immediate termination of all prior state.

F=n(n−1)F=n(n-1)
F counts directed workload-to-workload pairs among n distinct workloads when self-pairs are excluded. It is a review-space count before adding ports, protocols, identities, or resources, not a numerical measure of security or actual reachable attack paths.↔ Scroll wide equations horizontally.

Prove denials and preserve intended service paths

Run paired tests from allowed and denied sources to the same destination and port. A timeout alone may reflect a missing listener or broken route rather than policy enforcement, so keep a positive control and inspect the enforcement system's available evidence. Then test that a label change or newly created workload does not escape the intended selection scope. Policy behavior must be assessed at the real interfaces and supported protocols; do not extrapolate pod-traffic results to every host-network or infrastructure path without checking documented coverage.

The probability lab examines a synthetic test-selection limitation. Reset, set both p=0.1 for an independently selected forbidden case exposing a mistaken allow and n=20, predict zero detections, then Play or Step. It does not enforce policy or construct a topology. Real forbidden cases often share selectors, ports, and namespaces, so random independence can fail badly. Use the explicit connection matrix to cover each meaningful boundary, including required DNS and renewal paths, rather than accepting a small clean sample as proof of complete segmentation.

Count and evaluate scoped connection cases

Eight workloads have 56 directed non-self pairs. A review explicitly allows twelve pairs for one fixed protocol and port, denying the rest. One proposed connection has source egress allowed but destination ingress denied.

  1. Compute the review space: 8 × 7 = 56 directed pairs. With twelve granted pairs, 56 − 12 = 44 pairs are intended denials for this one protocol/port context.

  2. Apply both directional predicates to the proposed connection: true AND false is false. The source egress allow cannot override the destination ingress denial under the stated enforced policy model.

  3. Test a known allowed pair as a control and representative denials across selector groups. Additional ports or protocols enlarge the review space; the number forty-four is not a complete count of every possible application permission.

The result

The proposed fresh connection is denied by the stated directional policy. The review has forty-four specified denied pairs within its deliberately narrow transport scope.

Explore the model

Interactive lab

Interactive lab · probability

A clean sample does not cover every boundary

Reset, set both synthetic mistaken-allow detection probability p=0.1 and independent trials n=20, predict zero detections, then Play or Step. This is a coverage illustration, not a network-policy engine or topology simulator.

A clean sample does not cover every boundaryThese are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Current readings: Mean · np: 5; Variance · np(1−p): 2.5; Total probability: 1. All parameters are adjustable with the labeled controls below.03581000.070.150.220.3Successes kP(X = k)k = 0 · P = 9.77e-4
Exact probabilityHighlighted outcomeMean np
Mean · np
5
Variance · np(1−p)
2.5
Total probability
1
t = 0 s

These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forDirectional rules and enforcement need targeted positive and negative tests across the actual selected populations.

Check your understanding

Two applicable ingress policies allow different peer sets to the same isolated pod. How do ordinary Kubernetes NetworkPolicy allow rules combine?

Try it yourself

A team adds a narrow ingress policy expecting it to block a peer previously allowed by a broad ingress policy. The peer still connects. What policy-model assumption should they correct, and what positive control should accompany a fix?

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

A second allow list is not a deny override. Inspect all policies selecting the destination in the relevant direction.

Compare with the solution

They must account for the union of all applicable ingress allows: the broad policy still grants the peer access. Correct the effective policy set and selectors rather than relying on creation order or a narrower additional allow. Alongside a denied-peer test, keep an intended allowed source connecting to the same healthy destination and port. That control helps distinguish an enforced denial from a broken service, route, or unrelated firewall.

Take it with you

  • A new connection can require both source-egress and destination-ingress permission.
  • Additive allow rules and selector composition determine the effective boundary.
  • Segmentation, workload authentication, and resource authorization need separate evidence.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.