Reputation: 16216
I configured my Ubuntu 20.04 server to have multiple IPv6 addresses using nestat
like this:
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: yes
dhcp6: no
addresses:
- "xxxx:xxxx:xxxx:xxxx::1/64"
- "xxxx:xxxx:xxxx:xxxx::2/64"
gateway6: "xxxx::1"
nameservers:
search: [xxxx.xxxx.com]
addresses:
- xxxx:xxxx::6
- xxxx:xxxx::7
I can see these addresses in the output of ifconfig
and when I ping them using ping6
on the same server it works.
Now I'm trying to bind to one these IPv6 addresses using localAddress
and send an HTTP GET request:
const http = require('http')
const options = {
host: "xxx.xxx.xxx.xxx",
port: 3000,
path: '/',
family: 6,
localAddress: 'xxxx:xxxx:xxxx:xxxx::1'
}
const req = http.get(options)
req.on('response', res => {
res.on('data', chunk => console.log)
})
This results in the following error:
Error: bind EINVAL xxxx:xxxx:xxxx:xxxx::1
I understand that this error can mean multiple things:
The socket is already bound to an address, and the protocol does not support binding to a new address; or the socket has been shut down.
What can I do to debug this?
Upvotes: 1
Views: 450
Reputation: 16216
I resolved this issue and the answer is trivial - the server I was connecting to simply doesn't support IPv6. If I substitute host
value with google.com everything works. I wish the error message was more descriptive.
Upvotes: 1