#!/usr/bin/ksh93 # # Ethernet/tap forwarding via ssh # set -o xtrace set -o errexit set -o nounset # list of commands our ssh session should execute typeset -a sshcmds=( "set -o xtrace ;" "set -o errexit ;" "brctl addbr br19 ;" "brctl addif br19 tap19 ;" "brctl addif br19 eno1 ;" "brctl show ;" "ifconfig tap19 promisc ;" "ifconfig tap19 up ;" "ifconfig br19 up ;" "set +o errexit ;" "read dummy ;" # dummy wait # # cleanup: # # we need to clean up the bridge interface ourselves, if # we do not do that we risk getting that any subsequent # ifconfig/ip/etc command hangs # "brctl delif br19 tap19 ;" "brctl delif br19 eno1 ;" "ifconfig tap19 down ;" "ifconfig br19 down ;" "brctl delbr br19 ;" 'kill -s HUP -${PPID} ;' ) ssh \ -o ExitOnForwardFailure=yes \ -o PermitLocalCommand=yes \ -o LocalCommand="ifconfig tap19 up" \ -o Tunnel=ethernet -w 19:19 \ root@10.49.20.202 \ "${sshcmds[*]}" # cleanup # ... # EOF.