pastebin - collaborative debugging tool
rovema.kpaste.net RSS

Difference between
modified post b462550ed3 by Anonymous on Thu 14th Apr 2022 13:48
original post fad4 by Anonymous on Thu 14th Apr 2022 13:32
Download diff
Show old version | new version | both versions

    
11
#!/usr/bin/ksh93
22
33
#
44
# Ethernet/tap forwarding via ssh
55
#
66
77
set -o xtrace
88
set -o errexit
99
set -o nounset
1010
1111
# list of commands our ssh session should execute
1212
typeset -a sshcmds=(
1313
	#
1414
	# cleanup:
1515
	#
1616
	# we need to clean up the bridge interface ourselves, if
1717
	# we do not do that we risk getting that any subsequent
1818
	# ifconfig/ip/etc command hangs
1919
	#
2020
	'(( trap_once=0 )) ;'
2121
	"netcleanup() { "
2222
		'(( trap_once++ > 0 )) && return 0 ;'
2323
		"set +o errexit ;"
2424
		"brctl delif br19 tap19 ;"
2525
		"brctl delif br19 eno1 ;"
2626
		"ifconfig tap19 down ;"
2727
		"ifconfig br19 down ;"
2828
		"brctl delbr br19 ;"
29+
		"exit 0 ;"
2930
	"} ;"
3031
	'trap netcleanup EXIT ;'
3132
	'trap netcleanup HUP ;'
3233
3334
	"set -o xtrace ;"
3435
	"set -o errexit ;"
3536
	"brctl addbr br19 ;"
3637
	"brctl addif br19 tap19 ;"
3738
	"brctl addif br19 eno1 ;"
3839
	"brctl show ;"
3940
	"ifconfig tap19 promisc ;"
4041
	"ifconfig tap19 up ;"
4142
	"ifconfig br19 up ;"
4243
43-
	"read dummy ;" # dummy wait
44+
	"read dummy ;" # wait
4445
45-
	'kill -s HUP -${PPID} ;'
46+
	# this is nasty:
47+
	# we have to tell sshd to quit, and then busy-wait
4652
)
4753
4854
ssh \
4955
	-o ExitOnForwardFailure=yes \
5056
	-o PermitLocalCommand=yes \
5157
	-o LocalCommand="ifconfig tap19 up" \
5258
	-o Tunnel=ethernet -w 19:19 \
5359
	root@10.49.20.202 \
5460
	"${sshcmds[*]}"
5561
5662
# cleanup
5763
# ...
5864
5965
# EOF.
6066

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