【发布时间】:2020-09-30 06:46:16
【问题描述】:
我将我的 Ubuntu 20.04 服务器配置为使用 nestat 拥有多个 IPv6 地址,如下所示:
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
我可以在ifconfig 的输出中看到这些地址,当我在同一台服务器上使用ping6 对它们执行 ping 操作时,它可以正常工作。
现在我正在尝试使用localAddress 绑定到这些 IPv6 地址并发送 HTTP GET 请求:
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)
})
这会导致以下错误:
Error: bind EINVAL xxxx:xxxx:xxxx:xxxx::1
我了解此错误可能意味着多种情况:
socket已经绑定了一个地址,协议没有 支持绑定新地址;或套接字已关闭。
我可以做些什么来调试这个?
【问题讨论】:
标签: node.js networking ipv6