search
HomeOperation and MaintenanceLinux Operation and MaintenanceHow to turn off the network card in linux

Method: 1. Use the ifconfig command to turn off the network card, the syntax is "ifconfig network card name down"; 2. Use the ifdown command to turn off the network card, the syntax is "ifdown network card name"; 3. Use the ip command to turn off the network card, the syntax For "ip link set network card name down"

How to turn off the network card in linux

The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

How to turn off the network card in Linux

You may execute the following commands according to your needs. I'll list some examples here of where you might use these commands.

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 modifications 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’ll go over the top 5 methods we’ve used.

Enabling and disabling the network card can be accomplished using the following 5 methods:

  • ifconfig command: used to configure the network card. It can provide a lot of information about the network card.

  • ifdown/up command: ifdown command is used to disable the network card, and ifup command is used to enable the network card.

  • ip command: used to manage network cards, replacing the old and deprecated ifconfig command. It is very similar to the ifconfig command, but provides many powerful features that the ifconfig command does not have.

  • nmcli command: is a command line tool that controls NetworkManager and reports network status.

  • nmtui command: It is a terminal UI application based on the curses graphics library that interacts with NetworkManager.

The following shows the information about the network cards available in my Linux system.

# ip a
1: 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 forever
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/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 forever
3: 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 or disable the network card?

The ifconfig command is used to configure the network card.

If you need to enable the network card during system startup, the command to call is ifconfig. ifconfig can provide a lot of network card information. No matter what configuration we want to modify the network card, we can use this command.

Common syntax of 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

You can see from the following output 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

You can see from the following output 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/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 or disable 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 enpXXX.

Common syntax for ifdown/ifup:

# ifdown [NIC_NAME]
# ifup [NIC_NAME]

Execute the following command to disable the eth1 network card.

# ifdown eth1

You can see from the following output that the network card has been disabled.

# ip a | grep -A 3 "eth1:"
3: eth1:  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 eth1 network card.

# ifup eth1

You can see from the following output that the network card has been enabled.

# ip a | grep -A 5 "eth1:"
3: eth1:  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.7/24 brd 192.168.1.255 scope global eth1
    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 enpXXX. When executing this command, the results obtained are as follows:

# ifdown enp0s8
Unknown interface enp0s8

3. How to use the ip command to enable or disable the network card?

The ip command is used to manage network cards and replaces the old and deprecated ifconfig command.

It is very 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

You can see from the following output 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

You can see from the following output 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/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 nmcli command to enable or disable the network card?

nmcli is a command line tool that controls NetworkManager and reports network status.

nmcli can be used as a replacement for nm-applet or other graphical clients. It can be used to display, create, modify, delete, enable and deactivate network connections. In addition to this, it can also be used to manage and display network device status.

nmcli commands work in most cases using "configuration name" instead of "device name". Therefore, execute the following command to obtain the configuration name corresponding to the network card. (LCTT Translation: 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 show
NAME                UUID                                  TYPE      DEVICE
Wired connection 1  3d5afa0a-419a-3d1a-93e6-889ce9c6a18c  ethernet  enp0s3
Wired 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 a network card, you need to use the configuration name rather than the device name.

# nmcli con down 'Wired connection 1'
Connection 'Wired connection 1' successfully deactivated 
(D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)

You can see from the following output that the network card has been disabled.

# nmcli dev status
DEVICE  TYPE      STATE         CONNECTION
enp0s8  ethernet  connected     Wired connection 2
enp0s3  ethernet  disconnected  --
lo      loopback  unmanaged     --

Execute the following command to enable the enp0s3 network card. Again, here you need to use the configuration name instead of the device name.

# nmcli con up 'Wired connection 1'
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)

You can see from the following output that the network card has been enabled.

# nmcli dev status
DEVICE  TYPE      STATE      CONNECTION
enp0s8  ethernet  connected  Wired connection 2
enp0s3  ethernet  connected  Wired connection 1
lo      loopback  unmanaged  --

5. How to use the nmtui command to enable or disable the network card?

nmtui 是一个与 NetworkManager 交互的、基于 curses 图形库的终端 UI 应用。

在启用 nmtui 的时候,如果第一个参数没有特别指定,它会引导用户选择对应的操作去执行。

