pastebin - collaborative debugging tool
rovema.kpaste.net RSS


ssh tuntap #017
Posted by Anonymous on Thu 14th Apr 2022 12:47
raw | new post
view followups (newest first): ssh tuntap #017 by Anonymous
modification of post by Anonymous (view diff)

  1. #!/usr/bin/ksh93
  2.  
  3. #
  4. # Ethernet/tap forwarding via ssh
  5. #
  6.  
  7. set -o xtrace
  8. set -o errexit
  9. set -o nounset
  10.  
  11. # list of commands our ssh session should execute
  12. typeset -a sshcmds=(
  13.         "set -o xtrace ;"
  14.         "set -o errexit ;"
  15.         "brctl addbr br19 ;"
  16.         "brctl addif br19 tap19 ;"
  17.         "brctl addif br19 eno1 ;"
  18.         "brctl show ;"
  19.         "ifconfig tap19 promisc ;"
  20.         "ifconfig tap19 up ;"
  21.         "ifconfig br19 up ;"
  22.  
  23.         "set +o errexit ;"
  24.  
  25.         "read dummy ;" # dummy wait
  26.  
  27.         #
  28.         # cleanup:
  29.         #
  30.         # we need to clean up the bridge interface ourselves, if
  31.         # we do not do that we risk getting that any subsequent
  32.         # ifconfig/ip/etc command hangs
  33.         #
  34.         "brctl delif br19 tap19 ;"
  35.         "brctl delif br19 eno1 ;"
  36.         "ifconfig tap19 down ;"
  37.         "ifconfig br19 down ;"
  38.         "brctl delbr br19 ;"
  39.         'kill -s HUP -${PPID} ;'
  40. )
  41.  
  42. ssh \
  43.         -o ExitOnForwardFailure=yes \
  44.         -o PermitLocalCommand=yes \
  45.         -o LocalCommand="ifconfig tap19 up" \
  46.         -o Tunnel=ethernet -w 19:19 \
  47.         root@10.49.20.202 \
  48.         "${sshcmds[*]}"
  49.  
  50. # cleanup
  51. # ...
  52.  
  53. # EOF.

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at