Remove network interface permanently
I’m trying to remove a network interface permanently. For some reason, ifconfig lists eth0 and eth1 , although the latter RX/TX metrics remain at zero. I suspect that extra eth1 entry might be causing delays during boot. Surprinsgly, a search did not yield any answer on how to proceed. Most posts either are for older versions of Ubuntu or Debian, or for other distros (RedHat), or have no permanent effect, or pertain to adding an interface, or try to turn it off but after it’s been started, or are simply unanswered. But the answer might be somewhere after Google’s thrid result page. Removing the second entry from the desktop (up and down arrows, on the top bar) has no effect either on ifconfig . EDIT: I actutally do have two network cards on the MB. That’s a bit of a surprise I admit. I don’t have wifi. Question still stands, a least out of curiosity.
krakoukass@durum:~$ ifconfig eth0 Link encap:Ethernet HWaddr 00:1f:d0:a3:40:d9 inet addr:192.168.1.66 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::21f:d0ff:fea3:40d9/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:84 errors:0 dropped:0 overruns:0 frame:0 TX packets:93 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:12255 (12.2 KB) TX bytes:12241 (12.2 KB) eth1 Link encap:Ethernet HWaddr 00:1f:d0:a3:40:db UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:634 errors:0 dropped:0 overruns:0 frame:0 TX packets:634 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:64758 (64.7 KB) TX bytes:64758 (64.7 KB) krakoukass@durum:~$ lspci | grep -i eth 04:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 02) 05:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 02) krakoukass@durum:~$ cat /etc/network/interfaces # interfaces(5) file used by ifup(8) and ifdown(8) auto lo iface lo inet loopback krakoukas@durum:~$ systemctl -l status ifup@eth1.service ● ifup@eth1.service - ifup for eth1 Loaded: loaded (/lib/systemd/system/ifup@.service; static; vendor preset: enabled) Active: active (exited) since Fri 2015-05-15 12:36:34 CEST; 14min ago Process: 457 ExecStart=/bin/sh -ec ifup --allow=hotplug %I; ifup --allow=auto %I; if ifquery %I >/dev/null; then ifquery --state %I >/dev/null; fi (code=exited, status=0/SUCCESS) Main PID: 457 (code=exited, status=0/SUCCESS) May 15 12:36:34 durum systemd[1]: Started ifup for eth1. May 15 12:36:34 durum systemd[1]: Starting ifup for eth1. May 15 12:36:34 durum sh[457]: Unknown interface eth1 krakoukas@durum:~$ systemctl -l status ifup@eth0.service ● ifup@eth0.service - ifup for eth0 Loaded: loaded (/lib/systemd/system/ifup@.service; static; vendor preset: enabled) Active: active (exited) since Fri 2015-05-15 12:36:34 CEST; 15min ago Process: 458 ExecStart=/bin/sh -ec ifup --allow=hotplug %I; ifup --allow=auto %I; if ifquery %I >/dev/null; then ifquery --state %I >/dev/null; fi (code=exited, status=0/SUCCESS) Main PID: 458 (code=exited, status=0/SUCCESS) May 15 12:36:34 durum systemd[1]: Started ifup for eth0. May 15 12:36:34 durum systemd[1]: Starting ifup for eth0. May 15 12:36:34 durum sh[458]: Unknown interface eth0
How can I permanently delete tun interfaces
I am running Ubuntu 19.10 with openvpn 2.4.7, and over time I have accumulated 40 tun devices, which all show up when I log in. ifconfig confirms that they are all there. I have tried:
- doing sudo ip link delete tun0 (and for all other devices)
- doing sudo ip link delete tun0 and also doing sudo tunctl -d tun0 (which replies Set ‘tun0’ nonpersistent — and I’ve done this to all others too)
- doing sudo ifconfig tun0 down (and all others)
- removing and reinstalling openvpn (which removes all tun devices)
But after a reboot, they all come back. The only way I can use my system is to remove openvpn and reinstall after every boot. They are not part of netplan.
How can I delete them permanently?
*Edit: Disabling IPv6 actually made these devices disappear. I cannot belive it. Disabling IPv6 should not be a solution.
@HackSaw No such folder exists on my system. they’re nowhere to be found inside /etc/network (which contains if-down.d, if-pre-up.d and if-up.d as well as the file interfaces
Oh, how odd. Is there an include line in /etc/network/interfaces? Or, for that matter, are the device not listed there? A useful trick I use often is to grep for thing in /etc: sudo grep -r tun3
@HackSaw I got really excited when you suggested the grep -r command, didn’t think of that. I tried it and got no results for tun3. I have removed openvpn and reinstalled, so right now I only have tun0 active. doing sudo grep -r tun0 only shows one hit and that’s in my danted.conf file, which is telling my socks5 daemon what external interface to use. No other hits. I also tried searching in /dev
Huh. well, now we’re getting out of my depth, but it’s worth grepping a few other areas, such are /var/run, /usr/libexec, and so on. I’d look at the areas which those other servers might decide to plant files in. You also might find clues by looking at /var/log. My fave command to use there is ls -ltr, which sorts the files most recently updated last. Good luck!
1 Answer 1
If your want to permanently delete any interface so that it does not appear after a reboot, then it depends on which service they are under the control of. If your used nm, then in essence it automatically creates tun/tap interfaces when your install openvpn and they cannot be removed using networkctl, but only by force with nmcli tool . There is one subtlety between nm and sn, when your activate sn, it is important for your to uninstall nm BEFORE installing for example ‘openvpn’, since nm automatically creates an interface for traffic tunneling and it remains in the list networkctl and it CANNOT remove it. But if your uninstall and deactivate nm before installing openvpn, then the created interfaces can be not created from and disappear from the networkctl list. So that your do not stumble over the created by nm interfaces, . there is no beach in the list of networkctl and if your want to revolutionize then i advise your to use systemd-networkd, your can gradually get used to its syntax.
- Nmcli is a command-line tool for controlling network-manager and reporting network status.
- Networkctl may be used to introspect the state of the network links as seen by systemd-networkd.
Nmcli from network-manager.
shut down all interfaces after reboot managed by nm:
nmcli nmcli general status nmcli device show tun0 nmcli connection
temporarily disable/remove interface from nm until reboot:
nmcli device set autoconnect no tun0 nmcli device set managed no tun0 nmcli device delete tun0 uuidgen tun0 84a068f7-efe5-40c5-a813-3fc85fabdcc3 # replace it with yours uuid nmcli connection delete 84a068f7-efe5-40c5-a813-3fc85fabdcc3
Networkctl from systemd-networkd.
In order to have a possibility to think about an adequate solution to the setting and not in a hurry to reinstall the system, then the only way to bypass unnecessary interfaces from nm is to create a config that uses sn of all the interfaces your need in /etc/default/grub , thereby adding their in autoload. to see the interfaces in networkctl, only which ones your are interested in, create a config 01-netcfg.yaml:
sudo apt install bridge-utils net-tools ; reboot # use net-tools to display ifconfig list sudo nano /etc/netplan/01-netcfg.yaml netplan --debug generate
add the config you created to autoload:
GRUB_CMDLINE_LINUX="netcfg/do_not_use_netplan=true" update-grub ; reboot ifconfig
see all the interfaces you have:
networkctl status all WARNING: systemd-networkd is not running, output will be incomplete. Failed to request link: No such device
accordingly, your can see here that networkctl does not display until sn is running.
to shut down the interface before rebooting in networkctl:
sudo ifconfig tun0 down sudo ip link set tun0 down sudo ip link delete tun0 sudo systemctl restart systemd-networkd ; sudo systemctl status systemd-networkd
удалить или переименовать программно физический сетевой интерфейс(phy0) из линукс
Есть ли возможность каким либо образом удалить сетевой интерфейс, как то отключить сетевую карту чтобы он исчез, или переименовать его?
Можно выгрузить модуль ядра, отвечающий за данный сетевой интерфейс. Из недостатков — если все сетевые карты используют выгруженный драйвер — они все пропадут.
Переименовать тоже можно, но тогда интерфейс останется видным(пусть и под новым именем)
Еще вариант — можно создать отдельный network namespace(например с именем trash) и позасовывать в него «неугодные интерфейсы». Тогда в основном namespace они будут не видны(но при желании из под рута их можно будет достать обратно)
Короче, уточни задачу — чего ты хочешь достичь?
Pinkbyte ★★★★★ ( 07.07.20 22:00:28 MSK )
Последнее исправление: Pinkbyte 07.07.20 22:00:34 MSK (всего исправлений: 1)
iface eth1 inet manual >> /etc/network/interfaces и\или alias eth1 off >> /etc/modprobe.conf
Да сие действо на андроид происходит, вот у него есть встроенная сетевуха, ей по дефолту когда её включаеш присваивается phy0 ну и на него wlan0. Вот мне нужно phy0 переименовать или удалить. Узнать бы где вообще хранится список этих интерфейсов тогда я думаю и можно былоб это сделать.
Не скроет интерфейс из общего списка
О таком варианте признаюсь забыл — как-то не приходилось применять его к сетевым картам
сие действо на андроид происходит
Об этом сразу стоило бы говорить, учитывая что ядро в андроиде сильно-сильно патченное обычно
Панемаю, но из зацепок только связь с линукс поэтому и интересуюсь, как мне найти где эти интерфейсы хранятся (то что iw dev выводит? Если это динамически в оперативе лежит то плохо, если в файле то лучше, ну и 100% устраивающий меня вариант отрубить сетевуху, но модуля у неё нет (lsmod ничего вообще не выводит) все в ядре видимо.
Можешь попробовать вот так, не уверен правда что на андроиде это сработает.
Вопрос о том, как это добавить в автозапуск остается открытым — если у тебя там /system смонтированный в r/w или Magisk на худой конец — тогда оно как-то решается. Иначе — я хз.
Pinkbyte ★★★★★ ( 07.07.20 22:38:44 MSK )
Последнее исправление: Pinkbyte 07.07.20 22:39:35 MSK (всего исправлений: 1)
Если есть iw тогда iw dev phy0 del
Bring down and delete bridge interface that’s up
How do I remove a bridge that has an IP address that was brought up manually and isn’t in /etc/network/interfaces?
$ ifconfig br100 br100 Link encap:Ethernet HWaddr 00:00:00:00:00:00 inet addr:172.16.0.5 Bcast:172.16.0.255 Mask:255.255.255.0
# brctl delbr br100 bridge br100 is still up; can't delete it
# ifdown br100 ifdown: interface br100 not configured
7 Answers 7
# ip link set br100 down # brctl delbr br100
To delete all bridge interfaces do sudo ip link show | grep br- | awk -F ‘:’ ‘
I stumbled upon an info that «brctl» is obsolete as of centos8 (and may be missing from the repos). Use «ip» as in answer by robo
$ sudo ip link delete br0 type bridge
To clarify this for future.
ifup and ifdown are commands from some flavours of linux. And are used to control network settings set in /etc/network/interfaces for debian based systems and /etc/sysconfig/network-scripts/ifcg* on Redhat based systems (I cannot comment on others).
Creating and removing interfaces manually is done by using ifconfig (or ip which is bit more tricky to use). Bridges can be controlled with brctl
So after removing all interfaces from a bridge with brctl delif it can be moved to «down state» with ifconfig br100 down (or ip link set br100 down ) and can now be removed with brctl delbr br100
Please note that using network-manager to manage your networks might make your manually changed interfaces to reset.