执行以下命令打开 mntui 界面。选择 “Active a connection” 然后点击 “OK”。

# nmtui

相关推荐:《Linux视频教程

The above is the detailed content of How to turn off the network card in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Linux Operations: Understanding the Core FunctionalityLinux Operations: Understanding the Core FunctionalityMay 03, 2025 am 12:09 AM

Linux is a Unix-based multi-user, multi-tasking operating system that emphasizes simplicity, modularity and openness. Its core functions include: file system: organized in a tree structure, supports multiple file systems such as ext4, XFS, Btrfs, and use df-T to view file system types. Process management: View the process through the ps command, manage the process using PID, involving priority settings and signal processing. Network configuration: Flexible setting of IP addresses and managing network services, and use sudoipaddradd to configure IP. These features are applied in real-life operations through basic commands and advanced script automation, improving efficiency and reducing errors.

Linux: Entering and Exiting Maintenance ModeLinux: Entering and Exiting Maintenance ModeMay 02, 2025 am 12:01 AM

The methods to enter Linux maintenance mode include: 1. Edit the GRUB configuration file, add "single" or "1" parameters and update the GRUB configuration; 2. Edit the startup parameters in the GRUB menu, add "single" or "1". Exit maintenance mode only requires restarting the system. With these steps, you can quickly enter maintenance mode when needed and exit safely, ensuring system stability and security.

Understanding Linux: The Core Components DefinedUnderstanding Linux: The Core Components DefinedMay 01, 2025 am 12:19 AM

The core components of Linux include kernel, shell, file system, process management and memory management. 1) Kernel management system resources, 2) shell provides user interaction interface, 3) file system supports multiple formats, 4) Process management is implemented through system calls such as fork, and 5) memory management uses virtual memory technology.

The Building Blocks of Linux: Key Components ExplainedThe Building Blocks of Linux: Key Components ExplainedApr 30, 2025 am 12:26 AM

The core components of the Linux system include the kernel, file system, and user space. 1. The kernel manages hardware resources and provides basic services. 2. The file system is responsible for data storage and organization. 3. Run user programs and services in the user space.

Using Maintenance Mode: Troubleshooting and Repairing LinuxUsing Maintenance Mode: Troubleshooting and Repairing LinuxApr 29, 2025 am 12:28 AM

Maintenance mode is a special operating level entered in Linux systems through single-user mode or rescue mode, and is used for system maintenance and repair. 1. Enter maintenance mode and use the command "sudosystemctlisolaterscue.target". 2. In maintenance mode, you can check and repair the file system and use the command "fsck/dev/sda1". 3. Advanced usage includes resetting the root user password, mounting the file system in read and write mode and editing the password file.

Linux Maintenance Mode: Understanding the PurposeLinux Maintenance Mode: Understanding the PurposeApr 28, 2025 am 12:01 AM

Maintenance mode is used for system maintenance and repair, allowing administrators to work in a simplified environment. 1. System Repair: Repair corrupt file system and boot loader. 2. Password reset: reset the root user password. 3. Package management: Install, update or delete software packages. By modifying the GRUB configuration or entering maintenance mode with specific keys, you can safely exit after performing maintenance tasks.

Linux Operations: Networking and Network ConfigurationLinux Operations: Networking and Network ConfigurationApr 27, 2025 am 12:09 AM

Linux network configuration can be completed through the following steps: 1. Configure the network interface, use the ip command to temporarily set or edit the configuration file persistence settings. 2. Set up a static IP, suitable for devices that require a fixed IP. 3. Manage the firewall and use the iptables or firewalld tools to control network traffic.

Maintenance Mode in Linux: A System Administrator's GuideMaintenance Mode in Linux: A System Administrator's GuideApr 26, 2025 am 12:20 AM

Maintenance mode plays a key role in Linux system management, helping to repair, upgrade and configuration changes. 1. Enter maintenance mode. You can select it through the GRUB menu or use the command "sudosystemctlisolaterscue.target". 2. In maintenance mode, you can perform file system repair and system update operations. 3. Advanced usage includes tasks such as resetting the root password. 4. Common errors such as not being able to enter maintenance mode or mount the file system, can be fixed by checking the GRUB configuration and using the fsck command.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version