≡ Menu

ifconfig command

XEN Virtualization Set The MTU For xenbr0 Interface

I've already written about setting the MTU (Maximum Transmission Unit) under Linux including Jumbo frames (FreeBSD specific MTU information is here).

With this quick tip you can increase MTU size to get a better networking performance.
[click to continue…]

HowTo: Configure Linux Virtual Local Area Network (VLAN)

VLAN is an acronym for Virtual Local Area Network. Several VLANs can co-exist on a single physical switch, which are configured via Linux software and not through hardware interface (you still need to configure actual hardware switch too).
[click to continue…]

Read UNIX / Linux System IP Address In a Shell Script

Reading an IP address in shell script required many time. However, different Linux distribution stores IP address in different files. If you are looking to run script under different UNIX like OSes such as Solaris or FreeBSD then you need to use the ifconfig command. The ifconfig command is not just used to configure a network interface, but it can be use to obtained information such as network IP, netmask and much more.
[click to continue…]

FreeBSD IP Alias: Setup 2 or More IP address on One NIC

IP aliasing is the process of assigning more than one IP address to a network interface. This is useful for Apache web server virtual hosting or other network servers such as ftp server.

This tutorial explains how to assign one or more IP address to a single network interface under FreeBSD operating system.

It is possible to create network alias or assign 2 ip address to a single NIC under FreeBSD operating system.

Our Sample Setup

  • Interface name: lnc0 - IP :
  • Interface name: lnc0 alias - IP :

Netmask must be different otherwise you will get an error ifconfig: ioctl (SIOCAIFADDR): File exists.

Set ip alias using ifconfig command line utility

Login as the root user.

Now, use ifconfig command as follows to set alias:
# ifconfig lnc0 netmask alias

Persistent IP Alias Configuration

Edit file /etc/rc.conf to setup persistent ip aliasing option by appending following configuration, so that next time FreeBSD comes up (after restart/shutdown) it will create alias for you:
ifconfig_lnc0_alias0=" netmask"

Finally, Restart FreeBSD network service using network restart script:
# /etc/rc.d/netif restart && /etc/rc.d/routing restart
Display alias and real ip using ifconfig lnc0 command:
# ifconfig lnc0
Sample output:

inet6 fe80::20c:29ff:fe01:ddbd%lnc0 prefixlen 64 scopeid 0x1
inet netmask 0xffffff00 broadcast
inet netmask 0xffff

Sample /etc/rc.conf file with IP aliasing

Here is my /etc/rc.conf file with em0 and em1 interface with 5 aliases:

# default vsnl router interface
# Force 10Mbps for both public and private LAN interace
ifconfig_em0="inet netmask media 10baseT/UTP mediaopt full-duplex"
ifconfig_em1="inet netmask media 10baseT/UTP mediaopt full-duplex"
ifconfig_em0_alias0="inet netmask"
ifconfig_em0_alias1="inet netmask"
ifconfig_em0_alias2="inet netmask"
ifconfig_em0_alias3="inet netmask"
ifconfig_em0_alias4="inet netmask"
# static routing configuration

Further readings:

  • Read ifconfig man page.

FreeBSD: HowTo Change IP Address / Setup New IP Address For Existing Interface

In this quick post I will explain how to add and configuring a network card under FreeBSD operating system using command line options.
[click to continue…]