linux 查看网卡
来源:互联网 发布:bootstrap 可视化软件 编辑:程序博客网 时间:2024/05/21 04:21
查看当前的ip所绑网卡是哪一个:
/sbin/route -n | grep "^0.0.0.0" | rev | cut -d' ' -f1 | rev
Use grep
to filter IP address from ifconfig
:
ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'
Or with sed
:
ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'
If you are only interested in certain interfaces, wlan0, eth0, etc. then:
ifconfig wlan0 | ...
You can alias the command in your .bashrc
to create your own command called myip
for instance.
alias myip="ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'"
A much simpler way is hostname -I
. However, this is on Linux only.
hostname --ip-address
This doesn't rely on DNS at all, and it works even if /etc/hosts
is not set correctly (1
is shorthand for 1.0.0.0
):
ip route get 1 | awk '{print $NF;exit}'
or avoiding awk
and using Google's public DNS at 8.8.8.8
for obviousness:
ip route get 8.8.8.8 | head -1 | cut -d' ' -f8
A less reliable way: (see comment below)
hostname -I | cut -d' ' -f1
hostname -i hostname -I
/sbin/ip -4 -o addr show dev eth0| awk '{split($4,a,"/");print a[1]}'
- linux 查看有几块网卡
- linux查看网卡信息
- Linux查看网卡芯片型号
- linux查看网卡驱动
- linux 查看网卡流量
- Linux 查看网卡流量
- linux 查看网卡流量
- linux查看网卡
- linux 查看网卡流量
- linux查看网卡速率
- 查看Linux网卡流量
- linux 查看网卡
- linux ifconfig 查看网卡
- linux查看网卡驱动
- linux 查看网卡以及开启网卡
- linux查看网卡是否连接
- Linux 如何查看网卡流量
- linux下网卡流量查看
- 001-开始golang开发之旅
- redis常用命令(高级篇)
- javah 错误: 找不到 'XX' 的类文件或Exception in thread "main" name: XX.class
- DedeCms登录后台时一片空白解决方法
- redis中list类型详解及常用命令
- linux 查看网卡
- redis无序集合set类型详解
- redis有序集合sorted set详解
- Windows7 系统下设置Nodejs NPM全局路径
- redis中hash类型介绍
- 在windows上创建文件名以“.”开头的文件
- sorted
- redis命令大全参考手册
- numpy sum