ifconfig
—
configure network interface parameters
ifconfig |
[-L ] [-m ]
[-r ] [-f
type: format]
interface [create ]
[address_family] [address
[dest_address]]
[parameters] |
ifconfig |
interface destroy |
ifconfig |
-a [-L ]
[-d ] [-m ]
[-r ] [-u ]
[-v ] [-f
type: format]
[address_family] |
ifconfig |
-l [-d ]
[-u ] [address_family] |
ifconfig |
[-L ] [-d ]
[-m ] [-r ]
[-u ] [-v ]
[-C ] [-f
type: format] |
ifconfig |
interface vlan
vlan-tag vlandev
iface |
ifconfig |
interface -vlandev
iface |
ifconfig |
interface bonddev
iface |
ifconfig |
interface -bonddev
iface |
ifconfig |
interface bondmode
lacp | static |
ifconfig |
-X pattern
[parameters] |
The ifconfig
utility is used to assign an
address to a network interface and/or configure network interface
parameters.
The following options are available:
- address
- For the DARPA-Internet family, the address is either a host name present
in the host name data base, hosts(5),
or a DARPA Internet address expressed in the Internet standard “dot
notation”.
It is also possible to use the CIDR notation (also known as
the slash notation) to include the netmask. That is, one can specify an
address like 192.168.0.1/16
.
For the “inet6” family, it is also possible to
specify the prefix length using the slash notation, like
::1/128
. See the
prefixlen
parameter below for more
information.
The link-level (“link”) address is specified as
a series of colon-separated hex digits. This can be used to e.g. set a
new MAC address on an ethernet interface, though the mechanism used is
not ethernet-specific. If the interface is already up when this option
is used, it will be briefly brought down and then brought back up again
in order to ensure that the receive filter in the underlying ethernet
hardware is properly reprogrammed.
- address_family
- Specify the address family which affects interpretation of the remaining
parameters. Since an interface can receive transmissions in differing
protocols with different naming schemes, specifying the address family is
recommended. The address or protocol families currently supported are
“inet”, “inet6”, and “link”. The
default is “inet”. “ether” and
“lladdr” are synonyms for “link”.
- dest_address
- Specify the address of the correspondent on the other end of a point to
point link.
- interface
- This parameter is a string of the form “name unit”, for
example, “
en0
”.
The following parameters may be set with
ifconfig
:
add
- Another name for the
alias
parameter. Introduced
for compatibility with BSD/OS.
alias
- Establish an additional network address for this interface. This is
sometimes useful when changing network numbers, and one wishes to accept
packets addressed to the old interface. If the address is on the same
subnet as the first network address for this interface, a non-conflicting
netmask must be given. Usually
0xffffffff
is most
appropriate.
-alias
- Remove the network address specified. This would be used if you
incorrectly specified an alias, or it was no longer needed. If you have
incorrectly set an NS address having the side effect of specifying the
host portion, removing all NS addresses will allow you to respecify the
host portion.
anycast
- (Inet6 only.) Specify that the address configured is an anycast address.
Based on the current specification, only routers may configure anycast
addresses. Anycast address will not be used as source address of any of
outgoing IPv6 packets.
arp
- Enable the use of the Address Resolution Protocol
(arp(4)) in mapping between network
level addresses and link level addresses (default). This is currently
implemented for mapping between DARPA Internet addresses and IEEE 802
48-bit MAC addresses (Ethernet, FDDI, and Token Ring addresses).
-arp
- Disable the use of the Address Resolution Protocol
(arp(4)).
broadcast
- (Inet only.) Specify the address to use to represent broadcasts to the
network. The default broadcast address is the address with a host part of
all 1's.
debug
- Enable driver dependent debugging code; usually, this turns on extra
console error logging.
-debug
- Disable driver dependent debugging code.
delete
- Another name for the
-alias
parameter.
down
- Mark an interface “down”. When an interface is marked
“down”, the system will not attempt to transmit messages
through that interface. If possible, the interface will be reset to
disable reception as well.
ether
- Another name for the
lladdr
parameter.
lladdr
addr
- Set the link-level address on an interface. This can be used to e.g. set a
new MAC address on an ethernet interface, though the mechanism used is not
ethernet-specific. The address addr is specified as
a series of colon-separated hex digits. If the interface is already up
when this option is used, it will be briefly brought down and then brought
back up again in order to ensure that the receive filter in the underlying
ethernet hardware is properly reprogrammed.
media
type
- If the driver supports the media selection system, set the media type of
the interface to type. Some interfaces support the
mutually exclusive use of one of several different physical media
connectors. For example, a 10Mbit/s Ethernet interface might support the
use of either AUI or twisted pair connectors. Setting the media type to
10base5/AUI
would change the currently active
connector to the AUI port. Setting it to
10baseT/UTP
would activate twisted pair. Refer to
the interfaces' driver specific documentation or man page for a complete
list of the available types.
mediaopt
opts
- If the driver supports the media selection system, set the specified media
options on the interface. The opts argument is a
comma delimited list of options to apply to the interface. Refer to the
interfaces' driver specific man page for a complete list of available
options.
-mediaopt
opts
- If the driver supports the media selection system, disable the specified
media options on the interface.
rxcsum
,
txcsum
- If the driver supports user-configurable checksum offloading, enable
receive (or transmit) checksum offloading on the interface. Some drivers
may not be able to enable these flags independently of each other, so
setting one may also set the other. The driver will offload as much
checksum work as it can reliably support, the exact level of offloading
varies between drivers.
-rxcsum
,
-txcsum
- If the driver supports user-configurable checksum offloading, disable
receive (or transmit) checksum offloading on the interface. These settings
may not always be independent of each other.
tso
- If the driver supports tcp(4)
segmentation offloading, enable TSO on the interface. Some drivers may not
be able to support TSO for ip(4) and
ip6(4) packets, so they may enable only
one of them.
-tso
- If the driver supports tcp(4)
segmentation offloading, disable TSO on the interface. It will always
disable TSO for ip(4) and
ip6(4).
lro
- If the driver supports tcp(4) large
receive offloading, enable LRO on the interface.
-lro
- If the driver supports tcp(4) large
receive offloading, disable LRO on the interface.
av
- If supported by the driver, enable 802.1 AVB on the interface.
-av
- If supported by the driver, disable 802.1 AVB on the interface.
vlanmtu
,
vlanhwtag
- If the driver offers user-configurable VLAN support, enable reception of
extended frames or tag processing in hardware, respectively. Note that
this must be issued on a physical interface associated with
vlan(4), not on a
vlan(4) interface itself.
-vlanmtu
,
-vlanhwtag
- If the driver offers user-configurable VLAN support, disable reception of
extended frames or tag processing in hardware, respectively.
create
- Create the specified network pseudo-device. If the interface is given
without a unit number, try to create a new device with an arbitrary unit
number. If creation of an arbitrary device is successful, the new device
name is printed to standard output unless the interface is renamed or
destroyed in the same
ifconfig
invocation.
destroy
- Destroy the specified network pseudo-device.
plumb
- Another name for the
create
parameter. Included
for Solaris compatibility.
unplumb
- Another name for the
destroy
parameter. Included
for Solaris compatibility.
metric
n
- Set the routing metric of the interface to n,
default 0. The routing metric is used by the routing protocol
(routed(8)). Higher metrics have the
effect of making a route less favorable; metrics are counted as additional
hops to the destination network or host.
mtu
n
- Set the maximum transmission unit of the interface to
n, default is interface specific. The MTU is used to
limit the size of packets that are transmitted on an interface. Not all
interfaces support setting the MTU, and some interfaces have range
restrictions.
netmask
mask
- (Inet only.) Specify how much of the address to reserve for subdividing
networks into sub-networks. The mask includes the network part of the
local address and the subnet part, which is taken from the host field of
the address. The mask can be specified as a single hexadecimal number with
a leading ‘
0x
’, with a dot-notation
Internet address, or with a pseudo-network name listed in the network
table networks(5). The mask
contains 1's for the bit positions in the 32-bit address which are to be
used for the network and subnet parts, and 0's for the host part. The mask
should contain at least the standard network portion, and the subnet field
should be contiguous with the network portion.
The netmask can also be specified in CIDR notation after the
address. See the address option above for more
information.
prefixlen
len
- (Inet6 only.) Specify that len bits are reserved for
subdividing networks into sub-networks. The len must
be integer, and for syntactical reason it must be between 0 to 128. It is
almost always 64 under the current IPv6 assignment rule. If the parameter
is omitted, 64 is used.
The prefix can also be specified using the slash notation
after the address. See the address option above
for more information.
remove
- Another name for the
-alias
parameter. Introduced
for compatibility with BSD/OS.
link
[0
-2
]
- Enable special processing of the link level of the interface. These three
options are interface specific in actual effect, however, they are in
general used to select special modes of operation. An example of this is
to enable SLIP compression, or to select the connector type for some
Ethernet cards. Refer to the man page for the specific driver for more
information.
-link
[0
-2
]
- Disable special processing at the link level with the specified
interface.
up
- Mark an interface “up”. This may be used to enable an
interface after an “
ifconfig
down
”. It happens automatically when
setting the first address on an interface. If the interface was reset when
previously marked down, the hardware will be re-initialized.
The following parameters are for ICMPv6 Neighbor Discovery
Protocol. Note that the address family keyword
“inet6
” is needed for them:
nud
- Perform network unreachability detection (NUD).
-nud
- Do not perform network unreachability detection (NUD).
ifdisabled
- Disable all IPv6 communication on the interface.
-ifdisabled
- Do not disable all IPv6 communication on the interface.
insecure
- Disable the processing of Secure Neighbor Discovery (SEND).
-insecure
- Do not disabled the processing of Secure Neighbor Discovery (SEND).
dad
- Perform duplicate address detection (DAD).
-dad
- Do not perform duplicate address detection (DAD).
replicated
- Modify duplicate address detection (DAD) protocol to expect that interface
configuration is replicated at a network sleep proxy. Ignores certain NA
messages and disables optimistic DAD.
-replicated
- Do not use modified duplicated address detection (DAD) protocol.
The following parameters are specific to link aggregate
interfaces:
bonddev
iface
- If the interface is a bond pseudo device, associate physical interface
iface with it. By default, the bond pseudo device is
in LACP (Link Aggregation Control Protocol) mode (see bondmode
below). In this mode, the device conforms to the IEEE 802.3ad Link
Aggregation specification.
If this is the first physical interface to be associated with
the bond interface, the bond interface inherits the ethernet address
from the physical interface. Physical interfaces that are added to the
bond have their ethernet address re-programmed so that all members of
the bond have the same ethernet address. If the physical interface is
subsequently removed from the bond using
-bonddev
, a new ethernet address is chosen from
the remaining interfaces, and all interfaces are re-programmed again
with the new ethernet address. If no remaining interfaces exist, the
bond interface's ethernet address is cleared.
If the specified physical interface
iface is not capable of having its ethernet
address re-programmed, the bonddev
command will
fail.
Once the physical interface iface is
successfully associated with the bond interface, all received packets
are diverted to the bond interface. The physical interface is no longer
useable on its own, and remains that way until it is removed from the
bond using -bonddev
.
It is possible that the specified interface
iface is not capable of aggregating, and may
remain unused until the operating conditions change.
The link status of the bond interface depends on the state of
link aggregation. If no active partner is detected, the link status will
remain inactive.
To monitor the 802.3ad Link Aggregation state, use the
-b
option.
A physical interface that is associated with a vlan pseudo
device cannot at the same time be associated with a bond pseudo device.
A physical interface cannot be associated with more than one bond pseudo
device at the same time.
It is not possible to associate a bond with pseudo interfaces
such as vlan. Only physical ethernet interfaces may be associated with a
bond.
-bonddev
iface
- If the interface is a bond pseudo device, disassociate the physical
interface iface from it. Before the interface is
removed from the bond, the bond device announces to the link partner that
the interface is now individual and no longer aggregatable. If the
physical iface is the last interface in the bond,
the bond interface clears its link address.
bondmode
lacp | static
- If the interface is a bond pseudo device, this option will set the
mode on the bond interface. The two currently supported modes are
lacp and static. The default
mode is lacp.
To enable static mode (and turn off LACP), specify
static. In static mode, a member interface is made
an active part of the link aggregate as long as the link status is
active.
To re-enable LACP mode, specify
lacp.
The following parameters are specific to IP tunnel interfaces,
gif(4):
tunnel
src_addr dest_addr
- Configure the physical source and destination address for IP tunnel
interfaces. The arguments src_addr and
dest_addr are interpreted as the outer
source/destination for the encapsulating IPv4/IPv6 header.
-tunnel
- Unconfigure the physical source and destination address for IP tunnel
interfaces previously configured with
tunnel
.
deletetunnel
- Another name for the
-tunnel
parameter.
The following parameters are specific to bridge interfaces:
addm
interface
- Add the interface named by interface as a member of
the bridge. The interface is put into promiscuous mode so that it can
receive every packet sent on the network.
deletem
interface
- Remove the interface named by interface from the
bridge. Promiscuous mode is disabled on the interface when it is removed
from the bridge.
maxaddr
size
- Set the size of the bridge address cache to size.
The default is 100 entries.
timeout
seconds
- Set the timeout of address cache entries to seconds
seconds. If seconds is zero, then address cache
entries will not be expired. The default is 240 seconds.
addr
- Display the addresses that have been learned by the bridge.
static
interface-name address
- Add a static entry into the address cache pointing to
interface-name. Static entries are never aged out of
the cache or re-placed, even if the address is seen on a different
interface.
deladdr
address
- Delete address from the address cache.
flush
- Delete all dynamically-learned addresses from the address cache.
flushall
- Delete all addresses, including static addresses, from the address
cache.
discover
interface
- Mark an interface as a “discovering” interface. When the
bridge has no address cache entry (either dynamic or static) for the
destination address of a packet, the bridge will forward the packet to all
member interfaces marked as “discovering”. This is the
default for all interfaces added to a bridge.
-discover
interface
- Clear the “discovering” attribute on a member interface. For
packets without the “discovering” attribute, the only
packets forwarded on the interface are broadcast or multicast packets and
packets for which the destination address is known to be on the
interface's segment.
learn
interface
- Mark an interface as a “learning” interface. When a packet
arrives on such an interface, the source address of the packet is entered
into the address cache as being a destination address on the interface's
segment. This is the default for all interfaces added to a bridge.
-learn
interface
- Clear the “learning” attribute on a member interface.
stp
interface
- Enable Spanning Tree protocol on interface. The
if_bridge(4) driver has support
for the IEEE 802.1D Spanning Tree protocol (STP). Spanning Tree is used to
detect and remove loops in a network topology.
-stp
interface
- Disable Spanning Tree protocol on interface. This is
the default for all interfaces added to a bridge.
maxage
seconds
- Set the time that a Spanning Tree protocol configuration is valid. The
default is 20 seconds. The minimum is 6 seconds and the maximum is 40
seconds.
fwddelay
seconds
- Set the time that must pass before an interface begins forwarding packets
when Spanning Tree is enabled. The default is 15 seconds. The minimum is 4
seconds and the maximum is 30 seconds.
hellotime
seconds
- Set the time between broadcasting of Spanning Tree protocol configuration
messages. The hello time may only be changed when operating in legacy stp
mode. The default is 2 seconds. The minimum is 1 second and the maximum is
2 seconds.
priority
value
- Set the bridge priority for Spanning Tree. The default is 32768. The
minimum is 0 and the maximum is 61440.
ifpriority
interface value
- Set the Spanning Tree priority of interface to
value. The default is 128. The minimum is 0 and the
maximum is 240.
ifpathcost
interface value
- Set the Spanning Tree path cost of interface to
value. The default is calculated from the link
speed. To change a previously selected path cost back to automatic, set
the cost to 0. The minimum is 1 and the maximum is 200000000.
ifmaxaddr
interface size
- Set the maximum number of hosts allowed from an interface, packets with
unknown source addresses are dropped until an existing host cache entry
expires or is removed. Set to 0 to disable.
hostfilter
interface address
- Configure the bridge to accept incoming packet on the interface only if
they match the given MAC address and IP address -- use the command twice
to set both type of addresses. Other filtering restrictions apply.
-hostfilter
interface
- Allow traffic from any host on that interface.
The following parameters are specific to vlan interfaces:
vlan
vlan_tag
- Set the VLAN tag value to vlan_tag. This value is a
16-bit number which is used to create an 802.1Q VLAN header for packets
sent from the vlan(4) interface. Note
that
vlan
and vlandev
must
both be set at the same time.
vlandev
iface
- Associate the physical interface iface with a
vlan(4) interface. Packets transmitted
through the vlan(4) interface will be
diverted to the specified physical interface iface
with 802.1Q VLAN encapsulation. Packets with 802.1Q encapsulation received
by the parent interface with the correct VLAN tag will be diverted to the
associated vlan(4) pseudo-interface.
The vlan(4) interface is assigned a
copy of the parent interface's flags and the parent's ethernet address.
The
vlandev
and vlan
must
both be set at the same time. If the
vlan(4) interface already has a
physical interface associated with it, this command will fail. To change
the association to another physical interface, the existing association
must be cleared first.
Note: if the hardware tagging capability is set on the parent
interface, the vlan(4) pseudo
interface's behavior changes: the
vlan(4) interface recognizes that the
parent interface supports insertion and extraction of VLAN tags on its
own (usually in firmware) and that it should pass packets to and from
the parent unaltered.
-vlandev
[iface]
- If the driver is a vlan(4) pseudo
device, disassociate the parent interface from it. This breaks the link
between the vlan(4) interface and its
parent, clears its VLAN tag, flags and its link address and shuts the
interface down. The iface argument is useless and
hence deprecated.
tbr
rate
- Set a token bucket regulator that limits the egress bandwidth to
rate, measured in bps, Kbps, Mbps or Gbps. If the
specified rate is zero, the token bucket regulator is disabled.
The ifconfig
utility displays the current
configuration for a network interface when no optional parameters are
supplied. If a protocol family is specified,
ifconfig
will report only the details specific to
that protocol family.
If the -m
flag is passed before an
interface name, ifconfig
will display the capability
list and all of the supported media for the specified interface.
If -L
flag is supplied, address lifetime
is displayed for IPv6 addresses, as time offset string.
Optionally, the -a
flag may be used
instead of an interface name. This flag instructs
ifconfig
to display information about all interfaces
in the system. The -d
flag limits this to interfaces
that are down, and -u
limits this to interfaces that
are up. When no arguments are given, -a
is
implied.
The -l
flag may be used to list all
available interfaces on the system, with no other additional information.
Use of this flag is mutually exclusive with all other flags and commands,
except for -d
(only list interfaces that are down)
and -u
(only list interfaces that are up).
The -v
flag may be used to get more
verbose status for an interface.
The -C
flag may be used to list all of the
interface cloners available on the system, with no additional information.
Use of this flag is mutually exclusive with all other flags and
commands.
The -r
flag may be used to show additional
information related to the count of route references on the network
interface.
For bridge interfaces, the list of addresses learned by the bridge
is not shown when displaying information about all interfaces except when
the -v
flag is used.
The -X
flag may be used to list interfaces
whose names match the regular expression in the pattern. See re_format(7)
for more information on regular expressions. This flag may be used with the
-a
flag and the -l
flag to
further restrict the set of interfaces to be listed.
The -f
flag may be used to control the
output format of ifconfig
. The format is specified
as a comma-separated list of
type:
format
pairs (see the EXAMPLES section for more
information). The -f
flag can be supplied multiple
times.
The types and their associated
format strings are:
addr
- Adjust the display of inet and inet6 addresses:
default
- Default format,
numeric
fqdn
- Fully qualified domain names (FQDN)
host
- Unqualified hostnames
numeric
- Numeric format
ether
- Adjust the display of link-level ethernet (MAC) addresses:
colon
- Separate address segments with a colon
dash
- Separate address segments with a dash
default
- Default format,
colon
inet
- Adjust the display of inet address subnet masks:
cidr
- CIDR notation, for example:
‘
203.0.113.224/26
’
default
- Default format,
hex
dotted
- Dotted quad notation, for example:
‘
255.255.255.192
’
hex
- Hexadecimal format, for example:
‘
0xffffffc0
’
inet6
- Adjust the display of inet6 address prefixes (subnet masks):
cidr
- CIDR notation, for example:
‘
::1/128
’ or
‘fe80::1%lo0/64
’
default
- Default format,
numeric
numeric
- Integer format, for example: ‘
prefixlen
64
’
Only the super-user may modify the configuration of a network
interface.
The media selection system is relatively new and only some drivers
support it (or have need for it).
Assign the IPv4 address 192.0.2.10
, with a
network mask of 255.255.255.0
, to the interface
en0
:
# ifconfig en0 inet 192.0.2.10
netmask 255.255.255.0
Add the IPv4 address 192.0.2.45
, with the
CIDR network prefix /28
, to the interface
en0
, using add
as a synonym
for the canonical form of the option alias
:
# ifconfig en0 inet 192.0.2.45/28
add
Remove the IPv4 address 192.0.2.45
from
the interface en0
:
# ifconfig en0 inet 192.0.2.45
-alias
Add the IPv6 address 2001:DB8:DBDB::123/48
to the interface en0
:
# ifconfig en0 inet6
2001:db8:bdbd::123 prefixlen 48 alias
Note that lower case hexadecimal IPv6 addresses are acceptable.
Remove the IPv6 address added in the above example, using the
/
character as shorthand for the network prefix, and
using delete
as a synonym for the canonical form of
the option -alias
:
# ifconfig en0 inet6
2001:db8:bdbd::123/48 delete
Configure the interface en1
, to use
100baseTX, full duplex Ethernet media options:
# ifconfig en1 media 100baseTX
mediaopt full-duplex
Create the software network interface
gif1
:
# ifconfig gif1 create
Destroy the software network interface
gif1
:
# ifconfig gif1 destroy
Display inet and inet6 address subnet masks in CIDR notation
# ifconfig -f
inet:cidr,inet6:cidr
Messages indicating the specified interface does not exist, the
requested address is unknown, or the user is not privileged and tried to
alter an interface's configuration.
The ifconfig
utility appeared in
4.2BSD.
Basic IPv6 node operation requires a link-local address on each
interface configured for IPv6. Normally, such an address is automatically
configured by the kernel on each interface added to the system; this
behaviour may be disabled by setting the sysctl MIB variable
net.inet6.ip6.auto_linklocal to 0.
If you delete such an address using
ifconfig
, the kernel may act very odd. Do this at
your own risk.