Linux设置和查看静态IP之ifconfig命令(linux查看ip命令)

1. ifconfig命令简介

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

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

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

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

总下载量: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

完毕!

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

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

3. 禁用和启动网卡

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

或者:

[root@zcwyou ~]# ifdown ens33 && ifup ens33

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。

发布于 2021-12-08 22:17:13
收藏
分享
海报
0 条评论
89
上一篇:3分钟就能搞定黑屏蓝屏(电脑蓝屏重启后黑屏) 下一篇:win10怎样获取管理员权限详细教程(win10管理员权限怎么获取)
目录

    推荐阅读

    0 条评论

    本站已关闭游客评论,请登录或者注册后再评论吧~

    忘记密码?

    图形验证码