ifconfig
ネットワーク
書き方
ifconfig [-a] [<interface>]網の口を見て触る古い命令です。Linux では `ip addr` が代わりを務め、そもそも入っていないこともあり、ip で足した住所をすべて出せませんが、macOS では今もこれが本物の道具です。
よく使うオプション
| オプション | 意味 |
|---|---|
| -a | Include interfaces that are down; plain ifconfig may hide them on Linux. |
| <if> up / down | Bring one interface up or down. |
| <if> inet <ip> netmask <mask> | Set an address, until the next reboot. |
| en0 / eth0 | The usual names: en0 on macOS, eth0 or ens5 on Linux. |
例
ifconfig -aEvery interface, including the ones currently down.
ifconfig en0 | grep "inet "The local IPv4 address on macOS.
sudo ifconfig eth0 downTake an interface offline (Linux, if net-tools is installed).
つながらないとき、どこまで行けたのかを絞ります — 名前が引けないのか、経路がないのか、ポートが閉じているのか。
読み方
- 角括弧 [ ] は省いてよい部分です。
- 三点 … は複数並べられるという意味です。
- オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。
よくある質問
Q. ifconfig は何をしますか。
網の口を見て触る古い命令です。Linux では `ip addr` が代わりを務め、そもそも入っていないこともあり、ip で足した住所をすべて出せませんが、macOS では今もこれが本物の道具です。
Q. どう打ちますか。
ifconfig [-a] [<interface>] — 角括弧は省いてよい部分です。
Q. よく使うオプションはいくつですか。
ここにまとめたのは4個です。全部は man ifconfig にあります。このコマンドはネットワークの仲間です。
関連するコマンド
man ページ: man ifconfig