#!/bin/bash set -euo pipefail RED='\033[0;31m' NC='\033[0m' namespace=$1 pid=$2 host=$3 client=$4 GATEWAY=$(ip route show default | awk '{print $3}') #ip=$5 [[ -z "$namespace" || -z "$pid" || -z "$host" || -z "$client" ]] && { echo -e "${RED}Error:${NC} Missing arguments. Usage: $0 " exit 1 } ip netns attach "$namespace" "$pid" ip link add "$host" type veth peer name "$client" ip link set "$host" master br0 ip link set "$client" netns "$namespace" ip link set "$host" up ip netns exec "$namespace" ip link set lo up ip netns exec "$namespace" ip link set "$client" up #ip netns exec "$namespace" ip addr add "$ip" dev "$client" ip netns exec "$namespace" ip route add default via "$GATEWAY" exit 0