温馨提示×

linux ifconfig如何重启网络

小樊
58
2026-09-23 06:54:14
栏目: 智能运维

在 Linux 中,ifconfig 本身不能重启网络,它只能查看和配置网络接口。要“重启网络”,通常有以下几种方式(取决于发行版和版本):


一、使用 ifconfig + 关闭/启动网卡(最基础)

如果你只是想重启某个网卡(如 eth0):

sudo ifconfig eth0 down
sudo ifconfig eth0 up

或等价写法:

sudo ifdown eth0
sudo ifup eth0

⚠️ ifdown / ifup 依赖 /etc/network/interfaces(Debian 系)


二、Debian / Ubuntu(老版本)

sudo /etc/init.d/networking restart

或

sudo service networking restart

三、Ubuntu 16.04+ / 使用 systemd

sudo systemctl restart networking

如果是 Netplan(Ubuntu 18.04+):

sudo netplan apply

四、CentOS / RHEL

CentOS 6

service network restart

CentOS 7 / 8

systemctl restart network

或针对某个网卡:

nmcli connection down eth0
nmcli connection up eth0

五、通用(不推荐但可用)

sudo reboot

六、查看网卡名

ifconfig -a

或

ip addr

如果你能告诉我:

  • 发行版(Ubuntu / CentOS / Debian)
  • 版本号
  • 是想重启整台机器网络还是单个网卡

我可以给你最准确的一条命令 ✅

0 踩