Created
April 2, 2025 00:41
-
-
Save TechnicallyUnsure/a79154a9a3c80cfe66cf425e78534d48 to your computer and use it in GitHub Desktop.
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
| #!/bin/bash | |
| set -xe | |
| TAP_A=eth0 | |
| TAP_B=eth1 | |
| # Remove any IP addresses that may be set on the interfaces | |
| ip address flush dev "$TAP_A" | |
| ip address flush dev "$TAP_B" | |
| # Clear (delete) any existing ingress qdiscs to avoid duplicates | |
| tc qdisc del dev "$TAP_A" ingress 2>/dev/null || true | |
| tc qdisc del dev "$TAP_B" ingress 2>/dev/null || true | |
| # Add ingress qdiscs to both interfaces | |
| tc qdisc add dev "$TAP_A" ingress | |
| tc qdisc add dev "$TAP_B" ingress | |
| # Mirror traffic from TAP_A to TAP_B | |
| tc filter add \ | |
| dev "$TAP_A" \ | |
| parent ffff: \ | |
| protocol all \ | |
| u32 match u8 0 0 \ | |
| action mirred egress mirror dev "$TAP_B" | |
| # Mirror traffic from TAP_B to TAP_A | |
| tc filter add \ | |
| dev "$TAP_B" \ | |
| parent ffff: \ | |
| protocol all \ | |
| u32 match u8 0 0 \ | |
| action mirred egress mirror dev "$TAP_A" | |
| # Disable IPv6 (this helps prevent IPv6 autoconfiguration packets) | |
| sysctl -w net.ipv6.conf."$TAP_A".disable_ipv6=1 | |
| sysctl -w net.ipv6.conf."$TAP_B".disable_ipv6=1 | |
| # Bring up the interfaces and enable promiscuous mode | |
| ip link set dev "$TAP_A" up promisc on | |
| ip link set dev "$TAP_B" up promisc on |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment