Implementation of the following in Go:
- ping utility
- UDP protocol
- TCP protocol
From a Linux VM (eg. OrbStack - ubuntu)
-
Install dependencies
# Install tools $ sudo apt install -y iptables lsof # Install Go $ wget -O /tmp/go.tar.gz $LINK_TO_GO_BINARY (https://go.dev/dl) # Untar, add to path $ tar -C /usr/local -xzf /tmp/go.tar.gz $ export PATH=$PATH:/usr/local/go/bin # Confirm installation successful $ go version
-
Run a local server at:
192.0.2.1:8080
$ python3 -m http.server --bind 192.0.2.1 8080
-
Run setup script to create a network tunnel (
tun0
) and set up NATbash setup.sh
go run cmd/ping/main.go 192.0.2.1
go run cmd/ping/main.go -c 3 192.0.2.1
go run cmd/udp/main.go 8.8.8.8
go run cmd/tcp/main.go 192.0.2.1
- Lima: some potential network issues?
- Colima
- OrbStack: free for personal use, subscription otherwise.
- UTM
-
tcpdump
sudo tcpdump -ni tun0 sudo tcpdump -ni tun0 host 192.0.2.1
-
tshark (terminal Wireshark)
sudo tshark -f "tcp port 12345" -i tun0 -w dump.pcap
Open
dump.pcap
in Wireshark. -
nc
nc -l 192.0.2.1 8080