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

Client Configured with IPv6 Address not able to Connect to Server(Configured with IPv6 Address) Using Hostname #2084

Closed
srikr opened this issue Jul 5, 2021 · 9 comments
Labels

Comments

@srikr
Copy link

srikr commented Jul 5, 2021

Client Configured with IPv6 Address not able to Connect to Server(Configured with IPv6 Address) Using Hostname
Example:
get https://[IPv6 Address]:443/ -- Works Fine
get https://hostname:443/ -- Not Working Fine

Environment

  • k6 version: v0.31.1
  • OS and version: "16.04.6 LTS (Xenial Xerus)"
  • Docker version and image, if applicable:

Expected Behavior

get https://[IPv6 Address]:443/ -- Works Fine
get https://hostname:443/ -- Should also Work Fine with IPv6 address

Actual Behavior

get https://[IPv6 Address]:443/ -- Works Fine
get https://hostname:443/ -- Not Working Fine

Steps to Reproduce the Problem

  1. Have this Info Configured in Java Script File
    root@MyClient1:/home/testuser# cat K6JS/http1.js
import http from "k6/http";
import { check } from "k6";

export default function() {
var param = {
  headers: {"Accept": "text/html"}
};
check(http.get("https://myserver.test.net:443/get1.php?name=test", param), {
  "status is 200": (r) => r.status == 200,
  "protocol is HTTP/1.1": (r) => r.proto == "HTTP/1.1",
});
}

and run the following command:

k6 run --insecure-skip-tls-verify -d 900s --local-ips "<List of IPv6>" --no-connection-reuse --no-vu-connection-reuse -u 500  /home/aviuser/K6JS/http1.js
  1. Resulting in Connection Error
@srikr srikr added the bug label Jul 5, 2021
@mstoykov
Copy link
Collaborator

mstoykov commented Jul 6, 2021

Hi @srikr,

Do I understand correctly that the server has both a v4 and v6 IP?

If so you will need to tell k6 to prefer (or only) resolve ipv6 instead of the default ipv4. That can be done with the dns option as in --dns select=onlyIPv6 and adding this to the command line.

Previous related discussions in #1733 and linked comments.

As I argue in this comment it will make sense for k6 to change the policy per VU if the VU gets a specific IP as there is no way for a VU with only an ipv6 address to make a request to an ipv4 one so there is no point in resolving and giving it an ipv4 address. Although that can as well be confusing if you are told that it couldn't resolve a host but you can with hsot and it just returns you an ipv4/ipv6 address only but you need the other ... so 🤷

@srikr
Copy link
Author

srikr commented Jul 6, 2021

Hi @mstoykov
Thanks for the quick response. Yes your understanding is correct I have server configured for both IPv4 and IPv6 Address. I quickly tried the DNS solution(--dns "ttl=inf,select=first,policy=onlyIPv6") what you have suggested it did not work though, probably because I think you expect hostname to be resolved using DNS but in my case I have hardcoded the Hostname to IPv6 Mapping in /etc/hosts file of Linux
Also is it not possible to do some thing like below:
If --local_ips option is configured as IPv6 then url hostname should resolve to IPv6
if --local_ips option is configured or not configured then url hostname should resolve to default IPv4
Will that not work out, this way we need not bank on DNS Server always? I agree DNS is one option but I many a times hardcode IPs to avoid DNS Packets for Testing

-srikr

@mstoykov
Copy link
Collaborator

mstoykov commented Jul 6, 2021

Hmm, can you post the actual error you get ?

Also, can you try using the hosts option to set what it needs to be resolved to instead of /etc/hosts as I am not certain that works, although it should 🤔

@srikr
Copy link
Author

srikr commented Jul 6, 2021

This is the Error I am getting:

WARN[0005] Request Failed                                error="Get \"https://hostname:443/get1.php?name=aaa\": dial tcp: address [IPv6 Address]:0: no suitable address found"

This is what I tried which also did not work, I am not sure am I configuring the hosts incorrectly:

import http from "k6/http";
import { check } from "k6";

export default function() {
var param = {
  headers: {"Accept": "text/html"}
};
var options = {
  hosts: {
    'hostname': 'ipv6 address'
  }
};
check(http.get("https://hostname:443/get1.php?name=aaa", param), {
  "status is 200": (r) => r.status == 200,
  "protocol is HTTP/1.1": (r) => r.proto == "HTTP/1.1",
});
}

@srikr
Copy link
Author

srikr commented Jul 6, 2021

I also tried export which also did not work, Not sure what am I missing here
export let options = {
hosts: {
'hostname': 'IPv6 Address'
}
};
Also I having Configured Multiple IPv6 Address in one of the Interface which is what I want to use as Source.
ens192 Link encap:Ethernet HWaddr 00:50:56:95:9d:10
inet addr:IPv4Address Bcast:BroadCast Mask:SubnetMask
inet6 addr: IPv6Address1/64 Scope:Global
inet6 addr: IPv6Address2/64 Scope:Global
inet6 addr: IPv6Address3/64 Scope:Global
inet6 addr: IPv6Address4/64 Scope:Global
inet6 addr: IPv6Address5/64 Scope:Global
inet6 addr: IPv6Address6/64 Scope:Global
inet6 addr: IPv6Address7/64 Scope:Global
inet6 addr: IPv6Address8/64 Scope:Global
inet6 addr: IPv6Address9/64 Scope:Global
inet6 addr: IPv6Address10/64 Scope:Global
inet6 addr: IPv6Address11/64 Scope:Global
inet6 addr: IPv6Address12/64 Scope:Global
inet6 addr: IPv6Address13/64 Scope:Global
inet6 addr: IPv6Address14/64 Scope:Global
inet6 addr: IPv6Address15/64 Scope:Global
inet6 addr: IPv6Address16/64 Scope:Global
inet6 addr: IPv6Address17/64 Scope:Global
inet6 addr: IPv6Address18/64 Scope:Global
inet6 addr: IPv6Address19/64 Scope:Global
inet6 addr: IPv6Address20/64 Scope:Global
inet6 addr: IPv6Address21/64 Scope:Global
inet6 addr: IPv6Address22/64 Scope:Global
inet6 addr: LinkLocalIPv6Address/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:722267990 errors:0 dropped:1861 overruns:0 frame:0
TX packets:154852486404 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:113589083971 (113.5 GB) TX bytes:11480078646980 (11.4 TB)

@mstoykov
Copy link
Collaborator

mstoykov commented Jul 6, 2021

This is what I tried which also did not work, I am not sure am I configuring the hosts incorrectly:

you need to export it and it to be outside the export default function as in

import http from "k6/http";
import { check } from "k6";

export var options = { // here in the global scope
  hosts: {
    'hostname': 'ipv6 address'
  }
};
export default function() {
var param = {
  headers: {"Accept": "text/html"}
};
check(http.get("https://hostname:443/get1.php?name=aaa", param), {
  "status is 200": (r) => r.status == 200,
  "protocol is HTTP/1.1": (r) => r.proto == "HTTP/1.1",
});
}

@srikr
Copy link
Author

srikr commented Jul 6, 2021

Thanks @mstoykov the above host configuration works fine.

@srikr

@mstoykov
Copy link
Collaborator

mstoykov commented Jul 6, 2021

@srikr

I did just test /etc/hosts as well and it does work for me in the same way the hosts option works.
So you should not even need the hosts option, but probably need to check why /etc/hosts is not working for you.

Also is it not possible to do some thing like below:
If --local_ips option is configured as IPv6 then url hostname should resolve to IPv6
if --local_ips option is configured or not configured then url hostname should resolve to default IPv4

This is basically what is said in #1733 more or less and is what I knew will be a problem in this comment.

@mstoykov mstoykov closed this as completed Jul 6, 2021
@srikr
Copy link
Author

srikr commented Jul 6, 2021

I have two entries in /etc/hosts file, one for IPv4 and one for IPv6 which is why I think it is not working. I presume k6 is not able to distinguish between two IPs as it sees two entries in /etc/hosts file.
Anyways I am fine as long as hosts option in k6 java script file works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants