Skip to content
/ go-stun Public

A go implementation of the STUN client (RFC 3489 and RFC 5389)


Notifications You must be signed in to change notification settings


Folders and files

Last commit message
Last commit date

Latest commit


Repository files navigation


License GoDoc Go Report Card

go-stun is a STUN (RFC 3489, 5389) client implementation in golang (a.k.a. UDP hole punching).

RFC 3489: STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs)

RFC 5389: Session Traversal Utilities for NAT (STUN)

Use the Command Line Tool

Simply run these commands (if you have installed golang and set $GOPATH)

go get

or clone this repo and run these commands

go build

You will get the output like

NAT Type: Full cone NAT
External IP Family: 1
External IP:
External Port: 23009

You can use -s flag to use another STUN server, and use -v to work on verbose mode.

> ./go-stun --help
Usage of ./go-stun:
  -s string
        server address (default "")
  -v    verbose mode

Use the Library

The library is extremely easy to use -- just one line of code.

import ""

func main() {
	nat, host, err := stun.NewClient().Discover()

More details please go to main.go and GoDoc