Exploring FreeBSD's IFCONFIG Features

Have you ever encountered various network devices on a computer. But have you ever wondered how to activate, deactivate or configure these network devices on a computer. We only need a few command lines typed in the command shell menu to activate, deactivate or configure the network interfaces.

On the FreeBSD operating system or other BSD UNIX-based operating systems such as Linux, DragonflyBSD, GhostBSD, OpenBSD and others, the command to configure or activate the network interface uses ifconfig.

The ifconfig (interface configuration) command is used to configure network interfaces or kernel-resident network interfaces. ifconfig is used at boot time to set the network interface as necessary. In addition, ifconfig is usually used when debugging or during system setup. Not only that, the ifconfig command is also used to assign an IP address and netmask to a network interface or to enable or disable a given network interface.

ifconfig is a utility that is very necessary for a network system administrator. With ifconfig, an administrator can prepare network interfaces to monitor and carry out system maintenance.


1. Key Features of ifconfig
  • Displays detailed information about the interface.
  • Set network (3 Layer OSI) and hardware (2 Layer OSI) addresses.
  • Sets the interface to random fetch mode (useful during debugging).
  • Binding to one interface from multiple network addresses.
Below is an example of using the ifconfig command to view the network interfaces on a computer system.

root@ns1:~ # ifconfig
nfe0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=82008<VLAN_MTU,WOL_MAGIC,LINKSTATE>
ether 00:24:21:88:69:24
inet 192.168.5.2 netmask 0xffffff00 broadcast 192.168.5.255
media: Ethernet autoselect (100baseTX <full-duplex>)
status: active
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
inet 127.0.0.1 netmask 0xff000000
groups: lo
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

The example "ifconfig" command above displays information such as the IP address, subnet mask, and default gateway for all network interfaces.

nfe0: Is the Landcard or network adapter card used. The Land Card has a MAC address of 00:24:21:88:69:24 and an IP address of 192.168.5.2 netmask 255.255.255.0 with broadcast 192.168.5.255.
lo0: Is a loopback network with IP address 127.0.0.1.


2. Example of Using ifconfig on FreeBSD

a. Displays all active and inactive interfaces

root@ns1:~ # ifconfig -a


b. Displays certain interfaces

root@ns1:~ # ifconfig nfe0
n
fe0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=82008<VLAN_MTU,WOL_MAGIC,LINKSTATE>
ether 00:24:21:88:69:24
inet 192.168.5.2 netmask 0xffffff00 broadcast 192.168.5.255
media: Ethernet autoselect (100baseTX <full-duplex>)
status: active
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>


c. Turning Off Certain Network Interfaces

root@ns1:~ # ifconfig nfe0 down

The script above will turn off the nfe0 interface.


d. Restarting the Network Interface

root@ns1:~ # ifconfig nfe0 up


e. Enter the Netmask and Broadcast Static IP Address

root@ns1:~ # ifconfig nfe0 192.168.5.2 netmask 255.255.255.0 broadcast 192.168.5.255


f. Change the Maximum transmission unit (MTU) value for nfe0 to 1500

root@ns1:~ # ifconfig nfe0 mtu 1500


g. Looking for Other Features on the nfe0 Interface

root@ns1:~ # ifconfig -m nfe0
nfe0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=82008<VLAN_MTU,WOL_MAGIC,LINKSTATE>
capabilities=82008<VLAN_MTU,WOL_MAGIC,LINKSTATE>
ether 00:24:21:88:69:24
inet 192.168.5.2 netmask 0xffffff00 broadcast 192.168.5.255
media: Ethernet autoselect (100baseTX <full-duplex>)
status: active
supported media:
media autoselect mediaopt flowcontrol
media autoselect
media 1000baseT mediaopt full-duplex,flowcontrol,master
media 1000baseT mediaopt full-duplex,flowcontrol
media 1000baseT mediaopt full-duplex,master
media 1000baseT mediaopt full-duplex
media 1000baseT mediaopt master
media 1000baseT
media 100baseTX mediaopt full-duplex,flowcontrol
media 100baseTX mediaopt full-duplex
media 100baseTX
media 10baseT/UTP mediaopt full-duplex,flowcontrol
media 10baseT/UTP mediaopt full-duplex
media 10baseT/UTP
media none
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>

Everything that has been exemplified above can only be used temporarily. If you want to set the network interface permanently, you can do this by typing the "ifconfig" command in the /etc/rc.conf file. Here's an example.

root@ns1:~ # ee /etc/rc.conf
ifconfig_nfe0="inet 192.168.5.2 netmask 255.255.255.0"
defaultrouter="192.168.5.1"

For more details, you can read the previous article.



To get more complete information about using the "ifconfig" command, you can use the "man utilityname" command. An example is the following "man ifconfig". Type this command in the FreeBSD command shell.
Iwan Setiawan

I Like Adventure: Mahameru Mount, Rinjani Mount I Like Writer FreeBSD

Post a Comment

Previous Post Next Post