Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save mohlatif227/fb831ea6237a636cba70d07f33a0d99f to your computer and use it in GitHub Desktop.

Select an option

Save mohlatif227/fb831ea6237a636cba70d07f33a0d99f to your computer and use it in GitHub Desktop.

Revisions

  1. @coltenkrauter coltenkrauter revised this gist Jan 23, 2021. 1 changed file with 20 additions and 19 deletions.
    39 changes: 20 additions & 19 deletions fix-wsl2-dns-resolution
    Original file line number Diff line number Diff line change
    @@ -16,26 +16,27 @@ secondary.
    13. And finally in windows cmd, ps or terminal:
    Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 6000

    Credit: to @MartinCaccia, @yukosgiti, @machuu and @AlbesK:
    Credit: @MartinCaccia, @yukosgiti, @machuu and @AlbesK:
    https://github.com/microsoft/WSL/issues/4277
    https://github.com/microsoft/WSL/issues/4246

    ---

    > Original resoltuion:
    >
    > 1. Create a file: /etc/wsl.conf.
    > 2. Put the following lines in the file in order to ensure the your DNS changes do not get blown away
    >
    > [network]
    > generateResolvConf = false
    >
    > 3. In a cmd window, run wsl --shutdown
    > 4. Restart WSL2
    > 5. Create a file: /etc/resolv.conf. If it exists, replace existing one with this new file.
    > 6. Put the following line in the file
    >
    > nameserver 8.8.8.8 # Or use your DNS server instead of 8.8.8.8 which is a Google DNS server
    >
    > 7. Repeat step 3 and 4. You will see git working fine now.
    >
    > Credit: https://github.com/microsoft/WSL/issues/4285#issuecomment-522201021
    Original resoltuion:

    1. Create a file: /etc/wsl.conf.
    2. Put the following lines in the file in order to ensure the your DNS changes do not get blown away

    [network]
    generateResolvConf = false

    3. In a cmd window, run wsl --shutdown
    4. Restart WSL2
    5. Create a file: /etc/resolv.conf. If it exists, replace existing one with this new file.
    6. Put the following line in the file

    nameserver 8.8.8.8 # Or use your DNS server instead of 8.8.8.8 which is a Google DNS server

    7. Repeat step 3 and 4. You will see git working fine now.

    Credit: https://github.com/microsoft/WSL/issues/4285#issuecomment-522201021
  2. @coltenkrauter coltenkrauter revised this gist Jan 23, 2021. 1 changed file with 19 additions and 20 deletions.
    39 changes: 19 additions & 20 deletions fix-wsl2-dns-resolution
    Original file line number Diff line number Diff line change
    @@ -16,27 +16,26 @@ secondary.
    13. And finally in windows cmd, ps or terminal:
    Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 6000

    Credits to @MartinCaccia, @yukosgiti, @machuu and @AlbesK:
    Credit: to @MartinCaccia, @yukosgiti, @machuu and @AlbesK:
    https://github.com/microsoft/WSL/issues/4277
    https://github.com/microsoft/WSL/issues/4246

    ---------

    Original resoltuion:

    1. Create a file: /etc/wsl.conf.
    2. Put the following lines in the file in order to ensure the your DNS changes do not get blown away

    [network]
    generateResolvConf = false

    3. In a cmd window, run wsl --shutdown
    4. Restart WSL2
    5. Create a file: /etc/resolv.conf. If it exists, replace existing one with this new file.
    6. Put the following line in the file

    nameserver 8.8.8.8 # Or use your DNS server instead of 8.8.8.8 which is a Google DNS server

    7. Repeat step 3 and 4. You will see git working fine now.

    Credit: https://github.com/microsoft/WSL/issues/4285#issuecomment-522201021
    > Original resoltuion:
    >
    > 1. Create a file: /etc/wsl.conf.
    > 2. Put the following lines in the file in order to ensure the your DNS changes do not get blown away
    >
    > [network]
    > generateResolvConf = false
    >
    > 3. In a cmd window, run wsl --shutdown
    > 4. Restart WSL2
    > 5. Create a file: /etc/resolv.conf. If it exists, replace existing one with this new file.
    > 6. Put the following line in the file
    >
    > nameserver 8.8.8.8 # Or use your DNS server instead of 8.8.8.8 which is a Google DNS server
    >
    > 7. Repeat step 3 and 4. You will see git working fine now.
    >
    > Credit: https://github.com/microsoft/WSL/issues/4285#issuecomment-522201021
  3. @coltenkrauter coltenkrauter revised this gist Jan 23, 2021. 1 changed file with 27 additions and 1 deletion.
    28 changes: 27 additions & 1 deletion fix-wsl2-dns-resolution
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,29 @@
    More recent resolution:

    1. cd ~/../../etc (go to etc folder in WSL).
    2. echo "[network]" | sudo tee wsl.conf (Create wsl.conf file and add the first line).
    3. echo "generateResolvConf = false" | sudo tee -a wsl.conf (Append wsl.conf the next line).
    4. wsl --terminate Debian (Terminate WSL in Windows cmd, in case is Ubuntu not Debian).
    5. cd ~/../../etc (go to etc folder in WSL).
    6. sudo rm -Rf resolv.conf (Delete the resolv.conf file).
    7. In windows cmd, ps or terminal with the vpn connected do: Get-NetIPInterface or ipconfig /all for get the dns primary and
    secondary.
    8. With the dns primary and secondary getted replace the numbers in the next step in the X.X.X.X
    9. echo "nameserver X.X.X.X" | sudo tee resolv.conf (Create resolv.conf and append the line.)
    10. echo "nameserver X.X.X.X" | sudo tee -a resolv.conf (Append the line in resolv.conf)
    11. wsl --terminate Debian (Terminate WSL in Windows cmd, in case is Ubuntu not Debian).
    12. sudo chattr +i resolv.conf
    13. And finally in windows cmd, ps or terminal:
    Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 6000

    Credits to @MartinCaccia, @yukosgiti, @machuu and @AlbesK:
    https://github.com/microsoft/WSL/issues/4277
    https://github.com/microsoft/WSL/issues/4246

    ---------

    Original resoltuion:

    1. Create a file: /etc/wsl.conf.
    2. Put the following lines in the file in order to ensure the your DNS changes do not get blown away

    @@ -13,4 +39,4 @@ nameserver 8.8.8.8 # Or use your DNS server instead of 8.8.8.8 which is a Google

    7. Repeat step 3 and 4. You will see git working fine now.

    Credit: https://github.com/microsoft/WSL/issues/4285#issuecomment-522201021
    Credit: https://github.com/microsoft/WSL/issues/4285#issuecomment-522201021
  4. @coltenkrauter coltenkrauter revised this gist Oct 17, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fix-wsl2-dns-resolution
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ generateResolvConf = false
    3. In a cmd window, run wsl --shutdown
    4. Restart WSL2
    5. Create a file: /etc/resolv.conf. If it exists, replace existing one with this new file.
    6. Put the following lines in the file
    6. Put the following line in the file

    nameserver 8.8.8.8 # Or use your DNS server instead of 8.8.8.8 which is a Google DNS server

  5. @coltenkrauter coltenkrauter revised this gist Oct 17, 2019. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions fix-wsl2-dns-resolution
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,16 @@
    1. Create a file: /etc/wsl.conf.
    2. Put the following lines in the file in order to ensure the your DNS changes do not get blown away
    ```

    [network]
    generateResolvConf = false
    ```

    3. In a cmd window, run wsl --shutdown
    4. Restart WSL2
    5. Create a file: /etc/resolv.conf. If it exists, replace existing one with this new file.
    6. Put the following lines in the file

    nameserver 8.8.8.8 # Or use your DNS server instead of 8.8.8.8 which is a Google DNS server

    7. Repeat step 3 and 4. You will see git working fine now.

    Credit: https://github.com/microsoft/WSL/issues/4285#issuecomment-522201021
  6. @coltenkrauter coltenkrauter revised this gist Oct 17, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fix-wsl2-dns-resolution
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    1. Create a file: /etc/wsl.conf.
    2. Put the following lines in the file
    2. Put the following lines in the file in order to ensure the your DNS changes do not get blown away
    ```
    [network]
    generateResolvConf = false
  7. @coltenkrauter coltenkrauter created this gist Oct 17, 2019.
    14 changes: 14 additions & 0 deletions fix-wsl2-dns-resolution
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    1. Create a file: /etc/wsl.conf.
    2. Put the following lines in the file
    ```
    [network]
    generateResolvConf = false
    ```
    3. In a cmd window, run wsl --shutdown
    4. Restart WSL2
    5. Create a file: /etc/resolv.conf. If it exists, replace existing one with this new file.
    6. Put the following lines in the file
    nameserver 8.8.8.8 # Or use your DNS server instead of 8.8.8.8 which is a Google DNS server
    7. Repeat step 3 and 4. You will see git working fine now.

    Credit: https://github.com/microsoft/WSL/issues/4285#issuecomment-522201021