linux网络服务[网络配置]——————配置网络IP临时[ifconfig、ip]、永久[nmtui、nmcli、网络链接配置文件]

本文详细介绍了在Linux环境下,如何通过ifconfig、ip命令行工具以及nmtui、nmcli来临时和永久地配置网络IP。内容涵盖网卡设备查看、IP设置、网卡状态修改以及配置文件的编辑,适用于CentOS等Linux系统。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.临时设定

1.1 ifconfig命令

1.1.1 安装命令

在rhel7中,ifconfig需要自己安装才可以使用,我们可以查看自己是否已经安装:

[root@server ~]# rpm -qf /sbin/ifconfig
net-tools-2.0-0.17.20131004git.el7.x86_64

如果没有查询出来,使用yum进行安装:

[root@server ~]# yum whatprovides */ifconfig
Loaded plugins: langpacks
rhel7/filelists_db                                       | 3.0 MB     00:00     
net-tools-2.0-0.17.20131004git.el7.x86_64 : Basic networking tools
Repo        : rhel7
Matched from:
Filename    : /sbin/ifconfig # ficonfig命令包含在这个软件包中

[root@server ~]# yum install net-tools -y # 安装软件包

1.1.2 查看网卡设备

[root@server ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.25.5.10  netmask 255.255.255.0  broadcast 172.25.5.255
        inet6 fe80::5054:ff:fe00:50a  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:00:05:0a  txqueuelen 1000  (Ethernet)
        RX packets 413  bytes 3144511 (2.9 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 308  bytes 32690 (31.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 52:54:00:d3:36:54  txqueuelen 1000  (Ethernet)
        RX packets 41  bytes 5284 (5.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 52:54:00:e1:dc:0e  txqueuelen 1000  (Ethernet)
        RX packets 41  bytes 5284 (5.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 30  bytes 1948 (1.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 30  bytes 1948 (1.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

这里有三块物理网卡eth0、eth1、eth2,lo为回环接口,代表自己本身。

1.1.3 设置IP

ifconfig使用以下命令,这里设定的是临时IP,重启失效:

ifc
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值