ifconfig
Linux Commands - Network Commands

ifconfig

ifconfig is used to configure the network interfaces and parameters.

{mosimage}


Syntax

ifconfig interface parameters

Example:
ifconfig eth0 192.168.3.45 netmask 255.255.255.0

If parameters are not given the interface and the configuration for that interface are given. If the interface is not indicated then it will list all available information for active interfaces.

Output
With no options this is an example of the output listing the enabled interfaces and loopback, lo


eth0 Link encap:Ethernet HWaddr 00:03:0C:11:F6:A4
inet addr:192.168.3.18 Bcast:192.168.5.255 Mask:255.255.255.0
inet6 addr: fe80::203:dff:fe11:f6a9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:16535 errors:0 dropped:0 overruns:0 frame:0
TX packets:17674 errors:0 dropped:0 overruns:0 carrier:0
collisions:1782 txqueuelen:1000
RX bytes:14901259 (14.2 Mb) TX bytes:2966504 (2.8 Mb)
Interrupt:217 Base address:0xe800

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:199 errors:0 dropped:0 overruns:0 frame:0
TX packets:199 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:122418 (119.5 Kb) TX bytes:122418 (119.5 Kb)


Activating Interfaces

ifconfig eth0 up
This command will activate the eth0 interface.

ifconfig eth0 down
This will shut down the eth0 interface.

The interface needs to be chosen so that the correct interface is taken up or down.

{mosimage}

ifconfig ipaddress



The ipaddress can be set for a network card using this option. It is important to indicate the network interface that should have the ipaddress.


Example:

ifconfig eth0 192.168.3.45 netmask 255.255.255.0


The ipaddress 192.168.3.45 and the netmask of 255.255.255.0 are added to the eth0 interface.



ifconfig netmask



The network mask can be set for a network card using this option. It is important to indicate the network interface that should have the netmask.


Example:

ifconfig eth0 netmask 255.255.255.0


The netmask of 255.255.255.0 is added to the eth0 interface.