0

如果我坚持以下默认设置,我的 postgresql 连接将有效:

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     md5
host    replication     all             127.0.0.1/32            md5
host    replication     all             ::1/128                 md5

现在我正在尝试允许同一家庭中的另一台计算机连接到当前服务器,并尝试一些设置。我所做的更改之一是对 IPv6 本地连接线,改用我的临时 IPv6 地址,因为如果我在 google 上检查我的 ip 是什么,那就是那里显示的 ip。

# IPv6 local connections:
host    all             all             1111:2222:a111:a11:b222:11a:abcd:efgs                md5

(注意这里使用的ip只是一个例子

但是,这会导致 postgresql 日志中出现以下错误:

2021-11-21 12:26:40.508 PST [10356] LOG:  starting PostgreSQL 13.3, compiled by Visual C++ build 1914, 64-bit
2021-11-21 12:26:40.515 PST [10356] LOG:  listening on IPv6 address "::", port 5432
2021-11-21 12:26:40.517 PST [10356] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2021-11-21 12:26:40.529 PST [10356] LOG:  invalid IP mask "md5": Unknown host
2021-11-21 12:26:40.529 PST [10356] CONTEXT:  line 88 of configuration file "C:/current_dir/PostgresSQL/data/pg_hba.conf"
2021-11-21 12:26:40.531 PST [10356] FATAL:  could not load pg_hba.conf
2021-11-21 12:26:40.533 PST [10356] LOG:  database system is shut down

请问造成这个错误的可能原因是什么?非常感谢。

4

1 回答 1

0

您不能在 中指定客户端 IP 地址pg_hba.conf,您必须指定 CIDR。根据文档

IP 地址范围使用标准数字表示法指定范围的起始地址,然后是斜杠 ( /) 和 CIDR 掩码长度。掩码长度表示必须匹配的客户端 IP 地址的高位位数。在给定的 IP 地址中,其右侧的位应为零。/IP 地址、和 CIDR 掩码长度之间不得有任何空格。

所以条目必须看起来像:

host  all  all  fe80::8b0a:b1bf:4ce5:9a4a/128  md5
于 2021-11-22T03:11:42.753 回答