ifconfig查看ip_Linux设置和查看静态IP之ifconfig命令

请关注本头条号,每天坚持更新原创干货技术文章。

如需学习视频,请在微信搜索公众号“智传网优”直接开始自助视频学习

1. ifconfig命令简介

Linux系统中使用ifconfig命令查看和修改IP信息。但新系统建议使用ip命令。

CentOS 7 开始,已经废弃了ifconfig命令,ifconfig命令由net-tools套件提供。

CentOS 7默认并没有安装这个套件,需要手动额外安装。

[root@zcwyou ~]# yum -y install net-tools
b4ef955ce129ea114676e325483bf1b6.png

总下载量:306 k

安装大小:918 k

Downloading packages:

net-tools-2.0-0.24.20131004git.el7.x86_64.rpm | 306 kB 00:00:00

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

正在安装 : net-tools-2.0-0.24.20131004git.el7.x86_64 1/1

验证中 : net-tools-2.0-0.24.20131004git.el7.x86_64 1/1

已安装:

net-tools.x86_64 0:2.0-0.24.20131004git.el7

完毕!

168c4391c7b04ff69373dcf2a101be9f.png

linux安装ifconfig命令

2. 查看网卡信息,包括IP信息以及入口流量信息和出口流量信息

[root@zcwyou ~]# ifconfig

ens160: flags=4163 mtu 1500

inet 113.105.164.151 netmask 255.255.255.192 broadcast 113.105.164.191

inet6 fe80::4e97:36a0:c406:6ac1 prefixlen 64 scopeid 0x20

ether 00:0c:29:dc:f4:8f txqueuelen 1000 (Ethernet)

RX packets 143511935 bytes 146703282343 (136.6 GiB)

RX errors 0 dropped 779125 overruns 0 frame 0

TX packets 92937512 bytes 141760328247 (132.0 GiB)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73 mtu 65536

inet 127.0.0.1 netmask 255.0.0.0

inet6 ::1 prefixlen 128 scopeid 0x10

loop txqueuelen 1000 (Local Loopback)

RX packets 52922204 bytes 139829819707 (130.2 GiB)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 52922204 bytes 139829819707 (130.2 GiB)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

b4f8c9cc61853f686d8ce122b685de6d.png

linux使用ifconfig查看网卡与IP地址信息

3. 禁用和启动网卡

[root@zcwyou ~]# ifconfig eth0 down[root@zcwyou ~]# ifconfig eth0 up

或者:

[root@zcwyou ~]# ifdown ens33 && ifup ens33
4bee77ae7d5418848a8d8aff6b8cfe71.png

linux禁用和重新启动网卡

4. 配置网卡的IP地址与广播地址

[root@zcwyou ~]# ifconfig eth0 172.16.26.88 netmask 255.255.255.0 broadcast 172.16.26.255

5. 修改mtu大小

[root@zcwyou ~]# ifconfig eth0 mtu 1500 

6. 总结

ifdown命令是net-tools套件之一,但目前已经不建议使用net-tools套件了,因为已经有了iproute2这个现代的网络管理工具。CentOS7开始,默认已经不再集成net-tools,而是集成了iproute2。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值