diff --git a/beacon-chain/p2p/discovery.go b/beacon-chain/p2p/discovery.go index bca78f381..99c7d01de 100644 --- a/beacon-chain/p2p/discovery.go +++ b/beacon-chain/p2p/discovery.go @@ -49,7 +49,7 @@ func createListener(ipAddr net.IP, privKey *ecdsa.PrivateKey, cfg *Config) *disc } if cfg.HostAddress != "" { hostIP := net.ParseIP(cfg.HostAddress) - if hostIP.To4() == nil { + if hostIP.To4() == nil && hostIP.To16() == nil { log.Errorf("Invalid host address given: %s", hostIP.String()) } else { localNode.SetFallbackIP(hostIP) diff --git a/beacon-chain/p2p/options.go b/beacon-chain/p2p/options.go index 019a20422..7d0d7133f 100644 --- a/beacon-chain/p2p/options.go +++ b/beacon-chain/p2p/options.go @@ -42,7 +42,11 @@ func buildOptions(cfg *Config, ip net.IP, priKey *ecdsa.PrivateKey) []libp2p.Opt } if cfg.HostAddress != "" { options = append(options, libp2p.AddrsFactory(func(addrs []multiaddr.Multiaddr) []multiaddr.Multiaddr { - external, err := multiaddr.NewMultiaddr(fmt.Sprintf("/ip4/%s/tcp/%d", cfg.HostAddress, cfg.TCPPort)) + protocol := "ip4" + if ip := net.ParseIP(cfg.HostAddress); ip.To4() == nil { + protocol = "ip6" + } + external, err := multiaddr.NewMultiaddr(fmt.Sprintf("/%s/%s/tcp/%d", protocol, cfg.HostAddress, cfg.TCPPort)) if err != nil { log.WithError(err).Error("Unable to create external multiaddress") } else {