Command line utility to forward ports between two hosts across different networks/subnets, in a peer-to-peer fashion using zerotier, without sudo privileges
On both the hosts.
-
Homebrew
brew install https://raw.githubusercontent.com/selvakn/homebrew-core/master/Formula/p2p-port-forward.rb
Or
-
Using
go get
go get https://github.com/selvakn/p2p-port-forward
Or
-
Single binaries
- Download the single binary for your platform from releases
mv p2p-port-forward-<platform/arch> p2p-port-forward
chmod +x p2p-port-forward
usage: p2p-port-forward [<flags>]
Flags:
--help Show context-sensitive help (also try --help-long and --help-man).
-n, --network="8056c2e21c000001"
zerotier network id
-f, --forward-port="22" port to forward (in listen mode)
-a, --accept-port="2222" port to accept (in connect mode)
-u, --use-udp UDP instead of TCP (TCP default)
-c, --connect-to=CONNECT-TO server (zerotier) ip to connect
--version Show application version.
On host1 (where the service or any port should be exposed)
p2p-port-forward [-n 8056c2e21c000001] [-f 22]
On host2 (where we want to access the port)
p2p-port-forward -c <server-ip-from-output-of-server> [-a 2222]
Then connect to port 2222 on host2, to reach host1:22. Ex:
ssh -p 2222 user@localhost