I have a specific need to identify which interface a part of an octet (e.g. xx.xx.xx.112
) belongs to on a CentOS machine
My initial idea was to dump the output of ifconfig
and parse it manually to identify the corresponding interface. Is it the right approach or a better way exists to do this?
My crude attempt would be something like below in GNU grep
,
ifconfig | grep -B1 -E '\.112' | grep -oP 'e\w+:'