# 使用 ifconfig 命令查看内网 IP 地址
ifconfig
# 或者使用 ip addr 命令查看内网 IP 地址
ip addr
# 解释:
# 1. ifconfig:这是一个传统的命令,用于显示和配置网络接口。它会列出所有网络接口及其对应的 IP 地址。
# 2. ip addr:这是较新的命令,功能更强大且灵活。它同样可以列出所有网络接口及其对应的 IP 地址。
# 如果你只想查看特定的内网 IP 地址(例如 eth0 网卡),可以使用以下命令:
ifconfig eth0
# 或者
ip addr show eth0如果你需要更简洁的输出,可以使用以下命令:
# 使用 ifconfig 并结合 grep 和 awk 提取内网 IP 地址
ifconfig | grep -o 'inet [0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+' | grep -v '127.0.0.1'
# 或者使用 ip addr 并结合 grep 和 awk 提取内网 IP 地址
ip addr | grep -o 'inet [0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+/[0-9]\+' | grep -v '127.0.0.1' | cut -d' ' -f2这些命令会过滤掉回环地址(127.0.0.1),并只显示内网 IP 地址。
上一篇:linux crontab日志
下一篇:linux文件中查找关键字
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站