Enable ethernet and disable WiFi on Ubuntu Server (on Raspberry Pi)

,

Initially I set up my Raspberry Pi with WiFi (which you can do during OS install), but later I realized I’d rather have it connected through Ethernet.

So first navigate to the /etc/netplan folder.

$ cd /etc/netplan

In that folder, check the contents of 50-cloud-init.yaml, it should look something like this (some comments omitted):

$ sudo cat 50-cloud-init.yaml
...
network:
    version: 2
    wifis:
        renderer: networkd
        wlan0:
            access-points:
                YourNetworkName:
                    password: bd4a793d...
            dhcp4: true
            optional: true

Edit the file:

$ sudo vim 50-cloud-init.yaml

Excepting the comments, change the content to this, save and quit.

network:
    ethernets:
        eth0:
            dhcp4: true
            optional: true
    version: 2

Reboot the machine:

$ sudo reboot

After the reboot, you can check if it worked. It should show eth0 as UP with an IPv4 assigned and wlan0 as DOWN:

~$ ip a
...
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 2c:cf:67:56:3b:0d brd ff:ff:ff:ff:ff:ff
    inet 192.168.68.106/24 metric 100 brd 192.168.68.255 scope global dynamic eth0
       valid_lft 7174sec preferred_lft 7174sec
    inet6 fe80::2ecf:67ff:fe56:3b0d/64 scope link
       valid_lft forever preferred_lft forever
3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether 2c:cf:67:56:3b:0f brd ff:ff:ff:ff:ff:ff
...

Hope this helps, have fun clickity-clacking.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *