macOS & ifconfig command All In One
IP address / ipconfig
ifconfig
$ ifconfig
# usage: ipconfig <command> <args>
# where <command> is one of waitall, getifaddr, ifcount, getoption, getiflist, getsummary, getpacket, getv6packet, getra, set, setverbose
$ man ifconfig
IPCONFIG(8) System Manager's Manual IPCONFIG(8)
NAME
ipconfig – view and control IP configuration state
SYNOPSIS
ipconfig waitall
ipconfig getifaddr interface-name
ipconfig ifcount
ipconfig getoption interface-name (option-name | option-code)
ipconfig getpacket interface-name
ipconfig getv6packet interface-name
ipconfig getra interface-name
ipconfig setverbose level
ipconfig set interface-name NONE
ipconfig set interface-name (DHCP | BOOTP)
ipconfig set interface-name (MANUAL | INFORM) ip-address subnet-mask
ipconfig set interface-name NONE-V6
ipconfig set interface-name AUTOMATIC-V6
ipconfig set interface-name MANUAL-V6 ipv6-address prefix-length
ipconfig set interface-name 6TO4
DESCRIPTION
$ ipconfig getifaddr
# usage: ipconfig getifaddr <interface name>
$ ipconfig getifaddr en0
# 192.168.18.207
get localhost IP address
$ ipconfig getifaddr en0
# 192.168.18.207
grep
# ifconfig filter the localhost ip address
$ ifconfig en0
# `空格`,过滤掉 IPv6 `inet6` ✅
$ ifconfig en0 | grep "inet "
# 不过滤
$ ifconfig en0 | grep "inet"
# 等价于
$ ifconfig en0 | grep inet
refs
如何在 Apple Mac 上获得 IP 地址 All In One
https://www.cnblogs.com/xgqfrms/p/16127607.html
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载
标签:macOS,set,name,ipconfig,ifconfig,command,getifaddr,interface From: https://www.cnblogs.com/xgqfrms/p/16792005.html