Enabling and disabling network card through commandline
Since ifconfig
has been deprecated for many years now, you should probably use the ip
command :
To list the interfaces:
ip link
or with the ip addresses:
ip a
To take one down:
if=eth0
sudo ip link set $if down
use ifconfig
to view your ethernet or NIC ports (to get port names; eg. eth0 was the first port on my machine, next was eth1 etc)
to disable say port named eth0 use
sudo ifconfig eth0 down
to re-enable the port use
sudo ifconfig eth0 up
note: this disables (down) and enables (up) each port individually. if for example a NIC (network interface card) has four ports on a card, you need to enable/disable each port individually.
To see list of network cards:
lshw -C network
You will see all the network cards. Attention to logical name example:
logical name: wlp6s0
logical name: enp7s0
So just use ifconfig
to enable or disable it.
Examples:
-
Enable
sudo ifconfig wlp6s0 up
-
Disable:
sudo ifconfig enp7s0 down