神戸学院大学 経営学部 林坂ゼミ

CLI 入門トップページ

« 戻る 次へ »

PowerShell

ネットワーク関連コマンドレット

ネットワーク設定の取得 (Get-NetIPAddress)

Windowsのネットワーク設定を取得するためのコマンドレットのひとつが「Get-NetIPConfiguration」です.

PS C:\Users\rinsaka\Documents> Get-NetIPConfiguration ⏎


InterfaceAlias       : Wi-Fi
InterfaceIndex       : 5
InterfaceDescription : Killer Wireless-n/a/ac 1435 Wireless Network Adapter
NetProfile.Name      : ??????
IPv4Address          : 10.195.18.124
IPv6DefaultGateway   :
IPv4DefaultGateway   : 10.195.31.254
DNSServer            : 10.0.0.232
                       10.0.0.221

InterfaceAlias       : Bluetooth ネットワーク接続
InterfaceIndex       : 18
InterfaceDescription : Bluetooth Device (Personal Area Network)
NetAdapter.Status    : Disconnected



PS C:\Users\rinsaka\Documents>

他にも「Get-NetIPAddress」もあります.

PS C:\Users\rinsaka\Documents> Get-NetIPAddress ⏎


IPAddress         : fe80::ebfd:74ea:eff7:1ccf%9
InterfaceIndex    : 9
InterfaceAlias    : ローカル エリア接続* 2
AddressFamily     : IPv6
Type              : Unicast
PrefixLength      : 64
PrefixOrigin      : WellKnown
SuffixOrigin      : Link
AddressState      : Deprecated
ValidLifetime     :
PreferredLifetime :
SkipAsSource      : False
PolicyStore       : ActiveStore

IPAddress         : fe80::ff4b:c9d5:c2dd:5f9d%15
InterfaceIndex    : 15
InterfaceAlias    : ローカル エリア接続* 1
AddressFamily     : IPv6
Type              : Unicast
PrefixLength      : 64
PrefixOrigin      : WellKnown
SuffixOrigin      : Link
AddressState      : Deprecated
ValidLifetime     :
PreferredLifetime :
SkipAsSource      : False
PolicyStore       : ActiveStore

IPAddress         : fe80::28ca:c1e5:a651:c157%18
InterfaceIndex    : 18
InterfaceAlias    : Bluetooth ネットワーク接続
AddressFamily     : IPv6
Type              : Unicast
PrefixLength      : 64
PrefixOrigin      : WellKnown
SuffixOrigin      : Link
AddressState      : Deprecated
ValidLifetime     :
PreferredLifetime :
SkipAsSource      : False
PolicyStore       : ActiveStore

IPAddress         : ::1
InterfaceIndex    : 1
InterfaceAlias    : Loopback Pseudo-Interface 1
AddressFamily     : IPv6
Type              : Unicast
PrefixLength      : 128
PrefixOrigin      : WellKnown
SuffixOrigin      : WellKnown
AddressState      : Preferred
ValidLifetime     :
PreferredLifetime :
SkipAsSource      : False
PolicyStore       : ActiveStore

IPAddress         : fe80::c608:b28b:d2f1:72c8%5
InterfaceIndex    : 5
InterfaceAlias    : Wi-Fi
AddressFamily     : IPv6
Type              : Unicast
PrefixLength      : 64
PrefixOrigin      : WellKnown
SuffixOrigin      : Link
AddressState      : Preferred
ValidLifetime     :
PreferredLifetime :
SkipAsSource      : False
PolicyStore       : ActiveStore

IPAddress         : 169.254.243.97
InterfaceIndex    : 9
InterfaceAlias    : ローカル エリア接続* 2
AddressFamily     : IPv4
Type              : Unicast
PrefixLength      : 16
PrefixOrigin      : WellKnown
SuffixOrigin      : Link
AddressState      : Tentative
ValidLifetime     :
PreferredLifetime :
SkipAsSource      : False
PolicyStore       : ActiveStore

