ifconfig8
Configure network interface parameters
Usage
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]
Overview
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
prefixlenparameter 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”. .El
The following parameters may be set with
ifconfig:add-
Another name for the
aliasparameter. 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
-aliasparameter. 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
lladdrparameter. lladdraddr-
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.
mediatype-
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/AUIwould change the currently active connector to the AUI port. Setting it to10baseT/UTPwould activate twisted pair. Refer to the interfaces' driver specific documentation or man page for a complete list of the available types. mediaoptopts-
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
ifconfiginvocation. destroy-
Destroy the specified network pseudo-device.
plumb-
Another name for the
createparameter. Included for Solaris compatibility. unplumb-
Another name for the
destroyparameter. Included for Solaris compatibility. metricn-
Set the routing metric of the interface to n, default 0. The routing metric may be used by routing protocols. Higher metrics have the effect of making a route less favorable; metrics are counted as additional hops to the destination network or host.
mtun-
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.
netmaskmask-
(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.
prefixlenlen-
(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
-aliasparameter. 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 “
ifconfigdown”. 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:
bonddeviface-
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
bondmodebelow). 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
bonddevcommand 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
-boption.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.
bondmodelacp | 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):
tunnelsrc_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
-tunnelparameter.The following parameters are specific to bridge interfaces:
addminterface-
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.
deleteminterface-
Remove the interface named by interface from the bridge. Promiscuous mode is disabled on the interface when it is removed from the bridge.
maxaddrsize-
Set the size of the bridge address cache to size. The default is 100 entries.
timeoutseconds-
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.
staticinterface-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.
deladdraddress-
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.
discoverinterface-
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.
learninterface-
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.
stpinterface-
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.
maxageseconds-
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.
fwddelayseconds-
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.
hellotimeseconds-
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.
priorityvalue-
Set the bridge priority for Spanning Tree. The default is 32768. The minimum is 0 and the maximum is 61440.
ifpriorityinterface value-
Set the Spanning Tree priority of interface to value. The default is 128. The minimum is 0 and the maximum is 240.
ifpathcostinterface 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.
ifmaxaddrinterface 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.
hostfilterinterface 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:
vlanvlan_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
vlanandvlandevmust both be set at the same time. vlandeviface-
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
vlandevandvlanmust 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.
tbrrate-
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 following commands may be used for testing various features of the networking stack:
linkcongested[0-1]-
Indicates the link is congested.
lowpowerwake[0-1]-
Indicates the network interface support low power wake mode.
inbandwakepacket[0-1]-
Indicates the network interface support inband wake packet tagging.
disableinput-
Disable input.
-
-disableinput -
Enable input.
disable_outputvalue-
Disable output when the value is not 0.
The
ifconfigutility displays the current configuration for a network interface when no optional parameters are supplied. If a protocol family is specified,ifconfigwill report only the details specific to that protocol family.If the
-mflag is passed before an interface name,ifconfigwill display the capability list and all of the supported media for the specified interface.If
-Lflag is supplied, address lifetime is displayed for IPv6 addresses, as time offset string.Optionally, the
-aflag may be used instead of an interface name. This flag instructsifconfigto display information about all interfaces in the system. The-dflag limits this to interfaces that are down, and-ulimits this to interfaces that are up. When no arguments are given,-ais implied.The
-lflag 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
-vflag may be used to get more verbose status for an interface.The
-Cflag 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
-rflag 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
-vflag is used.The
-Xflag 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-aflag and the-lflag to further restrict the set of interfaces to be listed.The
-fflag may be used to control the output format ofifconfig. The format is specified as a comma-separated list of type:format pairs (see the EXAMPLES section for more information). The-fflag 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.
Notes
The media selection system is relatively new and only some drivers support it (or have need for it).
Examples
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
Diagnostics
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.
Releases
165 releases since Mac OS X 10.0; the text changed 15 times.
- 10.0–10.1.5
- 10.2–10.2.8
- 10.3–10.3.3
- 10.3.4–10.3.9
- 10.4–10.4.11
- 10.5–10.6.2
- 10.6.3
- 10.6.4–10.6.8
- 10.7–10.8.5
- 10.9–10.9.5
- 10.10–10.11.6
- 10.12–11.5
- 12.0.1–13.5
- 14.0–15.1
- 15.2–15.6
- 26.0–26.5
-alias since Mac OS X 10.2;
-av since Mac OS X 10.7;
-bonddev since Mac OS X 10.4;
-dad since macOS 10.12;
-disableinput since macOS 26.0;
-discover since Mac OS X 10.6.3;
-hostfilter since OS X 10.10;
-ifdisabled since OS X 10.9;
-insecure since OS X 10.9;
-learn since Mac OS X 10.6.3;
-lro since Mac OS X 10.7;
-mediaopt since Mac OS X 10.2;
-nud since OS X 10.9;
-replicated since macOS 10.12;
-rxcsum since Mac OS X 10.7;
-stp since Mac OS X 10.6.3;
-tso since Mac OS X 10.7;
-tunnel since Mac OS X 10.6.3;
-txcsum since Mac OS X 10.7;
-vlandev since Mac OS X 10.3.4;
-vlanhwtag since Mac OS X 10.7;
-vlanmtu since Mac OS X 10.7.
-a until Mac OS X 10.1.5;
-autoedge until Mac OS X 10.8.5;
-autoptp until Mac OS X 10.8.5;
-d until Mac OS X 10.1.5;
-edge until Mac OS X 10.8.5;
-l until Mac OS X 10.1.5;
-private until Mac OS X 10.8.5;
-ptp until Mac OS X 10.8.5;
-span until Mac OS X 10.8.5;
-sticky until Mac OS X 10.8.5;
-trailers until Mac OS X 10.1.5;
-u until Mac OS X 10.1.5.