ifconfig 命令用于显示网络接口、子网掩码等详细信息
来源:互联网 发布:java语言培训机构 编辑:程序博客网 时间:2024/06/14 14:21
当输入ifconfig的时候,有时候会出现“command not found”
这是因为/sbin没有包含在用户的PATH环境变量中。
这时候可以使用绝对路径:/sbin/ifconfig
举例:
[root@test temp]# ifconfig
bash: ifconfig: command not found
[root@test temp]# /sbin/ifconfig
eth0 Link encap:Ethernet HWaddr 00:16:3E:46:81:7C
inet addr:10.10.1.7 Bcast:159.226.11.255 Mask:255.255.255.0
inet6 addr: 2001:cc0:2004:2:216:3eff:fe46:817c/64 Scope:Global
inet6 addr: 2001:cc0:2004:1:216:3eff:fe46:817c/64 Scope:Global
inet6 addr: fe80::216:3eff:fe46:817c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:72003835 errors:0 dropped:0 overruns:0 frame:0
TX packets:1028769 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6360373372 (5.9 GiB) TX bytes:422728999 (403.1 MiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1817608 errors:0 dropped:0 overruns:0 frame:0
TX packets:1817608 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:596239246 (568.6 MiB) TX bytes:596239246 (568.6 MiB)
[root@test temp]#
其中lo是系统默认的一个称之为环回接口,这个接口只想当前主机本身。
打印网络接口列表:
[root@test temp]# /sbin/ifconfig | cut -c-10 | tr -d ' ' | tr -s '\n'
eth0
lo
[root@test temp]#
上述命令的含义是:ifconfig输出到前10个字符是被保留用于打印网络接口的名称,因此我们用cut命令提取每一行的前10个字符。tr -d ' ' 删除每一行的所有空格。用tr -s '\n' 压缩重复的换行符生成接口名称列表。
我们可以限制它显示某个特定的接口信息,举例如下:
[root@test temp]# /sbin/ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:16:3E:46:81:7C
inet addr:159.226.11.45 Bcast:159.226.11.255 Mask:255.255.255.0
inet6 addr: 2001:cc0:2004:2:216:3eff:fe46:817c/64 Scope:Global
inet6 addr: 2001:cc0:2004:1:216:3eff:fe46:817c/64 Scope:Global
inet6 addr: fe80::216:3eff:fe46:817c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:72012532 errors:0 dropped:0 overruns:0 frame:0
TX packets:1029111 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6361165051 (5.9 GiB) TX bytes:422755607 (403.1 MiB)
[root@test temp]#
从ifconfig中提取ip地址,如下:
[root@test temp]# /sbin/ifconfig eth0 | egrep -o "inet addr:[^ ]*" | grep -o "[0-9.] *"
10.10.1.7
[root@test temp]#
- ifconfig 命令用于显示网络接口、子网掩码等详细信息
- ifconfig命令及网络接口
- 安装ifconfig等命令
- linux 网络命令ifconfig
- linux网络命令 ifconfig
- ifconfig 用于查看和更改TCP/IP网络接口的地址和参数
- Fedora ifconfig配置网络接口
- ifconfig 配置网络接口用法
- 显示文件详细信息的命令
- linux网络命令之ifconfig
- [学习笔记] 网络命令Ifconfig
- Linux 网络命令ifconfig 详解
- linux网络命令详解ifconfig
- linux 网络命令之ifconfig
- linux网络命令--1--ifconfig
- Linux ifconfig --网络配置命令
- Ubuntu网络接口配置文件:nano/etc/network/interfaces 以及 Ifconfig只显示一个lo
- Ubuntu16.04字符界面ifconfig命令无网络接口ens33的解决方法
- HexEdit Linux下命令集
- linux-kernel 3.5.3Tcp系统调用,源码分析5-原子操作
- Action从jsp页面取值的<input id="user.pid",name="user.pid" value="huang">
- 64win7 64位oracle
- C#中用switch case 实现if(a== 1 || a == 2)的效果
- ifconfig 命令用于显示网络接口、子网掩码等详细信息
- 黑马程序员 20 Java基础加强-02-反射篇
- cocos2d-x c++通知android更新UI
- clang的编译和使用
- mysql 重定义分隔符
- 新手学Java 7编程(第5版)
- eclipse开发hadoop hdfs api 运行错误
- extjs 动态表格
- Java安全停止线程方法