Use StaticRelays

I have 3 nodes, A, B, C. Node A has a public network ip. A node configuration is as follows

A:

{
  "Identity": {
    "PeerID": "12D3KooWDzkEohDABVk6fUMRENaX1CWUcLLKLrew4X5aB7NvX6eZ",
    "PrivKey": "CAESQHfwiEmnoLUlHsr60PXHL/QyR54fLeaxyQNwPh6Z878QPheCrQNIXR1IYOnXna1GCAQFZhwyVmTaFVJ3gGWm/NY="
  },
  "Addresses": {
    "Swarm": [
      "/ip4/0.0.0.0/tcp/4001",
      "/ip6/::/tcp/4001",
      "/ip4/0.0.0.0/udp/4001/quic",
      "/ip4/0.0.0.0/udp/4001/quic-v1",
      "/ip4/0.0.0.0/udp/4001/quic-v1/webtransport",
      "/ip6/::/udp/4001/quic",
      "/ip6/::/udp/4001/quic-v1",
      "/ip6/::/udp/4001/quic-v1/webtransport"
    ],
    "Announce": [],
    "AppendAnnounce": [],
    "NoAnnounce": [],
    "API": "/ip4/127.0.0.1/tcp/5001",
    "Gateway": "/ip4/127.0.0.1/tcp/8080"
  },
  "Mounts": {
    "IPFS": "/ipfs",
    "IPNS": "/ipns",
    "FuseAllowOther": false
  },
  "Discovery": {
    "MDNS": {
      "Enabled": true
    }
  },
  "Routing": {
    "Routers": null,
    "Methods": null
  },
  "Ipns": {
    "RepublishPeriod": "",
    "RecordLifetime": "",
    "ResolveCacheSize": 128
  },
  "Bootstrap": [
  ],
  "Gateway": {
    "HTTPHeaders": {
      "Access-Control-Allow-Headers": [
        "X-Requested-With",
        "Range",
        "User-Agent"
      ],
      "Access-Control-Allow-Methods": [
        "GET"
      ],
      "Access-Control-Allow-Origin": [
        "*"
      ]
    },
    "RootRedirect": "",
    "Writable": false,
    "PathPrefixes": [],
    "APICommands": [],
    "NoFetch": false,
    "NoDNSLink": false,
    "PublicGateways": null
  },
  "API": {
    "HTTPHeaders": {}
  },
  "Swarm": {
    "AddrFilters": null,
    "DisableBandwidthMetrics": false,
    "DisableNatPortMap": false,
    "RelayClient": {},
    "RelayService": {},
    "Transports": {
      "Network": {},
      "Security": {},
      "Multiplexers": {}
    },
    "ConnMgr": {},
    "ResourceMgr": {}
  },

}

Both nodes B and C are behind NAT

