How to communciate between two tap interfaces on two machines?
0
votes
2
answers
109
views
I have two debian based machines with IP adresses XXX.XXX.8.76/26 and XXX.XXX.8.77/26.
Now i need to create a tap0 interface on both machines for an application that communicates with UDP messages.
But it is not possible for me to send a UDP messages between both tap0's.
tap0 eno1 eno1 tap0
I simply created the tap0 with
ip tuntap add dev tap0 mode tap
After this I bridge the tap0 and the physical ethernet adapter with the following script:
#!/bin/bash
# Exit on error
set -e
# Define variables
BRIDGE=br0
ETH_IFACE=eno1
TAP_IFACE=tap0
IP_ADDR=XXX.XXX.8.76/26
GATEWAY=XXX:XXX.8.65
# Check if run as root
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit
fi
echo "Creating bridge $BRIDGE..."
ip link add $BRIDGE type bridge
echo "Bringing up the bridge..."
ip link set $BRIDGE up
echo "Adding $ETH_IFACE and $TAP_IFACE to $BRIDGE..."
ip link set $ETH_IFACE master $BRIDGE
ip link set $TAP_IFACE master $BRIDGE
echo "Bringing up $ETH_IFACE and $TAP_IFACE..."
ip link set $ETH_IFACE up
ip link set $TAP_IFACE up
echo "Assigning IP address to $BRIDGE..."
ip addr flush dev $ETH_IFACE
ip addr add $IP_ADDR dev $BRIDGE
echo "Setting up default gateway..."
ip route add default via $GATEWAY dev $BRIDGE
echo "Bridge setup complete. Current configuration:"
ip addr show $BRIDGE
bridge link show
If you have solutions that don't include a bridge I'm glad to hear them too :)
The program I want to run is the lwIP Stack.
Asked by Simon
(1 rep)
Feb 27, 2025, 09:48 PM
Last activity: Mar 11, 2025, 09:56 AM
Last activity: Mar 11, 2025, 09:56 AM