Skip to content

issues with resolv.conf file #11

Description

@oldkingcone

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions