如何确定Solaris系统的IP地址

时间:2022-06-01 21:34:47

What command do I want to issue when I want to know the IP address of the Solaris machine I'm logged onto?

当我想知道我登录的Solaris机器的IP地址时,我想发出什么命令?

8 个解决方案

#1


If you're a normal user (i.e., not 'root') ifconfig isn't in your path, but it's the command you want.

如果您是普通用户(即,不是'root'),ifconfig不在您的路径中,但它是您想要的命令。

More specifically: /usr/sbin/ifconfig -a

更具体地说:/ usr / sbin / ifconfig -a

#2


/usr/sbin/ifconfig -a | awk 'BEGIN { count=0; } { if ( $1 ~ /inet/ ) { count++; if( count==2 ) { print $2; } } }'

This will list down the exact ip address for the machine

这将列出机器的确切IP地址

#3


The following worked pretty well for me:

以下对我来说效果很好:

ping -s my_host_name

#4


The following shell script gives a nice tabular result of interfaces and IP addresses (excluding the loopback interface) It has been tested on a Solaris box

以下shell脚本提供了一个很好的表格结果,包括接口和IP地址(不包括环回接口)它已在Solaris机箱上测试过

/usr/sbin/ifconfig -a | awk '/flags/ {printf $1" "} /inet/ {print $2}' | grep -v lo

ce0: 10.106.106.108
ce0:1: 10.106.106.23
ce0:2: 10.106.106.96
ce1: 10.106.106.109

#5


hostname and uname will give you the name of the host. Then use nslookup to translate that to an IP address.

hostname和uname将为您提供主机的名称。然后使用nslookup将其转换为IP地址。

#6


There's also:

getent $HOSTNAME

or possibly:

getent `uname -n`

On Solaris 11 the ifconfig command is considered legacy and is being replaced by ipadm

在Solaris 11上,ifconfig命令被认为是遗留的,并且正在被ipadm取代

ipadm show-addr

will show the IP addresses on the system for Solaris 11 and later.

将显示Solaris 11及更高版本的系统上的IP地址。

#7


Try using ifconfig -a. Look for "inet xxx.xxx.xxx.xxx", that is your IP address

尝试使用ifconfig -a。查找“inet xxx.xxx.xxx.xxx”,这是您的IP地址

#8


/usr/sbin/host `hostname`

should do the trick. Bear in mind that it's a pretty common configuration for a solaris box to have several IP addresses, though, in which case

应该做的伎俩。请记住,对于具有多个IP地址的solaris盒来说,这是一种非常常见的配置,在这种情况下

 /usr/sbin/ifconfig -a inet | awk '/inet/ {print $2}'

will list them all

将列出所有

#1


If you're a normal user (i.e., not 'root') ifconfig isn't in your path, but it's the command you want.

如果您是普通用户(即,不是'root'),ifconfig不在您的路径中,但它是您想要的命令。

More specifically: /usr/sbin/ifconfig -a

更具体地说:/ usr / sbin / ifconfig -a

#2


/usr/sbin/ifconfig -a | awk 'BEGIN { count=0; } { if ( $1 ~ /inet/ ) { count++; if( count==2 ) { print $2; } } }'

This will list down the exact ip address for the machine

这将列出机器的确切IP地址

#3


The following worked pretty well for me:

以下对我来说效果很好:

ping -s my_host_name

#4


The following shell script gives a nice tabular result of interfaces and IP addresses (excluding the loopback interface) It has been tested on a Solaris box

以下shell脚本提供了一个很好的表格结果,包括接口和IP地址(不包括环回接口)它已在Solaris机箱上测试过

/usr/sbin/ifconfig -a | awk '/flags/ {printf $1" "} /inet/ {print $2}' | grep -v lo

ce0: 10.106.106.108
ce0:1: 10.106.106.23
ce0:2: 10.106.106.96
ce1: 10.106.106.109

#5


hostname and uname will give you the name of the host. Then use nslookup to translate that to an IP address.

hostname和uname将为您提供主机的名称。然后使用nslookup将其转换为IP地址。

#6


There's also:

getent $HOSTNAME

or possibly:

getent `uname -n`

On Solaris 11 the ifconfig command is considered legacy and is being replaced by ipadm

在Solaris 11上,ifconfig命令被认为是遗留的,并且正在被ipadm取代

ipadm show-addr

will show the IP addresses on the system for Solaris 11 and later.

将显示Solaris 11及更高版本的系统上的IP地址。

#7


Try using ifconfig -a. Look for "inet xxx.xxx.xxx.xxx", that is your IP address

尝试使用ifconfig -a。查找“inet xxx.xxx.xxx.xxx”,这是您的IP地址

#8


/usr/sbin/host `hostname`

should do the trick. Bear in mind that it's a pretty common configuration for a solaris box to have several IP addresses, though, in which case

应该做的伎俩。请记住,对于具有多个IP地址的solaris盒来说,这是一种非常常见的配置,在这种情况下

 /usr/sbin/ifconfig -a inet | awk '/inet/ {print $2}'

will list them all

将列出所有