ParrotSec / parrot-core

Files to include in the package parrot-core.
41 stars 48 forks source link

issues with resolv.conf file #11

Open oldkingcone opened 2 years ago

oldkingcone commented 2 years ago

I noticed a few issues with the resolv file not being created/updated after any vpn connections. This causes a massive issue for updating/doing anything as most operations require internet connections to exist. I have created this script to assist with this issue, not sure if this is a bug in how the resolv system implementation through systemd is handled by parrotOS or not, but this appears to fix most issues:

#!/bin/bash

clear
while :; do
  ping -c1 google.com
  if [[ $? -eq 0 ]]; then
    echo "Connected!"
    break
  else
    clear
    date
    if ! [[ -f "/run/systemd/resolve/stub-resolv.conf" ]]; then
      echo -e "\033[0;31mAttempting to create file.\033[0m\n"
      if [[ -e "/run/systemd/resolve/" ]]; then
        sudo rm -rf /run/systemd/resolve/
        if [ $? -eq 0 ]; then
          echo "Removed previously created directory."
          echo
        else
          echo "Unable to remove previous directory....."
          echo
        fi
      fi
      sudo mkdir -p /run/systemd/resolve/
      sudo echo -e "search local\nnameserver 1.1.1.1\nnameserver 1.0.0.1" > /run/systemd/resolve/stub-resolv.conf
      if [ $? -eq 0 ]; then
        echo "File created!"
        echo
        file /run/systemd/resolve/stub-resolv.conf
      else
        echo -e "\033[0;31mFile creation failed!!!\033[0m"
        echo
      fi
    else
      echo "File exists, not sure why there is no internet. Check host system to ensure that the host has actual internet connection."
    fi
  fi
  sleep 1
done

This script will need to be run as the root user in order to correct the issue presented by the broken link from /etc/resolv.conf -> ../run/systemd/resolv/stub-resolv.conf

LemonTree1989 commented 2 years ago

: not found2: : not found3: clear **,sh: 40: Syntax error: end of file unexpected (expecting "then")

oldkingcone commented 2 years ago

: not found2: : not found3: clear **,sh: 40: Syntax error: end of file unexpected (expecting "then")

sounds like you copied from a windows host into a vm. use nano to copy it, or if you can use vim.

LemonTree1989 commented 2 years ago

My ParrotOS computer won't go inline at all sue to this issue and I don't know how to transfer it except a usb drive. I have Kali on WSL in Widows and the GUI/Kex version but with no internet on ParrotOS computer. I had this issue a couple years ago on Kali and it ultimately kept me from Linux but I love it so I gave it another try. I'm surprised the same issue is still there and even more surprised that a lot more people aren't pushing this issue in droves. I'm staying in for the long haul. Thank you for your help! I guess I could ssh in but due to this issue I'm down to using ParrotOS live.

oldkingcone commented 2 years ago

bash is very space complainy. so put the script into vs code, because it sounds like the spacing and tabbing is messed up between how you copied it, and how it looks when you open it on the parrot system.