sudo lshw -numeric -C network
logical
name: enp2s0
logical name is network interface name
Then do
# Restart dhcp client
sudo dhclient enp2s0
# Restart name resolution service
sudo systemctl start systemd-resolved
https://www.cyberciti.biz/faq/howto-linux-renew-dhcp-client-ip-address/#:~:text=The%20dhclient%20command%2C%20provides%20a,by%20statically%20assigning%20an%20address.
This error is mainly caused by dhcp service issues, check /etc/resolv.conf sym link***
The dhclient command, provides a means for configuring one or more network interfaces using the Dynamic Host Configuration Protocol, BOOTP protocol, or if these protocols fail, by statically assigning an address.
This is because
In newer versions of Ubuntu name resolution does not work via /etc/resolv.conf
anymore.
to prevent doing this all time do :
https://askubuntu.com/questions/193074/have-to-run-sudo-dhclient-eth0-automatically-every-boot
gksu gedit /etc/rc.local
Add: sudo dhclient eth0
like so.
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
sudo dhclient eth0
exit 0
https://unix.stackexchange.com/questions/49626/purpose-and-typical-usage-of-etc-rc-local
The script /etc/rc.local
is for use by the system administrator. It is traditionally executed after all the normal system services are started, at the end of the process of switching to a multiuser runlevel. You might use it to start a custom service, for example a server that's installed in /usr/local
. Most installations don't need /etc/rc.local
, it's provided for the minority of cases where it's needed.
If DNS name can not be resolved after above steps such as docker:
https://stackoverflow.com/questions/47580528/error-response-from-daemon-get-https-registry-1-docker-io-v2-dial-tcp-look
sudo vim /etc/resolv.conf
#Google name server or ur known name server)
#add nameserver 8.8.8.8
nameserver 8.8.4.4
sudo systemctl daemon-reload
sudo systemctl restart docker