-
Notifications
You must be signed in to change notification settings - Fork 230
USHIFT-6801: C2CC: IPSec test #6792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pmtk
wants to merge
6
commits into
openshift:main
Choose a base branch
from
pmtk:c2cc/ipsec-test
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
61e0224
Add Robot Framework resource for IPsec test keywords
pmtk a88d985
Add C2CC IPsec E2E test suite
pmtk a5e2c92
Add C2CC IPsec 3-VM test scenario
pmtk 01f2287
IPSec restart tests
pmtk 6c7d2aa
IPSec example configuration doc
pmtk 149da75
Remove unnecessary if in c2cc scenarios
pmtk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| # Encrypting C2CC Traffic with IPsec | ||
|
|
||
| MicroShift Cluster-to-Cluster Connectivity (C2CC) routes cross-cluster pod and service traffic as raw IP between nodes. | ||
| This traffic traverses the physical network unencrypted by default. | ||
| You can use IPsec to protect it using standard Linux tools. | ||
|
|
||
| MicroShift does not configure or manage IPsec. | ||
| Setting up and maintaining the IPsec tunnels is the responsibility of the system administrator. | ||
| This guide provides a minimal working example using Libreswan in tunnel mode to help you get started. | ||
|
|
||
| For comprehensive IPsec/VPN documentation, see [Setting up an IPsec VPN](https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/configuring_and_managing_networking/setting-up-an-ipsec-vpn_configuring-and-managing-networking) in the RHEL documentation. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Two or more RHEL hosts running MicroShift with C2CC configured (non-overlapping pod and service CIDRs, `clusterToCluster.remoteClusters` populated in each node's config). | ||
| - IP connectivity between the hosts on the underlay network. | ||
| - Libreswan installed on every host: | ||
|
|
||
| ```bash | ||
| sudo dnf install -y libreswan | ||
| ``` | ||
|
|
||
| ## Firewall | ||
|
|
||
| Open the firewall for IKE negotiation and ESP: | ||
|
|
||
| ```bash | ||
| sudo firewall-cmd --permanent --zone=public --add-service=ipsec | ||
| sudo firewall-cmd --reload | ||
| ``` | ||
|
|
||
| This allows UDP ports 500 and 4500 (IKE/NAT-T) and IP protocol 50 (ESP). | ||
|
|
||
| ## Generate a Pre-Shared Key | ||
|
|
||
| Generate a shared secret on one host and distribute it to all others through a secure channel: | ||
|
|
||
| ```bash | ||
| openssl rand -hex 32 | ||
| ``` | ||
|
|
||
| ## Configure Libreswan | ||
|
|
||
| The examples below assume a two-cluster setup: | ||
|
|
||
| | Host | Underlay IP | Pod CIDR | Service CIDR | | ||
| |---------|---------------|----------------|----------------| | ||
| | Host A | 192.168.1.10 | 10.42.0.0/16 | 10.43.0.0/16 | | ||
| | Host B | 192.168.1.20 | 10.45.0.0/16 | 10.46.0.0/16 | | ||
|
|
||
| ### Secrets | ||
|
|
||
| On **each** host, create `/etc/ipsec.d/c2cc.secrets`: | ||
|
|
||
| ```conf | ||
| 192.168.1.10 192.168.1.20 : PSK "<your-hex-key>" | ||
| ``` | ||
|
|
||
| Set permissions: | ||
|
|
||
| ```bash | ||
| sudo chmod 600 /etc/ipsec.d/c2cc.secrets | ||
| sudo restorecon -v /etc/ipsec.d/c2cc.secrets | ||
| ``` | ||
|
|
||
| ### Connection definition | ||
|
|
||
| On **Host A**, create `/etc/ipsec.d/c2cc-tunnel.conf`: | ||
|
|
||
| ```conf | ||
| conn c2cc-to-host-b | ||
| type=tunnel | ||
| authby=secret | ||
| left=192.168.1.10 | ||
| right=192.168.1.20 | ||
| leftsubnets={10.42.0.0/16 10.43.0.0/16} | ||
| rightsubnets={10.45.0.0/16 10.46.0.0/16} | ||
| auto=start | ||
| ike=aes256-sha2_256-modp2048 | ||
| esp=aes256-sha2_256 | ||
| failureshunt=drop | ||
| negotiationshunt=drop | ||
| ikev2=insist | ||
| ``` | ||
|
|
||
| On **Host B**, create the same file with `left`/`right` and subnet values swapped: | ||
|
|
||
| ```conf | ||
| conn c2cc-to-host-a | ||
| type=tunnel | ||
| authby=secret | ||
| left=192.168.1.20 | ||
| right=192.168.1.10 | ||
| leftsubnets={10.45.0.0/16 10.46.0.0/16} | ||
| rightsubnets={10.42.0.0/16 10.43.0.0/16} | ||
| auto=start | ||
| ike=aes256-sha2_256-modp2048 | ||
| esp=aes256-sha2_256 | ||
| failureshunt=drop | ||
| negotiationshunt=drop | ||
| ikev2=insist | ||
| ``` | ||
|
|
||
| Key parameters: | ||
|
|
||
| - **`type=tunnel`** -- Tunnel mode encrypts the original IP packet and wraps it in a new IP header. This is required because C2CC traffic uses pod/service CIDRs as source and destination, which are not routable on the underlay. | ||
| - **`leftsubnets` / `rightsubnets`** -- Must match the pod and service CIDRs configured in MicroShift. Each `{cidr1 cidr2}` pair creates one child SA per local/remote CIDR combination. | ||
| - **`auto=start`** -- Bring the tunnel up automatically when the IPsec service starts. | ||
| - **`failureshunt=drop` / `negotiationshunt=drop`** -- Drop traffic that matches the tunnel selectors if the SA fails or is still negotiating, preventing fallback to plaintext. | ||
| - **`ikev2=insist`** -- Require IKEv2. IKEv1 is not recommended. | ||
|
|
||
| ### Three or more clusters | ||
|
|
||
| For a full mesh of N clusters, each host needs a connection definition and a secrets entry for every remote host. | ||
| For example, with three hosts, Host A would have two `conn` blocks (one for Host B, one for Host C) and two secrets entries. | ||
|
|
||
| ## Start IPsec | ||
|
|
||
| Initialize the NSS database (first time only) and start the service: | ||
|
|
||
| ```bash | ||
| sudo ipsec checknss | ||
| sudo systemctl enable --now ipsec | ||
| ``` | ||
|
|
||
| ## Verify the Tunnels | ||
|
|
||
| Check that tunnel SAs are established: | ||
|
|
||
| ```bash | ||
| sudo ipsec trafficstatus | ||
| ``` | ||
|
|
||
| You should see output containing `type=ESP` entries for each subnet pair. | ||
| For a two-cluster setup with 2 local CIDRs and 2 remote CIDRs, expect 4 child SAs. | ||
|
|
||
| Verify XFRM state is populated: | ||
|
|
||
| ```bash | ||
| ip xfrm state | ||
| ``` | ||
|
|
||
| You can also capture packets on the wire to confirm ESP encapsulation: | ||
|
|
||
| ```bash | ||
| sudo tcpdump -i enp1s0 -c 10 esp | ||
| ``` | ||
|
|
||
| ## Considerations | ||
|
|
||
| - **IPsec adds overhead.** ESP tunnel mode adds approximately 36-52 bytes per packet. If you experience MTU issues, verify that path MTU discovery is working or adjust MTU settings accordingly. | ||
| - **Tunnel recovery.** If IPsec is restarted on one host, tunnels renegotiate automatically when `auto=start` is set. No MicroShift restart is required. | ||
| - **Certificates.** This guide uses pre-shared keys for simplicity. For production deployments, consider certificate-based authentication. See the [RHEL VPN documentation](https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/configuring_and_managing_networking/setting-up-an-ipsec-vpn_configuring-and-managing-networking) for details. | ||
| - **Policy enforcement.** The example connection definitions include `failureshunt=drop` and `negotiationshunt=drop` to prevent traffic from falling back to plaintext when the tunnel is down or still negotiating. If you remove these options, traffic matching the tunnel selectors will be sent unencrypted whenever the SA is unavailable. | ||
10 changes: 10 additions & 0 deletions
10
...ge-blueprints-bootc/el10/layer2-presubmit/group2/rhel102-bootc-source-ipsec.containerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| FROM localhost/rhel102-bootc-source:latest | ||
|
|
||
| # Install Libreswan (IPsec) and tcpdump for C2CC IPsec E2E tests. | ||
| # Libreswan provides the ipsec service and pluto daemon. | ||
| # tcpdump is used to capture and verify ESP-encapsulated packets. | ||
| RUN dnf install -y libreswan tcpdump && \ | ||
|
agullon marked this conversation as resolved.
|
||
| dnf clean all | ||
|
|
||
| # Pre-configure firewall for IKE (UDP 500/4500) and ESP (protocol 50). | ||
| RUN firewall-offline-cmd --zone=public --add-service=ipsec | ||
10 changes: 10 additions & 0 deletions
10
...mage-blueprints-bootc/el9/layer2-presubmit/group2/rhel98-bootc-source-ipsec.containerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| FROM localhost/rhel98-bootc-source:latest | ||
|
|
||
| # Install Libreswan (IPsec) and tcpdump for C2CC IPsec E2E tests. | ||
| # Libreswan provides the ipsec service and pluto daemon. | ||
| # tcpdump is used to capture and verify ESP-encapsulated packets. | ||
| RUN dnf install -y libreswan tcpdump && \ | ||
| dnf clean all | ||
|
|
||
| # Pre-configure firewall for IKE (UDP 500/4500) and ESP (protocol 50). | ||
| RUN firewall-offline-cmd --zone=public --add-service=ipsec |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.