3

Since I have changed my router, on one PC I I have to run the command sudo dhclient eno1 after every reboot. I have upgraded to Xubuntu 20.04, but the problem is still present. How can I change that?

Results of ifconfig -a :

eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.10  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::729a:2013:ba7e:ba02  prefixlen 64  scopeid 0x20<link>
        ether a4:5d:36:82:ba:53  txqueuelen 1000  (Ethernet)
        RX packets 8032  bytes 8241625 (8.2 MB)
        RX errors 0  dropped 8  overruns 0  frame 0
        TX packets 5851  bytes 763496 (763.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

I am working on eno1 (wired ethernet), and the IP 192.168.0.10 is correct (fixed IP address configured on the router for my MAC address).

@Thomas: There is no file in /etc/netplan directory

@Terrance: No : /etc/dhcpcd.conf doesn't exist

In /etc/dhcp/dhclient.conf the only lines that are not comments are:

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;

send host-name = gethostname(); request subnet-mask, broadcast-address, time-offset, routers, domain-name, domain-name-servers, domain-search, host-name, dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers, netbios-name-servers, netbios-scope, interface-mtu, rfc3442-classless-static-routes, ntp-servers; timeout 300;

karel
  • 114,770
Phil
  • 71
  • 1
    Please post your /etc/netplan/*.yaml network config file. – Thomas Aichinger Dec 18 '21 at 09:21
  • Does the file /etc/dhcpcd.conf exist? – Terrance Dec 18 '21 at 14:37
  • If you are on ubuntu 20.04 then we can configure netplan to do this for you out of the box, which is how it should be unless you're using network manager (the GUI application). Do you want to use Netplan or do you want to use network manager GUI to configure your devices? (Xubuntu has the ability to use one or the other). As it stands, there doesn't appear to be anything controlling DHCP and autoconfigure of the network interface, hence the problem (ifupdown is no longer the default in 20.04 so old mechanisms might not work like /etc/network/interfaces) – Thomas Ward Dec 18 '21 at 19:16
  • 2
    Welcome to Ask Ubuntu. Please don't put [solved] in your question title. Click on the gray check mark ✔️ next to the correct answer and turn it green ✅. This marks the question as answered and will help others. – user68186 Dec 19 '21 at 13:57

2 Answers2

3

Since you are using ifupdown for controlling your network interface make sure that the following 2 lines are added to the /etc/network/interfaces file:

auto eno1
iface eno1 inet dhcp

The first line tells the system to bring up the interface at startup automatically. The second line tells the system that the interface is going to use DHCP instead of static.

Hope this helps!

Terrance
  • 41,612
  • 7
  • 124
  • 183
  • 1
    ✔️ Phil iadded [solved] to the question's title before I edited it out, and this was the answer that solved it. – karel Dec 19 '21 at 14:03
0

Don't waste your time on 3rd party apps, fix it directly in Linux,

  1. if you do not know the interface name, use ip a interface could be something like ens3 or eno0 or whatever.

  2. then edit the YAML file in Netplan folder. You can either use nano, vi, or any other editors. If your user is not privileged, use sudo to run it.

    sudo vi /etc/netplan/*.yaml

  3. add some lines as your preference like this template.

network:
  ethernets:
    ens8:
      dhcp4: true
      match:
        macaddress: fa:16:3e:d7:29:b9
      mtu: 1450
      set-name: ens8
      nameservers:
        addresses: [1.1.1.1, 4.2.2.4]
      dhcp6: false
  version: 2

Please mind the indentations.

  1. Save it and try to execute it with sudo netplan apply If you get nothing, you are done and good to go. If you have any errors read it carefully, most of the time typos, indentation mistakes, or permission mistakes. If this is not the case for you, we can review what we had in this template together.

line1: network: means the configuration of the network could be found here. line2: ethernets: means the network adapter that we configure is an ethernet port, which could be also wlan or other types. line3: ens8: is the name of our interface, you should replace it with your interface name that has been shown in ip a line4: dhcp4: true means your dhcp client listen to a ipv4 dhcp server, if you want to use an ipv6 you may modify. this line to false. line5-6: match: is not necessary for this method and means if the interface name is assigned to the mac address of macaddress: fa:16:3e:d7:29:b9 the continue otherwise all the configurations will not be applied.
line7: mtu: 1450 is the suggested mtu of the connection line8: set-name: ens8 is the name of the interface after applying the configurations. This line is not mandatory. line9-10: nameservers: defines the DNS server address for nameservers, DNNS could be obtained from the DHCP server or here as explicitly. If you have an issue pinging a server with a name instead of IP, this can solve the issue. addresses: [1.1.1.1, 4.2.2.4] These are the IP addresses of the nameservers. line11: dhcp6: false obviously forces not to listen to ipv6 DHCP server line12: version: 2 is the version of the service.

Shrm
  • 101