Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Check that two arguments were provided
- if [ $# -ne 2 ]; then
- echo "Usage: $0 port1 port2"
- exit 1
- fi
- # Set variables for the two ports
- port1=$1
- port2=$2
- # Create bidirectional tunnel between the two ports using socat
- socat TCP-LISTEN:$port1,fork TCP:localhost:$port2 &
- socat TCP-LISTEN:$port2,fork TCP:localhost:$port1 &
- # Redirect outgoing traffic from port1 to port2 using iptables
- iptables -t nat -A OUTPUT -p tcp --dport $port1 -j REDIRECT --to-port $port2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement