Jigsaw-Code / outline-apps

Outline Client and Manager, developed by Jigsaw. Outline Manager makes it easy to create your own VPN server. Outline Client lets you share access to your VPN with anyone in your network, giving them access to the free and open internet.
https://getoutline.org/
Apache License 2.0
8.45k stars 1.37k forks source link

Properly prioritize between multiple network adapters on Windows #1235

Open xPROMSx opened 2 years ago

xPROMSx commented 2 years ago

Describe the bug Hello. I ran into a problem on windows 11. I use an outline client with one server and network on linux, iphone, ipad and have no problems. But if I connect to the server through windows 11 I get a long loading of sites. looks like a long dns server response. sometimes you have to wait more than 30 seconds before the site starts loading. however, if you use a different shadowsocks client, the problem disappears. I tried to reinstall all drivers and other manipulations to clean up the system. but nothing gives any result. page loading speed is slow only with the outline client. while speedtest shows normal speed.

To Reproduce Used window 11 with latest update

Expected behavior Fast loading sites like on Linux, iPhone or when using another shadowsocks client

Client System (please complete the following information):

Submit Feedback 00049408

jyyi1 commented 2 years ago

Hi @xPROMSx , thanks for reporting the issue. Could you please double confirm the DNS server on your device using https://whatsmydnsserver.com/ ? Just wanna make sure that was the bottleneck of the performance issue here. Thanks.

xPROMSx commented 2 years ago

@jyyi1 Hello. After many attempts, the results were: 1)172.70.241.31 2)172.70.241.31 3)2620:171:f8:f0::240 Country US

and dns

dem000n commented 2 years ago

Hello. I have same problem on Windows 10 too. Using the same outline server i have no issues on android and macOS. But on my windows 10 machines i have 5-10 seconds delay when loading any site for the first time. After that, if i open same site again, it opens without delay. But if i do "ipconfig /flushdns" and restart browser i have the delay again. So i presume there are some problem with dns using outline client.

jyyi1 commented 2 years ago

Thanks @xPROMSx and @dem000n for the information. While we are still investigating the root cause of this issue, would you please try to restart the machine to see whether the problem still exists? we are sorry for any inconvenience this may have caused you.

xPROMSx commented 2 years ago

Thanks @jyyi1 for your work. Unfortunately, restarting the computer, reinstalling the application, reinstalling TAP driver and many other actions that I tried to do do not bring the expected result.

hekarroko commented 2 years ago

Hello, @jyyi1 ! I run into the same problem as others described. It's been going for several months, but I don't remember, when it started - probably there were no delay earlier.

hekarroko commented 2 years ago

I can provide more specific information (ex. iperf logs) also, by your request, if you need

Suckaballs commented 2 years ago

I got this issue on 2 pc's. The first one had this problem because of tunnel bear software network adapter. The second one had two adapters bridged in control panel (not outline-tap0). If I disable this bridge, outline starts resolving DNS just fine. Bug behaved exactly the same on both windows machines - outline works, ping and bandwidth are ideal, but "Resolve-DnsName -name google.com" in Powershell takes a lot of time.

hekarroko commented 2 years ago

Any updates? How can we help to resolve this issue?

chuchenting commented 2 years ago

Any updates? How can we help to resolve this issue?

Still waiting for the solutions. Connections on Windows 11 are still much slower than android until now.

jyyi1 commented 2 years ago

Hi @hekarroko @chuchenting , sorry about the late response but we are still not able to reproduce this problem. But I can provide more information, our tap device will hard code 1.1.1.1 as the DNS server, I am not sure whether changing that could help this issue (please notice that this DNS address might be reset to 1.1.1.1 during update):

image
upanasiuk commented 1 year ago

As a workaround one may enable DoH for browser (Chrome, Firefox supported) or in Windows 11 Settings for only outline-tap0 interface. IMO when enabled in browser it's less laggy.

fortuna commented 1 year ago

I believe the Windows client does DNS over TCP, which may affect the performance. It would be great if you could run Wireshark to confirm that. The fix may be enabling DNS over UDP for Windows.

regzon commented 1 year ago

I have the same issue - loading a website takes a long time, but reloading or loading it a bit later is fast. So it looks like as long as the DNS cache is used everything works fast.

Also, I found that the ping utility behaves the same:

Pinging an IP address is always fast.

A capture of packets of the outline-tap0 interface using Wireshark shows the following:

When the VPN is diconnected the ping works fast.

@jyyi1 hope this'll help!


regzon commented 1 year ago

By the way, nslookup works fine.

regzon commented 1 year ago

Update: I've tested Outline on two different PCs both with WIndows 11 installed - when Internet is connected via Ethernet the issue exists, when WiFi is used the VPN works fine.

PCs have different Ethernet adapters but they were connected to the same router. I'll test it with a different router later.

regzon commented 1 year ago

I was able to fix this issue by setting the InterfaceMetric value for the Ethernet interface greater than it is for the outline-tap0 interface. I don't really know if it'll break something in the future. I hope Outline Client will do something like that automatically.


I've used the following command to list all interfaces along with their InterfaceMetric:

Get-NetIPInterface

And this command for setting a metric value:

Set-NetIPInterface -InterfaceIndex 20 -InterfaceMetric 45

20 is an index for my Ethernet interface, and 45 is a new value for the metric.

jyyi1 commented 1 year ago

Thanks @regzon for providing the detailed information. We will take a look at this configuration in the future.

fortuna commented 1 year ago

Won’t this favor Ethernet over tun and leak traffic? If traffic is leaking, it will be faster.

On Fri, Jul 21, 2023 at 6:32 PM Andrey Volkov @.***> wrote:

I was able to fix this issue by setting the InterfaceMetric value for the Ethernet interface greater than it is for the outline-tap0 interface. I don't really know if it'll break something in the future. I hope Outline Client will do something like that automatically.

I've used the following command to list all interfaces along with their InterfaceMetric:

Get-NetIPInterface

And this command for setting a metric value:

Set-NetIPInterface -InterfaceIndex 20 -InterfaceMetric 45

20 is an index for my Ethernet interface, and 45 is a new value for the metric.

— Reply to this email directly, view it on GitHub https://github.com/Jigsaw-Code/outline-client/issues/1235#issuecomment-1646301296, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA3XHOG3ESKNTEBCEJQN3TXRL7QZANCNFSM5SC2U7XQ . You are receiving this because you commented.Message ID: @.***>

regzon commented 1 year ago

Hi, @fortuna. Greater metric means less priority. So in my case I'm explicitly telling Windows that the Ethernet interface is less prioritized than the VPN's one. Also, Wireshark shows that data flows through the VPN connection.

Probably, there's a conflict between two interfaces when the metric is not set explicitly (the metric is the same for both interfaces by default). And in this case there could be a data leak indeed. I'll check with Wireshark next week.

comingAlive commented 1 year ago

I was able to fix this issue by setting the InterfaceMetric value for the Ethernet interface greater than it is for the outline-tap0 interface. I don't really know if it'll break something in the future. I hope Outline Client will do something like that automatically.

I've used the following command to list all interfaces along with their InterfaceMetric:

Get-NetIPInterface

And this command for setting a metric value:

Set-NetIPInterface -InterfaceIndex 20 -InterfaceMetric 45

20 is an index for my Ethernet interface, and 45 is a new value for the metric.

@regzon tyvm.

The same workaround without the console: qqq

specoff commented 1 year ago

Thanks @regzon, @comingAlive, you helped me! Same problem on Windows 11.

garnatka commented 1 year ago

I confirm the problem on Windows 11. Method @regzon, @comingAlive works! Thanks.

ShizumaruRiya commented 1 year ago

Thanks @regzon, @comingAlive, Fixed the same problem on Windows 10 too. This problem bothered me for a long time and now all the delays are gone. Very smooth now.

garnatka commented 1 year ago

@jyyi1 Is this a safe solution?

dksr commented 1 year ago

I was able to fix this issue by setting the InterfaceMetric value for the Ethernet interface greater than it is for the outline-tap0 interface. I don't really know if it'll break something in the future. I hope Outline Client will do something like that automatically.

I've used the following command to list all interfaces along with their InterfaceMetric:

Get-NetIPInterface

And this command for setting a metric value:

Set-NetIPInterface -InterfaceIndex 20 -InterfaceMetric 45

20 is an index for my Ethernet interface, and 45 is a new value for the metric.

Ты гений, спасибо за решение.

jyyi1 commented 1 year ago

@jyyi1 Is this a safe solution?

Yes, the method provided by @regzon and @comingAlive is safe, please use it. Thanks.

garanovich commented 1 year ago

Can confirm it works with Windows 10. But for me Interface Metric must be <25 to this method work. Proton VPN used value 5. I set 5 too and it works.

soshin1337 commented 8 months ago

I was able to fix this issue by setting the InterfaceMetric value for the Ethernet interface greater than it is for the outline-tap0 interface. I don't really know if it'll break something in the future. I hope Outline Client will do something like that automatically.

I've used the following command to list all interfaces along with their InterfaceMetric:

