Skip to content

Instantly share code, notes, and snippets.

@junqueira
Created November 4, 2025 17:33
Show Gist options
  • Select an option

  • Save junqueira/9c7c8a860be13cdc7c3b92a9ae66f3e6 to your computer and use it in GitHub Desktop.

Select an option

Save junqueira/9c7c8a860be13cdc7c3b92a9ae66f3e6 to your computer and use it in GitHub Desktop.

Revisions

  1. junqueira created this gist Nov 4, 2025.
    39 changes: 39 additions & 0 deletions # wsl-vpn
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    # wsl-vpn
    # erro-wsl
    nslookup localhost
    sudo vim /etc/wsl.conf
    [network]
    generateResolvConf = true
    sudo vim /etc/resolv.conf
    #nameserver 172.29.208.1
    #nameserver 127.0i.0.53
    #options edns0 trust-ad
    nameserver 8.8.8.8
    sudo vim /bin/vpn-dns.sh
    #!/bin/bash
    echo "Getting current DNS servers, this takes a couple of seconds"
    /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command '
    $ErrorActionPreference="SilentlyContinue"
    Get-NetAdapter -InterfaceDescription "Check Point*" | Get-DnsClientServerAddress | Select -ExpandProperty ServerAddresses
    Get-NetAdapter | ?{-not ($_.InterfaceDescription "Check Point*") } | Get-DnsClientServerAddress | Select -ExpandProperty ServerAddresses
    Get-NetAdapter | ?{-not ($_.InterfaceDescription -like "Check Point*") } | Get-DnsClientServerAddress | Select -ExpandProperty ServerAddresses
    ' | \
    awk 'BEGIN { print "# Generated by vpn fix func on", strftime("%c"); print } { print "nameserver", $1 }' | \
    tr -d '\r
    ' > /etc/resolv.conf
    #clear
    # execute
    sudo chmod +x /bin/vpn-dns.sh
    <!-- echo (whoami) ALL=ALL NOPASSWD: /bin/vpn-dns.sh | sudo tee /etc/sudoers.d/010-(whoami)-vpn-dns -->
    <!-- echo (whoami) ALL=(ALL:ALL) NOPASSWD: /bin/vpn-dns.sh | sudo tee /etc/sudoers.d/010-(whoami)-vpn-dns -->
    echo "`whoami` ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/`whoami` && sudo chmod 0440 /etc/sudoers.d/`whoami`
    <!-- echo "`whoami` ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/010-(whoami)-vpn-dns -->
    # test-dns: vpn-bb (wsl)
    Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Check Point*"} | Set-NetIPInterface -InterfaceMetric 6000
    Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Check Point*"} | Get-NetIPInterface
    Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Check Point*"} | Set-NetIPInterface -InterfaceMetric 1
    # cat /etc/networks
    link-local 169.254.0.0
    # wsl
    cat /etc/networks
    # symbolic names for networks, see networks(5) for more information