Skip to content

[feat] mark host ipv6 empty #517

Description

@loynoir

feat

mark host ipv6 empty

background

https://gitlab.archlinux.org/archlinux/infrastructure/-/work_items/858

There is scenario that ipv4 works, but ipv6 not work.

problem

This could be workarouond by

  • adding unreachable ipv6 above reachable ipv4
::1 archive.archlinux.org

49.12.124.107 archive.archlinux.org
2a01:4f8:242:5614::2 archive.archlinux.org
$ curl -vfsSL https://archive.archlinux.org
...
* IPv6: ::1, 2a01:4f8:242:5614::2
* IPv4: 49.12.124.107
...

But this is not perfect.

curl will

  • try unreachable ::1 port 443 first

  • wait failure

  • then try reachable ipv4 port 443

For better performance, first two steps should always avoid.

Would be nice to mark host ipv6 empty.

So, curl will directly try reachable ipv4 port 443

$ curl -vfsSL https://archive.archlinux.org
...
* IPv6: (none)
* IPv4: 49.12.124.107

workaround

adding unreachable ipv6 above reachable ipv4

dnsproxy \
  --config-path /path/to/custom/config \
  --hosts-file-enabled \
  --hosts-files /path/to/custom/hosts

/path/to/custom/hosts

::1 archive.archlinux.org

49.12.124.107 archive.archlinux.org
2a01:4f8:242:5614::2 archive.archlinux.org

On system prefer ipv6, curl will

  • try ipv6 ::1, ipv6 failed as expected
  • try ipv4 49.12.124.107, ipv4 ok as expected
$ curl -vfsSL https://archive.archlinux.org
* Host archive.archlinux.org:443 was resolved.
* IPv6: ::1, 2a01:4f8:242:5614::2
* IPv4: 49.12.124.107
*   Trying [::1]:443...
* connect to ::1 port 443 from ::1 port 52220 failed: Connection refused
*   Trying 49.12.124.107:443...
*   Trying [2a01:4f8:242:5614::2]:443...
...
* Established connection to archive.archlinux.org (49.12.124.107 port 443) from ...
...

suggest

mark host ipv6 empty

dnsproxy \
  --config-path /path/to/custom/config

/path/to/custom/config

hosts-file-enabled: true
hosts-files: /path/to/custom/hosts
hosts-empty:
  ipv6:
    - archive.archlinux.org

/path/to/custom/hosts

49.12.124.107 archive.archlinux.org
2a01:4f8:242:5614::2 archive.archlinux.org
$ curl -vfsSL https://archive.archlinux.org
* Host archive.archlinux.org:443 was resolved.
* IPv6: (none)
* IPv4: 49.12.124.107
*   Trying 49.12.124.107:443...
...
* Established connection to archive.archlinux.org (49.12.124.107 port 443) from ...
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions