In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to close the network card in linux". In the daily operation, I believe many people have doubts about how to close the network card in linux. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to close the network card in linux". Next, please follow the editor to study!
Methods: 1. Use the ifconfig command to close the network card, the syntax is "ifconfig network card name down"; 2, use the ifdown command to close the network card, the syntax is "ifdown network card name"; 3, use the ip command to close the network card, the syntax is "ip link set network card name down"
The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
How to turn off the network card by linux
You may execute the following orders according to your needs. I will give some examples of these commands that you will use here.
When you add a network card or create a virtual network card from a physical network card, you may need to use these commands to enable the new network card. In addition, if you have made some changes to the network card or the network card itself is not enabled, then you also need to use one of the following commands to enable the network card.
There are many ways to enable and disable the network card. In this article, we will introduce the five best methods we have used.
Enabling disabling the network card can be done using the following five methods:
Ifconfig command: used to configure the network card. It can provide a lot of information about the network card.
Ifdown/up command: the ifdown command is used to disable the network card, and the ifup command is used to enable the network card.
Ip command: used to manage the network card to replace the old, deprecated ifconfig command. It is similar to the ifconfig command, but provides powerful features that many ifconfig commands do not have.
Nmcli command: a command-line tool that controls NetworkManager and reports the status of the network.
Nmtui command: a terminal UI application that interacts with NetworkManager and is based on curses graphics library.
The following shows the information of the network cards available in my Linux system.
# ip a1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6:: 1/128 scope host valid_lft forever preferred_lft forever2: enp0s3: mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 08:00:27:c2:e4:e8 Brd ff:ff:ff:ff:ff:ff inet 192.168.1.4/24 brd 192.168.1.255 scope global dynamic noprefixroute enp0s3 valid_lft 86049sec preferred_lft 86049sec inet6 fe80::3899:270f:ae38:b433/64 scope link noprefixroute valid_lft forever preferred_lft forever3: enp0s8: mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 08:00:27:30:5d:52 brd ff:ff:ff:ff:ff:ff inet 192.168.1.3/24 brd 192.168.1.255 scope global dynamic noprefixroute enp0s8 valid_lft 86049sec preferred_lft 86049sec inet6 fe80::32b7:8727:bdf2:2f3/64 scope link noprefixroute valid_lft forever preferred_lft forever
1. How to use the ifconfig command to enable disabling the network card?
The ifconfig command is used to configure the network card.
If the network card needs to be enabled during system startup, the command to be called is ifconfig. Ifconfig can provide a lot of information about network cards. No matter what configuration we want to modify the network card, we can use this command.
Common syntax for ifconfig:
# ifconfig [NIC_NAME] Down/Up
Execute the following command to disable the enp0s3 network card. Note that you need to enter your own network card name here.
# ifconfig enp0s3 down
From the output below, you can see that the network card has been disabled.
# ip a | grep-A 1 "enp0s3:" 2: enp0s3: mtu 1500 qdisc fq_codel state DOWN group default qlen 1000 link/ether 08:00:27:c2:e4:e8 brd ff:ff:ff:ff:ff:ff
Execute the following command to enable the enp0s3 network card.
# ifconfig enp0s3 up
From the output below, you can see that the network card has been enabled.
# ip a | grep-A 5 "enp0s3:" 2: enp0s3: mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 08:00:27:c2:e4:e8 brd ff:ff:ff:ff:ff:ff inet 192.168.1.4 brd 24 brd 192.168.1.255 scope global dynamic noprefixroute enp0s3 valid_lft 86294sec preferred_lft 86294sec inet6 fe80::3899:270f:ae38:b433/64 scope link noprefixroute valid_lft forever preferred_lft forever
2. How to use the ifdown/up command to enable disabling the network card?
The ifdown command is used to disable the network card, and the ifup command is used to enable the network card.
Note: these two commands do not support new network devices named after enpXXX.
Common syntax for ifdown/ifup:
# ifdown [NIC_NAME] # ifup [NIC_NAME]
Execute the following command to disable the eth2 network card.
# ifdown eth2
From the output below, you can see that the network card has been disabled.
# ip a | grep-A 3 "eth2:" 3: eth2: mtu 1500 qdisc pfifo_fast state DOWN qlen 1000 link/ether 08:00:27:d5:a0:18 brd ff:ff:ff:ff:ff:ff
Execute the following command to enable the eth2 network card.
# ifup eth2
From the output below, you can see that the network card has been enabled.
# ip a | grep-A 5 "eth2:" 3: eth2: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:d5:a0:18 brd ff:ff:ff:ff:ff:ff inet 192.168.1.7and24 brd 192.168.1.255 scope global eth2 inet6 fe80::a00:27ff:fed5:a018/64 scope link tentative dadfailed valid_lft forever preferred_lft forever
Ifup and ifdown do not support network cards named after enpXXX. When the command is executed, the results are as follows:
# ifdown enp0s8Unknown interface enp0s8
3. How to use the ip command to enable disabling the network card?
The ip command is used to manage the network card and to replace the old, deprecated ifconfig command.
It is similar to the ifconfig command, but provides many powerful features that the ifconfig command does not have.
Common syntax for ip:
# ip link set Down/Up
Execute the following command to disable the enp0s3 network card.
# ip link set enp0s3 down
From the output below, you can see that the network card has been disabled.
# ip a | grep-A 1 "enp0s3:" 2: enp0s3: mtu 1500 qdisc fq_codel state DOWN group default qlen 1000 link/ether 08:00:27:c2:e4:e8 brd ff:ff:ff:ff:ff:ff
Execute the following command to enable the enp0s3 network card.
# ip link set enp0s3 up
From the output below, you can see that the network card has been enabled.
# ip a | grep-A 5 "enp0s3:" 2: enp0s3: mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 08:00:27:c2:e4:e8 brd ff:ff:ff:ff:ff:ff inet 192.168.1.4 brd 24 brd 192.168.1.255 scope global dynamic noprefixroute enp0s3 valid_lft 86294sec preferred_lft 86294sec inet6 fe80::3899:270f:ae38:b433/64 scope link noprefixroute valid_lft forever preferred_lft forever
4. How to use the nmcli command to enable disabling the network card?
Nmcli is a command-line tool that controls NetworkManager and reports the status of the network.
Nmcli can be used as an alternative to nm-applet or other graphical clients. It can be used to display, create, modify, delete, enable, and deactivate network connections. After that, it can also be used to manage and display the status of network devices.
In most cases, the nmcli command works with configuration name rather than device name. Therefore, execute the following command to get the configuration name corresponding to the network card. (LCTT translation note: when using nmtui or nmcli to manage network connections, you can configure a name for the network connection, which is the configuration name Profile name` mentioned here.)
# nmcli con showNAME UUID TYPE DEVICEWired connection 1 3d5afa0a-419a-3d1a-93e6-889ce9c6a18c ethernet enp0s3Wired connection 2 a22154b7-4cc4-3756-9d8d-da5a4318e146 ethernet enp0s8
Common syntax for nmcli:
# nmcli con Down/Up
Execute the following command to disable the enp0s3 network card. When disabling the network card, you need to use the configuration name instead of the device name.
# nmcli con down 'Wired connection 1'Connection' Wired connection 1' successfully deactivated (D-Bus active path: / org/freedesktop/NetworkManager/ActiveConnection/6)
From the output below, you can see that the network card has been disabled.
# nmcli dev statusDEVICE TYPE STATE CONNECTIONenp0s8 ethernet connected Wired connection 2enp0s3 ethernet disconnected-lo loopback unmanaged--
Execute the following command to enable the enp0s3 network card. Again, you need to use the configuration name instead of the device name here.
# nmcli con up 'Wired connection 1'Connection successfully activated (D-Bus active path: / org/freedesktop/NetworkManager/ActiveConnection/7)
From the output below, you can see that the network card has been enabled.
# nmcli dev statusDEVICE TYPE STATE CONNECTIONenp0s8 ethernet connected Wired connection 2enp0s3 ethernet connected Wired connection 1lo loopback unmanaged--
5. How to use the nmtui command to enable disabling the network card?
Nmtui is a terminal UI application that interacts with NetworkManager and is based on curses graphics library.
When nmtui is enabled, if the first parameter is not specifically specified, it guides the user to select the corresponding action to perform.
Execute the following command to open the mntui interface. Select "Active a connection" and click "OK".
# nmtui at this point, the study on "how to close the network card in linux" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.