Get-NetIPInterface

And this command for setting a metric value:

Set-NetIPInterface -InterfaceIndex 20 -InterfaceMetric 45

20 is an index for my Ethernet interface, and 45 is a new value for the metric.

thanks

soshin1337 commented 8 months ago

@jyyi1 it would be nice if it outline client fix it automatically

ParsaJR commented 8 months ago

I was able to fix this issue by setting the InterfaceMetric value for the Ethernet interface greater than it is for the outline-tap0 interface. I don't really know if it'll break something in the future. I hope Outline Client will do something like that automatically.

I've used the following command to list all interfaces along with their InterfaceMetric:

Get-NetIPInterface

And this command for setting a metric value:

Set-NetIPInterface -InterfaceIndex 20 -InterfaceMetric 45

20 is an index for my Ethernet interface, and 45 is a new value for the metric.

my God . I thought that this problem was due to network disturbances in the government. You are a savior .

FCTL3314 commented 2 months ago

I was able to fix this issue by setting the InterfaceMetric value for the Ethernet interface greater than it is for the outline-tap0 interface. I don't really know if it'll break something in the future. I hope Outline Client will do something like that automatically.

I've used the following command to list all interfaces along with their InterfaceMetric:

Get-NetIPInterface

And this command for setting a metric value:

Set-NetIPInterface -InterfaceIndex 20 -InterfaceMetric 45

20 is an index for my Ethernet interface, and 45 is a new value for the metric.

Great job @regzon! @jyyi1 Hope this will be implemented in Outline Client in the future.

FCTL3314 commented 2 months ago

I wrote a Python script that decrements the outline-tap0 interface by 1 relative to the Ethernet interface and fixes this problem. It can be compiled via PyInstaller for convenience. I'll be glad if it helps someone.

import re
import subprocess

def run_powershell_command(command: str) -> str:
    result = subprocess.run(
        ["powershell", "-Command", command], capture_output=True, text=True
    )
    if result.returncode != 0:
        raise Exception(result.stderr)
    return result.stdout

def get_interface_line(all_interfaces: str, interface_name: str) -> str | None:
    for i, line in enumerate(all_interfaces.splitlines()):
        if i in [0, 1, 2]:
            continue

        line_parts = line.split()
        try:
            if line_parts[1] == interface_name:
                return line
        except IndexError:
            continue
    return None

def press_enter_to_close() -> None:
    input("Press Enter to close...")

def main():
    ethernet_interface_name = "Ethernet"
    outline_interface_name = "outline-tap0"

    print("> Getting all network interfaces")
    all_interfaces = run_powershell_command("Get-NetIPInterface")

    ethernet_interface_line = get_interface_line(
        all_interfaces, ethernet_interface_name
    )

    if ethernet_interface_line is None:
        print(f"(!) No '{ethernet_interface_name}' interface found")
        press_enter_to_close()
        return

    outline_interface_line = get_interface_line(all_interfaces, outline_interface_name)

    if outline_interface_line is None:
        print(f"(!) No '{outline_interface_name}' interface found")
        press_enter_to_close()
        return

    print(
        f"> Found '{ethernet_interface_name}' and '{outline_interface_name}' interfaces"
    )

    ethernet_interface_metric_value = int(re.split(r"\s+", ethernet_interface_line)[5])
    print(
        f"> Found '{ethernet_interface_name}' interface metric value: {ethernet_interface_metric_value}"
    )

    outline_interface_index = re.split(r"\s+", outline_interface_line)[0]
    print(
        f"> Found '{outline_interface_name}' interface index: {outline_interface_index}"
    )

    new_metric = ethernet_interface_metric_value - 1

    print(f"> New value for {outline_interface_name} metric is {new_metric}")

    if not outline_interface_index.isdigit():
        print(f"'{outline_interface_name} index is not a number'")
        press_enter_to_close()
        return

    print(f"Changing {outline_interface_name} interface metric value")

    try:
        run_powershell_command(
            f"Set-NetIPInterface -InterfaceIndex {outline_interface_index} -InterfaceMetric {new_metric}"
        )
        run_powershell_command(
            f"Set-NetIPInterface -InterfaceIndex {outline_interface_index} -AutomaticMetric Disabled"
        )
    except Exception as e:
        print(e)
        print(
            "(!) PowerShell command failed. Try to run script with administrator privileges."
        )
        press_enter_to_close()
        return

    print(
        f"InterfaceMetric {new_metric} is successfully set for NetIPInterface with ifIndex {outline_interface_index}"
    )
    press_enter_to_close()

if __name__ == "__main__":
    main()