13

I recently installed Ubuntu Server 20.04 LTS on my desktop, and found out there was no internet connection even though I had the LAN cable connected. ifconfig and iwconfig failed saying the corresponding packages net-tools and wireless-tools were not installed.

EDIT

Here is the info requested. Please find the image here.

6
  • Add to your question above the complete output of ip addr
    – user535733
    May 1, 2020 at 13:31
  • Also ip link. Look at service NetworkManager status, to. The whole ifconfig/ifup/ifdown system is depreciated in later Ubuntu releases.
    – waltinator
    May 1, 2020 at 13:35
  • @waltinator Network Manager is not installed by default in Ubuntu server.
    – chili555
    May 1, 2020 at 13:58
  • Please edit your question to show the result of the terminal command: cat /etc/netplan/*.yaml Welcome to Ask Ubuntu.
    – chili555
    May 1, 2020 at 14:02
  • Along with @chili555 request, also please show us sudo lshw -C network and cat /etc/network/interfaces.
    – heynnema
    May 1, 2020 at 14:35

2 Answers 2

13

Networking in Ubuntu server is managed by netplan. Your file lacks the details needed to connect the ethernet properly.

First, let's rename the file:

sudo mv /etc/netplan/*.yaml  /etc/netplan/01-netcfg.yaml

Now, let's change it to include the required details:

sudo nano /etc/netplan/01-netcfg.yaml   

Change the file to read:

network:
  version: 2
  renderer: networkd
  ethernets:
    ens33:
      dhcp4: true

Netplan is very particular about spacing, indentation, etc. Proofread carefully twice. Save (Ctrl+o followed by Enter) and exit (Ctrl+x) the text editor. Follow with:

sudo netplan generate
sudo netplan apply

You should be all set.

5
  • Good job! +1... however, be careful with your mv, as there may be more than one .yaml file in /etc/netplan.
    – heynnema
    May 1, 2020 at 16:08
  • worked. Thank you :)
    – wardaddy
    May 1, 2020 at 16:23
  • @heynnema Let's discuss, please: chat.stackexchange.com/rooms/107486/…
    – chili555
    May 1, 2020 at 22:56
  • solved my problem on ubuntu-desktop. but why netplan is not installed on ubuntu desktop already? I had to download .deb file. thank you Sep 4, 2020 at 20:17
  • I was hoping I would find an answer here, but alas, I didn't. My netplan config is there. Did 20+ servers all the same. This one, however, no dice. Fresh server out of the box too. Log during install says it can't resolve archive.ubuntu.com to download packages. Sep 3, 2021 at 1:04
2

A short addon to chili555's answer: In my case, the only problem was that for some strange reason, Ubuntu believed my network interface name in /etc/netplan/01-netcfg.yaml to be enp0s5 instead of enp0s4 which was the correct for my VM.

4
  • You can find out the name of your network interface name using ifconfig
    – RyanQuey
    Oct 19, 2020 at 22:41
  • 2
    @RyanQuey As per question statement (and I can confirm) ifconfig is not installed, and it cannot be without network.
    – tishma
    Dec 17, 2020 at 11:35
  • @RyanQuey You have to have it installed first. Can't install if you have no network! Nov 22, 2021 at 15:19
  • Since ifconfig is not available you can also use the command ip link
    – Gibado
    Aug 26, 2022 at 17:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.