---

Making a cross-connect between two LXD containers

Couple of small scripts to cross-connect the containers: lxc-connect:
#!/bin/bash
ANAME=$1
BNAME=$2
APID=`lxc info $ANAME | grep Pid:  | awk '{print $2;}'`
BPID=`lxc info $BNAME | grep Pid:  | awk '{print $2;}'`
ANS="../../../proc/$APID/ns/net"
BNS="../../../proc/$BPID/ns/net"

sudo ip link add name ${ANAME}_${BNAME} type veth peer name ${BNAME}_${ANAME}
sudo ip link set dev ${ANAME}_${BNAME} up netns $ANS
sudo ip link set dev ${BNAME}_${ANAME} up netns $BNS
lxc-disconnect:
#!/bin/bash
ANAME=$1
BNAME=$2
APID=`lxc info $ANAME | grep Pid:  | awk '{print $2;}'`
BPID=`lxc info $BNAME | grep Pid:  | awk '{print $2;}'`
ANS="../../../proc/$APID/ns/net"
BNS="../../../proc/$BPID/ns/net"

sudo ip netns exec $ANS ip link del dev ${ANAME}_${BNAME}
sudo ip netns exec $BNS ip link del dev ${BNAME}_${ANAME}

Files in 2016-04-03-Making-a-cross-connect-between-two-LXD-containers:


../
HEADER.txt                                         01-Jul-2024 21:41                 897

(c) Andrew Yourtchenko