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