Как удалить сетевой интерфейс linux

How to permanently remove eth0.x in CentOS

I’m trying to remove eth0.x and keep eth0. While ifconfig lists both eth0.1 and eth0.500, I didn’t find their configuration files /etc/sysconfig/network-scripts/ifcfg-eth0.x . I tried ifconfig eth0.1 down and it worked. But after restarting the network, both eth0.1 and eth0.500 came back. Is there a way to permanently remove these two interfaces?

You can remove the network card from the machine (but note that then the eth* name can change on the next boot).

eth0.x and eth0 are on the same card. Is there a way to remove eth0.x without deleting eth0? @grochmal

3 Answers 3

I’m thinking you use Centos 7, where Network-Manager is default network configuration utility. Two interfaces eth0.1 and eth0.500 are vlan 1 and vlan 500 tagged. To show all interfaces use command: # nmcli connection show To delete both vlan interfaces use these commands: # nmcli con del eth0.1 and # nmcli con del eth0.500 You can find help there https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Networking_Guide/sec-Configure_802_1Q_VLAN_Tagging_Using_the_Command_Line_Tool_nmcli.html

These are virtual devices, they do not have their own configuration files in /etc/sysconfig/network-scripts/ but are defined in the main configuration file, something along the lines of this:

iface eth0:1 inet static address 192.168.4.1 netmask 255.255.255.0 

You can delete the interface using ip link delete eth0.1 assuming you want to delete interface eth0.1 . But if the main configuration file holds those lines or something similar as I wrote above then I think the interface will come back on reboot. To permanently remove it then find the lines that define the virtual interface and comment them out or remove them (I recommend commenting out, never know unless you need them some time again).

Источник

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 

Источник

Читайте также:  Linux как увеличить шрифт в терминале

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 ‘:’ ‘‘ | tr -d ‘ ‘ | while read b; do sudo ip link set «$b» down; sudo brctl delbr «$b»; done

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.

Читайте также:  Удаление всего содержимого папки linux

Источник

удалить или переименовать программно физический сетевой интерфейс(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

Источник

Оцените статью
Adblock
detector