From 25d5b9b92f81c840152e1652eabc868a80271e6e Mon Sep 17 00:00:00 2001 From: Bas Berkhout Date: Mon, 12 Feb 2024 08:45:23 +0100 Subject: [PATCH 1/2] add option to specify own nameservers --- run.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) mode change 100644 => 100755 run.sh diff --git a/run.sh b/run.sh old mode 100644 new mode 100755 index 4bdc1ea..a8d129e --- a/run.sh +++ b/run.sh @@ -10,10 +10,23 @@ rm -f $resolv # Create custom WSL name resolution cp ./dist/wsl.conf $wsl -cp ./dist/resolv.conf $resolv + +# Check if --dnsserver argument is provided +if [ "$1" = "--dnsservers" ]; then + shift + # Create a new resolv.conf file with default dns servers + cp ./dist/resolv.conf $resolv + + #overwrite the resolv.conf with with the given nameservers + for server in "$@"; do + echo "nameserver $server" >> $resolv + done +else + cp ./dist/resolv.conf $resolv +fi # This prevents resolv.conf from being deleted when WSL starts -chattr +i $resolv +#chattr +i $resolv echo 'WSL name resolution configured' -echo 'Restart WSL on Windows: "wsl --shutdown"' +echo 'Restart WSL on Windows: "wsl --shutdown"' \ No newline at end of file From e8e0f4379be5ad40d2a55a3a1a02b30fb1c1930e Mon Sep 17 00:00:00 2001 From: Bas Berkhout Date: Mon, 12 Feb 2024 08:48:55 +0100 Subject: [PATCH 2/2] add option to specify own nameservers --- run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run.sh b/run.sh index a8d129e..3ad3542 100755 --- a/run.sh +++ b/run.sh @@ -15,7 +15,7 @@ cp ./dist/wsl.conf $wsl if [ "$1" = "--dnsservers" ]; then shift # Create a new resolv.conf file with default dns servers - cp ./dist/resolv.conf $resolv + #overwrite the resolv.conf with with the given nameservers for server in "$@"; do @@ -26,7 +26,7 @@ else fi # This prevents resolv.conf from being deleted when WSL starts -#chattr +i $resolv +chattr +i $resolv echo 'WSL name resolution configured' echo 'Restart WSL on Windows: "wsl --shutdown"' \ No newline at end of file