Linux 如何通过 iscsi target name 获取 ip
Posted liujx2019
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux 如何通过 iscsi target name 获取 ip相关的知识,希望对你有一定的参考价值。
by Mike Andrews
# lsscsi -t [2:0:0:0] disk iqn.2009-12.com.blockbridge:t-pjxfzufjkp-illoghjk,t,0x1 /dev/sda [3:0:0:0] disk iqn.2009-12.com.blockbridge:t-pjxfzuecga-eajejghg,t,0x1 /dev/sdb [4:0:0:0] disk iqn.2009-12.com.blockbridge:t-pjxfzufjjo-pokqaja,t,0x1 /dev/sdd [5:0:0:0] disk iqn.2009-12.com.blockbridge:t-pjxfzufnfg-cqikkgl,t,0x1 /dev/sdc
# iscsiadm -m node -T iqn.2009-12.com.blockbridge:t-pjxfzufjkp-illoghjk | egrep ‘node.conn.+address‘ node.conn[0].address = 172.16.5.148
#!/usr/bin/bash if [[ -z $1 ]]; then >&2 echo "Usage: devip.sh <device>" exit 1 fi iqn=$(sudo lsscsi -t | grep "$1" | grep iqn | awk ‘print $3‘ | awk -F , ‘print $1‘) if [[ -z "$iqn" ]]; then >&2 echo "IQN not found for \"$1\"." exit 1 fi sudo iscsiadm -m node -T $iqn | egrep ‘node.conn.+address‘ | awk -F ‘ *= *‘ ‘print $2‘ exit $?
以上是关于Linux 如何通过 iscsi target name 获取 ip的主要内容,如果未能解决你的问题,请参考以下文章
[Linux] Configure iSCSI on Linux5 (both target and initiator)