On default settings, the use of reuse-port means all connections will come and go from the same port. That means, if you are listening on :4001 , all egress connections source-port is set to 4001. Per the ipfs id
output above, it would seem AutoNAT has discovered port 48049
as well or upnp has assigned that port. Is this firewall NAT’ing you?
Given all the source port for all connections is 4001, in the case of NAT, only one external-facing port needs to be assigned in the firewall. If you set up port forwarding manually, this may be 4001 as well and you can disable upnp etc. You can use https://check.ipfs.network/ to check which addresses can be found and work from the outside. Incoming connections should only go to “advertised” ports (tcp 4001, udp 48049, udp 4001 per the above).
Now, what exactly is the policy blocking connections?
- Is it blocking egress or ingress? Is it resetting connections or pooling them for later?
- Is it blocking IPv6, which is not NAT’ed anyways?
- Does it handle UDP/TCP traffic differently?
- What is the limit? 100? 200? 1000?
I don’t know what the firewall is doing that connections hurt its performance (it is its job to handle them?). Sometimes UDP connection tracking in Firewalls come with large timeouts, which cause otherwise short-lived connections to build-up on the tracking table (even though you have only 200 peers, the number may be bigger from the firewall’s point of view). You can try disabling UDP-based transports and see if your admin is happier:
"Transports": {
"Multiplexers": {},
"Network": {
"QUIC": false,
"WebTransport": false,
"WebRTCDirect": false,
"TCP": true,
"Websocket": true
},
"Security": {}
}
In order to avoid many new but short-lived connections, you can actually increase the connmgr settings to reduce churn, while lowering GracePeriod:
"ConnMgr": {
"LowWater": 500,
"HighWater": 1000,
"GracePeriod": "5s"
},
It is still not clear what exactly is bothering your admin or your firewall. A full network crawl, IPFS will top at around 6500 egress-connections at the firewall table. This should be manageable by non consumer-grade hardware with ease. From their side it would be interested to know (if you manage to have a conversation about it):
- What are the UDP timeouts? What about the TCP_SYN timeouts? Large timeouts may cause build up of otherwise short-lived connections.
- Confirm whether source port for all egress connections is 4001: it should be, otherwise SO_REUSEPORT is not working on your platform (you can check this yourself via
lsof -n -i -P | grep ipfs
- How many connections can they attribute to your Kubo box at any given time?
- What is the state of those connections? Is there UDP build up? Many stuck TCP SYNs?
- What are the limits on? Per max connections? Per protocol? Per IP? Per direction?
If the answer is “you can only have 50 connections every 5 minutes” then it is going to be very hard to work on the public network, without requiring specific configuration/peering in clients. The ConnMgr can be use as baseline, but DHT lookups or announcements will spike total connections. There are some improvements coming here as well that will smooth things out significantly (new DHT reprovider) but right now controlling those spikes will hurt lookup/provide reliability.