IPAddress         : 169.254.229.29
InterfaceIndex    : 15
InterfaceAlias    : ローカル エリア接続* 1
AddressFamily     : IPv4
Type              : Unicast
PrefixLength      : 16
PrefixOrigin      : WellKnown
SuffixOrigin      : Link
AddressState      : Tentative
ValidLifetime     :
PreferredLifetime :
SkipAsSource      : False
PolicyStore       : ActiveStore

IPAddress         : 169.254.251.149
InterfaceIndex    : 18
InterfaceAlias    : Bluetooth ネットワーク接続
AddressFamily     : IPv4
Type              : Unicast
PrefixLength      : 16
PrefixOrigin      : WellKnown
SuffixOrigin      : Link
AddressState      : Tentative
ValidLifetime     :
PreferredLifetime :
SkipAsSource      : False
PolicyStore       : ActiveStore

IPAddress         : 127.0.0.1
InterfaceIndex    : 1
InterfaceAlias    : Loopback Pseudo-Interface 1
AddressFamily     : IPv4
Type              : Unicast
PrefixLength      : 8
PrefixOrigin      : WellKnown
SuffixOrigin      : WellKnown
AddressState      : Preferred
ValidLifetime     :
PreferredLifetime :
SkipAsSource      : False
PolicyStore       : ActiveStore

IPAddress         : 10.195.18.124
InterfaceIndex    : 5
InterfaceAlias    : Wi-Fi
AddressFamily     : IPv4
Type              : Unicast
PrefixLength      : 19
PrefixOrigin      : Dhcp
SuffixOrigin      : Dhcp
AddressState      : Preferred
ValidLifetime     : 17:39:37
PreferredLifetime : 17:39:37
SkipAsSource      : False
PolicyStore       : ActiveStore



PS C:\Users\rinsaka\Documents>

目次に戻る

ネットワーク接続の確認 (ping)

ネットワークの接続状態は確認するには「ping」コマンドを利用すると良いでしょう.IPアドレスやドメイン名を指定して実行すると,ネットワークを経由して指定したノードまでパケットが到着してその返答があるかどうかを確認することができます.

PS C:\Users\rinsaka\Documents> ping 10.195.31.254 ⏎

10.195.31.254 に ping を送信しています 32 バイトのデータ:
10.195.31.254 からの応答: バイト数 =32 時間 =4ms TTL=64
10.195.31.254 からの応答: バイト数 =32 時間 =5ms TTL=64
10.195.31.254 からの応答: バイト数 =32 時間 =4ms TTL=64
10.195.31.254 からの応答: バイト数 =32 時間 =5ms TTL=64

10.195.31.254 の ping 統計:
    パケット数: 送信 = 4、受信 = 4、損失 = 0 (0% の損失)、
ラウンド トリップの概算時間 (ミリ秒):
    最小 = 4ms、最大 = 5ms、平均 = 4ms
PS C:\Users\rinsaka\Documents>

指定したIPアドレスにパケットが届かない場合は次のような結果になります.下の例ではIPアドレスが「10.195.31.253」のノード(コンピュータ)が存在しないため,パケットが届きません.これ以外にもノードが存在してパケットが到達するが,そのノードがセキュリティ等の理由で ping に返答しないよう設定されている場合も同じ結果になります.

PS C:\Users\rinsaka\Documents> ping 10.195.31.253 ⏎

10.195.31.253 に ping を送信しています 32 バイトのデータ:
10.195.18.124 からの応答: 宛先ホストに到達できません。
10.195.18.124 からの応答: 宛先ホストに到達できません。
10.195.18.124 からの応答: 宛先ホストに到達できません。
10.195.18.124 からの応答: 宛先ホストに到達できません。

10.195.31.253 の ping 統計:
    パケット数: 送信 = 4、受信 = 4、損失 = 0 (0% の損失)、
PS C:\Users\rinsaka\Documents>

目次に戻る