Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: pure Go DNS resolver uses IPv4 addresses when only IPv6 present #8573

Closed
vtolstov opened this issue Aug 22, 2014 · 12 comments

Comments

Projects
None yet
4 participants
@vtolstov
Copy link

commented Aug 22, 2014

go 1.3.1

Default http.client in net/go without CGO tries to connect to ipv4 hosts if no ipv4
address exists in system (pure ipv6 environment). 

Steps to reproduce issue

1. Delete all ipv4 addresses in system
2. build example program that tries to connect to google.com without CGO
3. run and see, that it tries to connect firstly to ipv4 address.

What happened?
failed to connect to google.com

What should have happened instead?
succeseful connect to google.com

Please provide any additional information below.
DualStack switch in transport does not helps.
@bradfitz

This comment has been minimized.

Copy link
Member

commented Aug 22, 2014

Comment 1:

Owner changed to @mikioh.

Status changed to Accepted.

@mikioh

This comment has been minimized.

Copy link
Contributor

commented Aug 22, 2014

Comment 2:

thanks for the report. not sure the reason but seems like this is a linux specific issue
because i failed to reproduce this on darwin and freebsd; i mean the attached perfectly
works on my ipv6 access using dhcpv6-pd+ipv6 over ethernet.
so could you please let us know that;
nut: node under the test
nut operating system configuration:
- kernel version, distro name
- /etc/resolv.conf
- /etc/gai.conf
- /etc/hosts
- outputs of ip command // we need to know all running states of ipv6 routing stuff
- outputs of ip6tables command // we need to know all running states if nptv6 stuff
your environment network configuration:
- topology chart
- address assignment (per link/interface)
what happens when you run the following commands on the nut:
- ping6 www.example.com
- ping6 www.google.com
- go run dualstackhttp.go

Attachments:

  1. dualstackhttp.go (1388 bytes)
@mikioh

This comment has been minimized.

Copy link
Contributor

commented Aug 22, 2014

Comment 3:

> what happens when you run the following commands on the nut:
> - ping6 www.example.com
> - ping6 www.google.com
> - go run dualstackhttp.go
plus, packet captures for above on nut's ipv6 access interface please.
@vtolstov

This comment has been minimized.

Copy link
Author

commented Sep 2, 2014

Comment 4:

nut config: kernel 3.14.17
/etc/resolv.conf:
nameserver 2001:4860:4860::8888
nameserver 2001:4860:4860::8844
/etc/gai.conf: - not exists
/etc/hosts: - not exists
ip a s: 
lo
eth0 inet6: fed0::5054:ff:fe12:3456/64 scope site tentative dynamic
     inet6: fe80::5054:ff:fe12:3456/64 scope link
ipv4 addresses absent
iptables: not installed and rules are empty
my host environment network config:
ip a s:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
group default qlen 1000
    link/ether 74:d0:2b:97:16:62 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.101/24 brd 192.168.1.255 scope global dynamic enp3s0
       valid_lft 914sec preferred_lft 914sec
    inet6 2a04:ac01:1:1:76d0:2bff:fe97:1662/64 scope global dynamic 
       valid_lft 86270sec preferred_lft 14270sec
    inet6 fe80::76d0:2bff:fe97:1662/64 scope link 
       valid_lft forever preferred_lft forever
ip r s:
default via 192.168.1.1 dev enp3s0 
default via 192.168.1.1 dev enp3s0  metric 1024 
192.168.1.0/24 dev enp3s0  proto kernel  scope link  src 192.168.1.101 
192.168.1.1 dev enp3s0  scope link  metric 1024 
ip -6 r s:
2a04:ac01:1:1::/64 dev enp3s0  proto kernel  metric 256  expires 86255sec
fe80::/64 dev enp3s0  proto kernel  metric 256 
fe80::/64 dev dummy0  proto kernel  metric 256 
default via fe80::218:feff:fe89:f9a6 dev enp3s0  proto ra  metric 1024  expires 1655sec
I can't provide info about pings because qemu slirp network stack does not handle now
icmpv6. But i'm provide tcpdump output when running dualstackhttp.go:
15:27:57.003524 IP6 (hlim 64, next-header UDP (17) payload length: 41)
2a04:ac01:1:1:76d0:2bff:fe97:1662.56855 > 2001:4860:4860::8888.53: [udp sum ok] 3900+
A? www.example.com. (33)
15:27:57.008297 IP6 (hlim 56, next-header UDP (17) payload length: 57)
2001:4860:4860::8888.53 > 2a04:ac01:1:1:76d0:2bff:fe97:1662.56855: [udp sum ok] 3900
q: A? www.example.com. 1/0/0 www.example.com. [2h15m57s] A 93.184.216.119 (49)
15:27:57.009057 IP6 (hlim 64, next-header UDP (17) payload length: 41)
2a04:ac01:1:1:76d0:2bff:fe97:1662.60175 > 2001:4860:4860::8888.53: [udp sum ok] 8555+
AAAA? www.example.com. (33)
15:27:57.013859 IP6 (hlim 56, next-header UDP (17) payload length: 69)
2001:4860:4860::8888.53 > 2a04:ac01:1:1:76d0:2bff:fe97:1662.60175: [udp sum ok] 8555
q: AAAA? www.example.com. 1/0/0 www.example.com. [2h18m36s] AAAA
2606:2800:220:6d:26bf:1447:1097:aa7 (61)
15:27:57.015722 IP6 (hlim 64, next-header TCP (6) payload length: 40)
2a04:ac01:1:1:76d0:2bff:fe97:1662.38366 > 2606:2800:220:6d:26bf:1447:1097:aa7.80:
Flags [S], cksum 0x4a8f (correct), seq 3988499717, win 28800, options [mss
1440,sackOK,TS val 82453122 ecr 0,nop,wscale 7], length 0
15:27:57.156937 IP6 (hlim 52, next-header TCP (6) payload length: 32)
2606:2800:220:6d:26bf:1447:1097:aa7.80 > 2a04:ac01:1:1:76d0:2bff:fe97:1662.38366:
Flags [S.], cksum 0xeb18 (correct), seq 2866496700, ack 3988499718, win 12200, options
[mss 1220,nop,nop,sackOK,nop,wscale 6], length 0
15:27:57.156988 IP6 (hlim 64, next-header TCP (6) payload length: 20)
2a04:ac01:1:1:76d0:2bff:fe97:1662.38366 > 2606:2800:220:6d:26bf:1447:1097:aa7.80:
Flags [.], cksum 0x59c1 (correct), seq 1, ack 1, win 225, length 0
15:27:57.158974 IP6 (hlim 64, next-header TCP (6) payload length: 142)
2a04:ac01:1:1:76d0:2bff:fe97:1662.38366 > 2606:2800:220:6d:26bf:1447:1097:aa7.80:
Flags [P.], cksum 0xaa94 (correct), seq 1:123, ack 1, win 225, length 122
15:27:57.301552 IP6 (hlim 52, next-header TCP (6) payload length: 20)
2606:2800:220:6d:26bf:1447:1097:aa7.80 > 2a04:ac01:1:1:76d0:2bff:fe97:1662.38366:
Flags [.], cksum 0x5969 (correct), seq 1, ack 123, win 191, length 0
15:27:57.302170 IP6 (hlim 52, next-header TCP (6) payload length: 498)
2606:2800:220:6d:26bf:1447:1097:aa7.80 > 2a04:ac01:1:1:76d0:2bff:fe97:1662.38366:
Flags [P.], cksum 0xbd52 (correct), seq 1:479, ack 123, win 191, length 478
15:27:57.302195 IP6 (hlim 64, next-header TCP (6) payload length: 20)
2a04:ac01:1:1:76d0:2bff:fe97:1662.38366 > 2606:2800:220:6d:26bf:1447:1097:aa7.80:
Flags [.], cksum 0x5760 (correct), seq 123, ack 479, win 234, length 0
15:27:57.303367 IP6 (hlim 64, next-header TCP (6) payload length: 20)
2a04:ac01:1:1:76d0:2bff:fe97:1662.38366 > 2606:2800:220:6d:26bf:1447:1097:aa7.80:
Flags [F.], cksum 0x575f (correct), seq 123, ack 479, win 234, length 0
15:27:57.303619 IP6 (hlim 64, next-header UDP (17) payload length: 41)
2a04:ac01:1:1:76d0:2bff:fe97:1662.58225 > 2001:4860:4860::8888.53: [udp sum ok]
33820+ A? www.example.com. (33)
15:27:57.308307 IP6 (hlim 56, next-header UDP (17) payload length: 57)
2001:4860:4860::8888.53 > 2a04:ac01:1:1:76d0:2bff:fe97:1662.58225: [udp sum ok] 33820
q: A? www.example.com. 1/0/0 www.example.com. [2h16m39s] A 93.184.216.119 (49)
15:27:57.308736 IP6 (hlim 64, next-header UDP (17) payload length: 41)
2a04:ac01:1:1:76d0:2bff:fe97:1662.50099 > 2001:4860:4860::8888.53: [udp sum ok]
64792+ AAAA? www.example.com. (33)
15:27:57.313551 IP6 (hlim 56, next-header UDP (17) payload length: 69)
2001:4860:4860::8888.53 > 2a04:ac01:1:1:76d0:2bff:fe97:1662.50099: [udp sum ok] 64792
q: AAAA? www.example.com. 1/0/0 www.example.com. [2h18m19s] AAAA
2606:2800:220:6d:26bf:1447:1097:aa7 (61)
15:27:57.314726 IP6 (hlim 64, next-header UDP (17) payload length: 40)
2a04:ac01:1:1:76d0:2bff:fe97:1662.44921 > 2001:4860:4860::8888.53: [udp sum ok]
34084+ A? www.google.com. (32)
15:27:57.321212 IP6 (hlim 56, next-header UDP (17) payload length: 120)
2001:4860:4860::8888.53 > 2a04:ac01:1:1:76d0:2bff:fe97:1662.44921: [udp sum ok] 34084
q: A? www.google.com. 5/0/0 www.google.com. [4m59s] A 74.125.232.49, www.google.com.
[4m59s] A 74.125.232.48, www.google.com. [4m59s] A 74.125.232.50, www.google.com.
[4m59s] A 74.125.232.51, www.google.com. [4m59s] A 74.125.232.52 (112)
15:27:57.321628 IP6 (hlim 64, next-header UDP (17) payload length: 40)
2a04:ac01:1:1:76d0:2bff:fe97:1662.58601 > 2001:4860:4860::8888.53: [udp sum ok]
49578+ AAAA? www.google.com. (32)
15:27:57.328248 IP6 (hlim 56, next-header UDP (17) payload length: 68)
2001:4860:4860::8888.53 > 2a04:ac01:1:1:76d0:2bff:fe97:1662.58601: [udp sum ok] 49578
q: AAAA? www.google.com. 1/0/0 www.google.com. [4m59s] AAAA 2a00:1450:4010:c07::6a (60)
15:27:57.333850 IP6 (hlim 64, next-header TCP (6) payload length: 40)
2a04:ac01:1:1:76d0:2bff:fe97:1662.41281 > 2a00:1450:4010:c07::6a.80: Flags [S], cksum
0xe3c9 (correct), seq 3233632541, win 28800, options [mss 1440,sackOK,TS val 82453201
ecr 0,nop,wscale 7], length 0
15:27:57.338377 IP6 (hlim 56, next-header TCP (6) payload length: 40)
2a00:1450:4010:c07::6a.80 > 2a04:ac01:1:1:76d0:2bff:fe97:1662.41281: Flags [S.],
cksum 0x5aa7 (correct), seq 1913863658, ack 3233632542, win 42594, options [mss
1386,sackOK,TS val 3395410182 ecr 82453201,nop,wscale 6], length 0
15:27:57.338401 IP6 (hlim 64, next-header TCP (6) payload length: 32)
2a04:ac01:1:1:76d0:2bff:fe97:1662.41281 > 2a00:1450:4010:c07::6a.80: Flags [.], cksum
0x2ea9 (correct), seq 1, ack 1, win 225, options [nop,nop,TS val 82453202 ecr
3395410182], length 0
15:27:57.339516 IP6 (hlim 64, next-header TCP (6) payload length: 141)
2a04:ac01:1:1:76d0:2bff:fe97:1662.41281 > 2a00:1450:4010:c07::6a.80: Flags [P.],
cksum 0x47e4 (correct), seq 1:110, ack 1, win 225, options [nop,nop,TS val 82453203 ecr
3395410182], length 109
15:27:57.344315 IP6 (hlim 56, next-header TCP (6) payload length: 32)
2a00:1450:4010:c07::6a.80 > 2a04:ac01:1:1:76d0:2bff:fe97:1662.41281: Flags [.], cksum
0x2c7e (correct), seq 1, ack 110, win 664, options [nop,nop,TS val 3395410188 ecr
82453203], length 0
15:27:57.345704 IP6 (hlim 56, next-header TCP (6) payload length: 538)
2a00:1450:4010:c07::6a.80 > 2a04:ac01:1:1:76d0:2bff:fe97:1662.41281: Flags [P.],
cksum 0x83f2 (correct), seq 1:507, ack 110, win 664, options [nop,nop,TS val 3395410189
ecr 82453203], length 506
15:27:57.345720 IP6 (hlim 64, next-header TCP (6) payload length: 32)
2a04:ac01:1:1:76d0:2bff:fe97:1662.41281 > 2a00:1450:4010:c07::6a.80: Flags [.], cksum
0x2c30 (correct), seq 110, ack 507, win 234, options [nop,nop,TS val 82453204 ecr
3395410189], length 0
15:27:57.346271 IP6 (hlim 64, next-header UDP (17) payload length: 40)
2a04:ac01:1:1:76d0:2bff:fe97:1662.50042 > 2001:4860:4860::8888.53: [udp sum ok]
55241+ A? www.google.com. (32)
15:27:57.385470 IP6 (hlim 56, next-header UDP (17) payload length: 120)
2001:4860:4860::8888.53 > 2a04:ac01:1:1:76d0:2bff:fe97:1662.50042: [udp sum ok] 55241
q: A? www.google.com. 5/0/0 www.google.com. [4m59s] A 74.125.232.51, www.google.com.
[4m59s] A 74.125.232.49, www.google.com. [4m59s] A 74.125.232.48, www.google.com.
[4m59s] A 74.125.232.52, www.google.com. [4m59s] A 74.125.232.50 (112)
15:27:57.385903 IP6 (hlim 64, next-header UDP (17) payload length: 40)
2a04:ac01:1:1:76d0:2bff:fe97:1662.43470 > 2001:4860:4860::8888.53: [udp sum ok]
57033+ AAAA? www.google.com. (32)
15:27:57.392737 IP6 (hlim 56, next-header UDP (17) payload length: 68)
2001:4860:4860::8888.53 > 2a04:ac01:1:1:76d0:2bff:fe97:1662.43470: [udp sum ok] 57033
q: AAAA? www.google.com. 1/0/0 www.google.com. [4m59s] AAAA 2a00:1450:4010:c04::67 (60)
15:27:57.393766 IP6 (hlim 64, next-header UDP (17) payload length: 40)
2a04:ac01:1:1:76d0:2bff:fe97:1662.44793 > 2001:4860:4860::8888.53: [udp sum ok]
60892+ A? www.google.com. (32)
15:27:57.400446 IP6 (hlim 56, next-header UDP (17) payload length: 120)
2001:4860:4860::8888.53 > 2a04:ac01:1:1:76d0:2bff:fe97:1662.44793: [udp sum ok] 60892
q: A? www.google.com. 5/0/0 www.google.com. [4m59s] A 74.125.232.49, www.google.com.
[4m59s] A 74.125.232.50, www.google.com. [4m59s] A 74.125.232.52, www.google.com.
[4m59s] A 74.125.232.51, www.google.com. [4m59s] A 74.125.232.48 (112)
15:27:57.400834 IP6 (hlim 64, next-header UDP (17) payload length: 40)
2a04:ac01:1:1:76d0:2bff:fe97:1662.52334 > 2001:4860:4860::8888.53: [udp sum ok]
62053+ AAAA? www.google.com. (32)
15:27:57.408430 IP6 (hlim 56, next-header UDP (17) payload length: 68)
2001:4860:4860::8888.53 > 2a04:ac01:1:1:76d0:2bff:fe97:1662.52334: [udp sum ok] 62053
q: AAAA? www.google.com. 1/0/0 www.google.com. [4m59s] AAAA 2a00:1450:4010:c07::68 (60)
15:27:57.410236 IP6 (hlim 64, next-header TCP (6) payload length: 32)
2a04:ac01:1:1:76d0:2bff:fe97:1662.41281 > 2a00:1450:4010:c07::6a.80: Flags [F.],
cksum 0x2c1f (correct), seq 110, ack 507, win 234, options [nop,nop,TS val 82453220 ecr
3395410189], length 0
15:27:57.414835 IP6 (hlim 56, next-header TCP (6) payload length: 32)
2a00:1450:4010:c07::6a.80 > 2a04:ac01:1:1:76d0:2bff:fe97:1662.41281: Flags [F.],
cksum 0x2a2a (correct), seq 507, ack 111, win 664, options [nop,nop,TS val 3395410259
ecr 82453220], length 0
15:27:57.414865 IP6 (hlim 64, next-header TCP (6) payload length: 32)
2a04:ac01:1:1:76d0:2bff:fe97:1662.41281 > 2a00:1450:4010:c07::6a.80: Flags [.], cksum
0x2bd6 (correct), seq 111, ack 508, win 234, options [nop,nop,TS val 82453222 ecr
3395410259], length 0
15:27:57.444870 IP6 (hlim 52, next-header TCP (6) payload length: 20)
2606:2800:220:6d:26bf:1447:1097:aa7.80 > 2a04:ac01:1:1:76d0:2bff:fe97:1662.38366:
Flags [F.], cksum 0x5789 (correct), seq 479, ack 124, win 191, length 0
15:27:57.444897 IP6 (hlim 64, next-header TCP (6) payload length: 20)
2a04:ac01:1:1:76d0:2bff:fe97:1662.38366 > 2606:2800:220:6d:26bf:1447:1097:aa7.80:
Flags [.], cksum 0x575e (correct), seq 124, ack 480, win 234, length 0

Attachments:

  1. shot-2014-09-02_15-26-12.jpg (146893 bytes)
@vtolstov

This comment has been minimized.

Copy link
Author

commented Sep 2, 2014

Comment 5:

Screenshot above displays output from dualstackhttp.go
@mikioh

This comment has been minimized.

Copy link
Contributor

commented Sep 3, 2014

Comment 6:

can you please attach an entire raw pcap data using tcpdump; e.g., tcpdump -i enp3s0 -w
<filename> and make sure you are using go1.3.1, not go1.3. thanks.
> I can't provide info about pings because qemu...
you can write your own ping-like stuff by using $GOROOT/src/pkg/net/mockicmp_test.go or
go.net/ipv6/mockicmp_test.go if you have a spare time.
@mikioh

This comment has been minimized.

Copy link
Contributor

commented Sep 3, 2014

Comment 7:

and... sorry i'm not a psychic. please show us the output of "ip link show" and
/etc/ip6tables.rules too.
@mikioh

This comment has been minimized.

Copy link
Contributor

commented Sep 3, 2014

Comment 8:

it's obvious that;
- go application shows that it used a source address from "fed0::/64" prefix on eth0?
- but tcpdump displays that your node used a source address form "2a04:ac01:1:1::/64"
prefix on enp3s0
- that means that your paravirtualization environment using qemu (w/ or w/o kvm) does
something funny for ipv6 packet routing
looks like we need to make sure basic ipv6 packet routing functionality on your
paravirtualization environment first.
@mikioh

This comment has been minimized.

Copy link
Contributor

commented Sep 9, 2014

Comment 9:

Status changed to WaitingForReply.

@vtolstov

This comment has been minimized.

Copy link
Author

commented Sep 9, 2014

Comment 10:

I'm try to provide more clean env without qemu userspace network for ipv6 and recheck.
Please wait.
@mikioh

This comment has been minimized.

Copy link
Contributor

commented Sep 16, 2014

Comment 11:

Labels changed: added repo-main.

@mikioh

This comment has been minimized.

Copy link
Contributor

commented Oct 1, 2014

Comment 12:

hi,
i've just re-checked this issue on ipv6-only transport environment w/ non-vm bsd
variants and linux, and didn't see your issue. it's likely that your ipv6 routing
configuration issue on linux/kvm-qemu, though, i found another dual ip stack issue #8847.
anyway thanks for the report.

Status changed to Invalid.

This issue was closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.