B:
{
  "Identity": {
    "PeerID": "12D3KooWR1DDhp7obaSRfdC6TTSURYs5S23f8ithS79npmnY1j7b",
    "PrivKey": "CAESQADvqMn0RvVqGPXmzA63uV2EJur3bea5t8SBJcRLlIMm4aaS/K43JHX1PPr7ONwrehb0BY9k7sA/gqjeO3NhaPY="
  },
  "Addresses": {
    "Swarm": [
      "/ip4/0.0.0.0/tcp/4001",
      "/ip6/::/tcp/4001",
      "/ip4/0.0.0.0/udp/4001/quic",
      "/ip4/0.0.0.0/udp/4001/quic-v1",                                                                                                        
      "/ip4/0.0.0.0/udp/4001/quic-v1/webtransport",                                                                                           
      "/ip6/::/udp/4001/quic",                                                                                                                
      "/ip6/::/udp/4001/quic-v1",                                                                                                             
      "/ip6/::/udp/4001/quic-v1/webtransport"                                                                                                 
    ],                                                                                                                                        
    "Announce": [],                                                                                                                           
    "AppendAnnounce": [],                                                                                                                     
    "NoAnnounce": [],                                                                                                                         
    "API": "/ip4/127.0.0.1/tcp/5001",                                                                                                         
    "Gateway": "/ip4/127.0.0.1/tcp/8080"                                                                                                      
  },                                                                                                                                          
  "Mounts": {                                                                                                                                 
    "IPFS": "/ipfs",                                                                                                                          
    "IPNS": "/ipns",                                                                                                                          
    "FuseAllowOther": false                                                                                                                   
  },                                                                                                                                          
  "Discovery": {                                                                                                                              
    "MDNS": {                                                                                                                                 
      "Enabled": true                                                                                                                         
    }                                                                                                                                         
  },                                                                                                                                          
  "Routing": {                                                                                                                                
    "Routers": null,                                                                                                                          
    "Methods": null                                                                                                                           
  },                                                                                                                                          
  "Ipns": {                                                                                                                                   
    "RepublishPeriod": "",                                                                                                                    
    "RecordLifetime": "",                                                                                                                     
    "ResolveCacheSize": 128                                                                                                                   
  },                                                                                                                                          
  "Bootstrap": [                                                                                                                              
    "/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",                                                        
    "/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa",                                                        
    "/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",
    "/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",                                                        
    "/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",                                                        
    "/ip4/104.131.131.82/udp/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"                                                    
  ],                                                                                                                                          
  "Gateway": {                                                                                                                                
    "HTTPHeaders": {                                                                                                                          
      "Access-Control-Allow-Headers": [                                                                                                       
        "X-Requested-With",                                                                                                                   
        "Range",                                                                                                                              
        "User-Agent"                                                                                                                          
      ],                                                                                                                                      
      "Access-Control-Allow-Methods": [                                                                                                       
        "GET"                                                                                                                                 
      ],                                                                                                                                      
      "Access-Control-Allow-Origin": [                                                                                                        
        "*"                                                                                                                                   
      ]                                                                                                                                       
    },                                                                                                                                        
    "RootRedirect": "",                                                                                                                       
    "Writable": false,                                                                                                                        
    "PathPrefixes": [],                                                                                                                       
    "APICommands": [],                                                                                                                        
    "NoFetch": false,                                                                                                                         
    "NoDNSLink": false,                                                                                                                       
    "PublicGateways": null                                                                                                                    
  },                                                                                                                                          
  "API": {                                                                                                                                    
    "HTTPHeaders": {}                                                                                                                         
  },                                                                                                                                          
  "Swarm": {                                                                                                                                  
    "AddrFilters": null,                                                                                                                      
    "DisableBandwidthMetrics": false,                                                                                                         
    "DisableNatPortMap": false,                                                                                                               
    "RelayClient": {                                                                                                                          
      "StaticRelays": [
        "/ip4/1.14.49.178/tcp/4001/p2p/12D3KooWDzkEohDABVk6fUMRENaX1CWUcLLKLrew4X5aB7NvX6eZ"
      ]                                                                                                                                       
    },                                                                                                                                        
    "RelayService": {},                                                                                                                       
    "Transports": {                                                                                                                           
      "Network": {},                                                                                                                          
      "Security": {},                                                                                                                         
      "Multiplexers": {}                                                                                                                      
    },                                                                                                                                        
    "ConnMgr": {},                                                                                                                            
    "ResourceMgr": {}                                                                                                                         
  },                                                                                                                                          
                                                                                                                                                                                                                                                            
}
C:
{
  "Identity": {
    "PeerID": "12D3KooWQy7qrxKo918uTPmVMnewDGHmUzMFL8MHcWJTfZoZhXCr",
    "PrivKey": "CAESQML3S2ePs41VqTkQBZdVFnNOGom+g+2IohhR+YwtCbun4R1VTbU9AcmpaDH0v2jTGuKHUZHvIqTcQZgG+nazPuc="
  },                                                                                                                         
  "Addresses": {                                                                                                                              
    "Swarm": [                                                                                                                                
      "/ip4/0.0.0.0/tcp/4001",                                                                                                                
      "/ip6/::/tcp/4001",                                                                                                                     
      "/ip4/0.0.0.0/udp/4001/quic",                                                                                                           
      "/ip4/0.0.0.0/udp/4001/quic-v1",                                                                                                        
      "/ip4/0.0.0.0/udp/4001/quic-v1/webtransport",                                                                                           
      "/ip6/::/udp/4001/quic",                                                                                                                
      "/ip6/::/udp/4001/quic-v1",                                                                                                             
      "/ip6/::/udp/4001/quic-v1/webtransport"                                                                                                 
    ],                                                                                                                                        
    "Announce": [],                                                                                                                           
    "AppendAnnounce": [],                                                                                                                     
    "NoAnnounce": [],                                                                                                                         
    "API": "/ip4/127.0.0.1/tcp/5001",                                                                                                         
    "Gateway": "/ip4/127.0.0.1/tcp/8080"                                                                                                      
  },                                                                                                                                          
  "Mounts": {                                                                                                                                 
    "IPFS": "/ipfs",                                                                                                                          
    "IPNS": "/ipns",                                                                                                                          
    "FuseAllowOther": false                                                                                                                   
  },                                                                                                                                          
  "Discovery": {                                                                                                                              
    "MDNS": {                                                                                                                                 
      "Enabled": true                                                                                                                         
    }                                                                                                                                         
  },                                                                                                                                          
  "Routing": {                                                                                                                                
    "Routers": null,                                                                                                                          
    "Methods": null                                                                                                                           
  },                                                                                                                                          
  "Ipns": {                                                                                                                                   
    "RepublishPeriod": "",                                                                                                                    
    "RecordLifetime": "",                                                                                                                     
    "ResolveCacheSize": 128                                                                                                                   
  },                                                                                                                                          
  "Bootstrap": [                                                                                                                              
    "/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",                                                        
    "/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",                                                        
    "/ip4/104.131.131.82/udp/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",                                                   
    "/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",                                                        
    "/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa",                                                        
    "/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb"                                                         
  ],                                                                                                                                          
  "Gateway": {                                                                                                                                
    "HTTPHeaders": {                                                                                                                          
      "Access-Control-Allow-Headers": [                                                                                                       
        "X-Requested-With",                                                                                                                   
        "Range",                                                                                                                              
        "User-Agent"                                                                                                                          
      ],                                                                                                                                      
      "Access-Control-Allow-Methods": [                                                                                                       
        "GET"                                                                                                                                 
      ],                                                                                                                                      
      "Access-Control-Allow-Origin": [                                                                                                        
        "*"                                                                                                                                   
      ]                                                                                                                                       
    },                                                                                                                                        
    "RootRedirect": "",                                                                                                                       
    "Writable": false,                                                                                                                        
    "PathPrefixes": [],                                                                                                                       
    "APICommands": [],                                                                                                                        
    "NoFetch": false,                                                                                                                         
    "NoDNSLink": false,                                                                                                                       
    "PublicGateways": null                                                                                                                    
  },                                                                                                                                          
  "API": {                                                                                                                                    
    "HTTPHeaders": {}                                                                                                                         
  },                                                                                                                                          
  "Swarm": {                                                                                                                                  
    "AddrFilters": null,                                                                                                                      
    "DisableBandwidthMetrics": false,                                                                                                         
    "DisableNatPortMap": false,                                                                                                               
    "RelayClient": {                                                                                                                          
      "StaticRelays": [
        "/ip4/1.14.49.178/tcp/4001/p2p/12D3KooWDzkEohDABVk6fUMRENaX1CWUcLLKLrew4X5aB7NvX6eZ"
      ]                                                                                                                                       
    },                                                                                                                                        
    "RelayService": {},                                                                                                                       
    "Transports": {                                                                                                                           
      "Network": {},                                                                                                                          
      "Security": {},                                                                                                                         
      "Multiplexers": {}                                                                                                                      
    },                                                                                                                                        
    "ConnMgr": {},                                                                                                                            
    "ResourceMgr": {}                                                                                                                         
  },                                                                                                                                          
                                                                                                                                                                                                                                                          
}

The node information of B and C are as follows

B:
ipfs id
{
        "ID": "12D3KooWR1DDhp7obaSRfdC6TTSURYs5S23f8ithS79npmnY1j7b",
        "PublicKey": "CAESIOGmkvyuNyR19Tz6+zjcK3oW9AWPZO7AP4Ko3jtzYWj2",
        "Addresses": [
                "/ip4/1.14.49.178/tcp/4001/p2p/12D3KooWDzkEohDABVk6fUMRENaX1CWUcLLKLrew4X5aB7NvX6eZ/p2p-circuit/p2p/12D3KooWR1DDhp7obaSRfdC6TTSURYs5S23f8ithS79npmnY1j7b",
                "/ip4/1.14.49.178/udp/4001/quic-v1/p2p/12D3KooWDzkEohDABVk6fUMRENaX1CWUcLLKLrew4X5aB7NvX6eZ/p2p-circuit/p2p/12D3KooWR1DDhp7obaSRfdC6TTSURYs5S23f8ithS79npmnY1j7b",
                "/ip4/1.14.49.178/udp/4001/quic/p2p/12D3KooWDzkEohDABVk6fUMRENaX1CWUcLLKLrew4X5aB7NvX6eZ/p2p-circuit/p2p/12D3KooWR1DDhp7obaSRfdC6TTSURYs5S23f8ithS79npmnY1j7b",
                "/ip4/127.0.0.1/tcp/4001/p2p/12D3KooWR1DDhp7obaSRfdC6TTSURYs5S23f8ithS79npmnY1j7b",
                "/ip4/127.0.0.1/udp/4001/quic/p2p/12D3KooWR1DDhp7obaSRfdC6TTSURYs5S23f8ithS79npmnY1j7b",
                "/ip4/192.168.1.4/tcp/4001/p2p/12D3KooWR1DDhp7obaSRfdC6TTSURYs5S23f8ithS79npmnY1j7b",
        ],
        "AgentVersion": "kubo/0.18.0/",
        "ProtocolVersion": "ipfs/0.1.0",
                                                                                                                                       
}
C:
ipfs id
{
        "ID": "12D3KooWQy7qrxKo918uTPmVMnewDGHmUzMFL8MHcWJTfZoZhXCr",
        "PublicKey": "CAESIOEdVU21PQHJqWgx9L9o0xrih1GR7yKk3EGYBvp2sz7n",
        "Addresses": [
                "/ip4/1.14.49.178/tcp/4001/p2p/12D3KooWDzkEohDABVk6fUMRENaX1CWUcLLKLrew4X5aB7NvX6eZ/p2p-circuit/p2p/12D3KooWQy7qrxKo918uTPmVMnewDGHmUzMFL8MHcWJTfZoZhXCr",
                "/ip4/1.14.49.178/udp/4001/quic-v1/p2p/12D3KooWDzkEohDABVk6fUMRENaX1CWUcLLKLrew4X5aB7NvX6eZ/p2p-circuit/p2p/12D3KooWQy7qrxKo918uTPmVMnewDGHmUzMFL8MHcWJTfZoZhXCr",
                "/ip4/1.14.49.178/udp/4001/quic/p2p/12D3KooWDzkEohDABVk6fUMRENaX1CWUcLLKLrew4X5aB7NvX6eZ/p2p-circuit/p2p/12D3KooWQy7qrxKo918uTPmVMnewDGHmUzMFL8MHcWJTfZoZhXCr",
                "/ip4/127.0.0.1/tcp/4001/p2p/12D3KooWQy7qrxKo918uTPmVMnewDGHmUzMFL8MHcWJTfZoZhXCr",
                "/ip4/127.0.0.1/udp/4001/quic-v1/p2p/12D3KooWQy7qrxKo918uTPmVMnewDGHmUzMFL8MHcWJTfZoZhXCr",
        ],
        "AgentVersion": "kubo/0.18.0/",
        "ProtocolVersion": "ipfs/0.1.0",
                                                                                                                                    
}

I want to connect B and C to each other through A node, and then they can transfer files to each other.

when i execute the commandipfs swarm connect /ip4/1.14.49.178/udp/4001/quic-v1/p2p/12D3KooWDzkEohDABVk6fUMRENaX1CWUcLLKLrew4X5aB7NvX6eZ/p2p-circuit/p2p/12D3KooWQy7qrxKo918uTPmVMnewDGHmUzMFL8MHcWJTfZoZhXCr but there is no result, no error and no connection to the target node

When I do not specify the relay point, the two points behind NAT can connect to each other and transfer files

1 Like

It looks like you’re trying to use CircuitRelayV1 (full relaying), which was deprecated in Kubo v0.11.0 unfortunately. So to test out what you’re trying, you’d need v0.10.x or earlier. In newer version of Kubo, the circuit-relay v2 is used “under-the-hood” to assist in automatic hole-punching for users behind NAT to achieve connections.