How to delete all network interface permanently on Ubuntu

I need to remove all network interface permanently on Ubuntu Linux system except eth0. I have eth1, eth2 and wifi0 interfaces. How can I remove network interface permanently on Ubuntu Linux 18.04 system?

It is a little complicated. I think you need to use either NetworkManager or netplan on latest Ubuntu version. What does the following command say?

ls -l /etc/netplan/ 

Post file list along with contains.

AWS instances networking config

cat /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    version: 2
    ethernets:
        eth0:
            dhcp4: true
            match:
                macaddress: 0a:99:85:fc:11:57
            set-name: eth0

Here is what I see on Ubuntu desktop:

This is what you will see on Ubuntu 18.04 or 20.04 LTS or latest version:

cat /etc/netplan/01-netcfg.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: NetworkManager

Hence, I would use the nmcli command or NetworkManager GUI to remove all network interfaces.

Step 1. List all connections on Ubuntu 20.04 LTS desktop

nmcli device

Look for CONNECTION in last column and note down that name such as “Ethernet connection 1” or “Eth0

Step 2. Delete all or needed connection one-by-one

To delete connection by name via Network Manager CLI:

nmcli connection delete CONNECTION_NAME
nmcli connection delete "Ethernet connection 1"
nmcli connection delete "Wifi 1"
nmcli connection delete "Eth0"

Dealing with Ubuntu Linux distros such as Ubuntu 16.04 and older

Edit the /etc/network/interfaces and files in /etc/network/interfaces.d/ directory.

Remove network interface permanently on Ubuntu 16.04 LTS

Edit the file:

sudo nano /etc/network/interfaces

My listing:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto eth1
iface eth0 inet dhcp

auto eth2
iface eth0 inet dhcp

# Static IP example 
auto eth3
iface eth3 inet static
     address 10.15.43.23
     netmask 255.255.255.0
     gateway 10.15.43.1

Either delete lines. Say disable eth3, remove all those lines:

# Static IP example 
auto eth3
iface eth3 inet static
     address 10.15.43.23
     netmask 255.255.255.0
     gateway 10.15.43.1

Another option os to edit and make line as follows to disable eth2:

iface eth2 inet manual

Save the file and run command to restart networking service:

sudo service network-manager restart
## or ## 
sudo systemctl restart network-manager.service
1 Like

Why does everything have to be so complicated? So many options. I will check back and report here soon.


Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki