2018-11-15 15:00:14 +00:00
|
|
|
---
|
|
|
|
layout: page
|
|
|
|
category-page: intermediate
|
|
|
|
category-title: Intermediate commands
|
2018-11-15 20:09:21 +00:00
|
|
|
tags: command ifconfig
|
2018-11-15 15:00:14 +00:00
|
|
|
author: Matteo Omenetti
|
2018-11-15 20:09:21 +00:00
|
|
|
title: ifconfig
|
2018-11-18 20:38:56 +00:00
|
|
|
previous-page: pages/cmd/interm/git.html
|
|
|
|
next-page: pages/cmd/interm/install.html
|
2018-11-15 15:00:14 +00:00
|
|
|
---
|
2018-11-15 20:09:21 +00:00
|
|
|
|
|
|
|
The command <code>ifconfig</code> stands for <i>Interface CONFIGuration</i>. It is used
|
|
|
|
to configure, control, and query network interface parameters of your system.<br>
|
2018-11-15 15:00:14 +00:00
|
|
|
If you try running this command with no arguments, it will simply display information
|
2018-11-15 20:09:21 +00:00
|
|
|
about all network interfaces currently active.<br>
|
|
|
|
|
2018-11-15 15:00:14 +00:00
|
|
|
{% highlight bash %}
|
2018-11-15 20:09:21 +00:00
|
|
|
ifconfig
|
2018-11-15 15:00:14 +00:00
|
|
|
{% endhighlight %}
|
2018-11-15 20:09:21 +00:00
|
|
|
|
2018-11-15 15:00:14 +00:00
|
|
|
The output sill resembles something like this, of course it changes from machine
|
|
|
|
to machine:
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
en5: flags=8863 UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST mtu 1500
|
2018-11-15 20:09:21 +00:00
|
|
|
ether ac:de:48:00:11:22
|
|
|
|
inet6 fe80::aede:48ff:fe00:1122%en5 prefixlen 64 scopeid 0x8
|
|
|
|
nd6 options=201 PERFORMNUD,DAD
|
|
|
|
media: autoselect (100baseTX full-duplex)
|
|
|
|
status: active
|
2018-11-15 15:00:14 +00:00
|
|
|
|
|
|
|
ap1: flags=8802 BROADCAST,SIMPLEX,MULTICAST mtu 1500
|
2018-11-15 20:09:21 +00:00
|
|
|
ether f2:18:98:41:74:42
|
|
|
|
media: autoselect
|
|
|
|
status: inactive
|
|
|
|
...
|
2018-11-15 15:00:14 +00:00
|
|
|
</pre>
|
|
|
|
|
2018-11-15 20:09:21 +00:00
|
|
|
If you want to view the configuration of all network interfaces, not just the ones
|
|
|
|
currently active, you can use flag <code>a</code>.
|
|
|
|
|
2018-11-15 15:00:14 +00:00
|
|
|
{% highlight bash %}
|
2018-11-15 20:09:21 +00:00
|
|
|
ifconfig -a
|
2018-11-15 15:00:14 +00:00
|
|
|
{% endhighlight %}
|
|
|
|
|
2018-11-15 20:09:21 +00:00
|
|
|
If you want to view the configuration of a specific interface, you can specify
|
|
|
|
the name of the interface you want to view after the command <i>ifconfig</i>:
|
|
|
|
|
2018-11-15 15:00:14 +00:00
|
|
|
{% highlight bash %}
|
2018-11-15 20:09:21 +00:00
|
|
|
ifconfig ap1
|
2018-11-15 15:00:14 +00:00
|
|
|
{% endhighlight %}
|
|
|
|
|
2018-11-15 20:09:21 +00:00
|
|
|
This command will show only the configuration of ap1.<br>
|
|
|
|
|
|
|
|
To enable an interface, you can use the command ifconfig with the name of the interface
|
|
|
|
you want to enable, followed by the key word <code>up</code>.<br>
|
|
|
|
|
|
|
|
However, enabling or disabling a device, is a privilege reserved for the super user,
|
|
|
|
therefore you also have to use the command <code>sudo</code>.
|
|
|
|
|
2018-11-15 15:00:14 +00:00
|
|
|
{% highlight bash %}
|
2018-11-15 20:09:21 +00:00
|
|
|
sudo ifconfig ap1 up
|
2018-11-15 15:00:14 +00:00
|
|
|
{% endhighlight %}
|
|
|
|
|
2018-11-15 20:09:21 +00:00
|
|
|
To disable an interface, you can follow the same procedure, this time using
|
|
|
|
the key word <code>down</code>.
|
|
|
|
|
2018-11-15 15:00:14 +00:00
|
|
|
{% highlight bash %}
|
2018-11-15 20:09:21 +00:00
|
|
|
sudo ifconfig ap1 down
|
2018-11-15 15:00:14 +00:00
|
|
|
{% endhighlight %}
|