ifconfig utility in linux

Upload: minnalraj

Post on 09-Apr-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/8/2019 Ifconfig Utility in Linux

    1/5

    Page 1

    Copyright 2006 CNET Networks, Inc. All rights reserved.

    For more downloads and a free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html

    Version 1.0February 17, 2006

    Linux 101: Use the ifconfig utility in Linuxto configure your network

    By Chad Perrin

    TakeawayThe ifconfigcommand line utility is used to get information about a Linux network interface configuration and tomake changes to it.

    ifconfigMany Windows administrators are familiar with the ipconfigcommand line utility, which is used to get informationabout network interface configuration and make changes to it. Linux systems have a similar utility, ifconfig, which isa common part of the day-to-day tool belt of most Linux sysadmins. There are some distinct differences betweenipconfigand ifconfig, however, such as the fact that the DOS/Windows ipconfig does not allow you to makechanges to network configuration.

    In general, you must be logged in as root or use sudoto make use of the ifconfig utility on a Linux machine. Theifconfigutility can be used either to simply get information about network interface configuration or to changeconfiguration, depending on what options are used with the ifconfigcommand.

    http://techrepublic.com.com/5264-1-0.html?query=linux%20101http://techrepublic.com.com/5264-1-0.html?query=linux%20101
  • 8/8/2019 Ifconfig Utility in Linux

    2/5

    Linux 101: Use the ifconfig utility in Linux to configure your network

    Basic functionalityEntering ifconfigat the command line interface without specifying any options will provide a fairly completedescription of the current state of all active network interfaces. For instance, on a machine with hostname erebus,entering ifconfigat the command line might return the following output:

    eth0 Link encap:Ethernet HWaddr 00:C0:F0:77:FD:AD

    inet addr:192.168.2.103 Bcast:192.168.2.255 Mask:255.255.255.0inet6 addr: fe80::2c0:f0ff:fe77:fdad/64 Scope:Link

    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

    RX packets:913240 errors:230 dropped:0 overruns:0 frame:230

    TX packets:663990 errors:7 dropped:0 overruns:0 carrier:12

    collisions:0 txqueuelen:1000

    RX bytes:179148797 (170.8 MiB) TX bytes:53220450 (50.7 MiB)

    Interrupt:9 Base address:0xb000

    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:9814 errors:0 dropped:0 overruns:0 frame:0TX packets:9814 errors:0 dropped:0 overruns:0 carrier:0

    collisions:0 txqueuelen:0

    RX bytes:3655065 (3.4 MiB) TX bytes:3655065 (3.4 MiB)

    Some important information provided by the ifconfig command includes:

    Each active interface is identified by its name. For instance, on erebus, eth0 (the first Ethernet adapter)and lo (the loopback adapter) are both active.

    In the case of a physical network adapter, you'll get the MAC address, preceded by the term HWaddr.

    The IP address of the interface is preceded by the term inet addr, the broadcast address by Bcast, andthe subnet mask by Mask.

    The IPv6 address of each interface is preceded by the term inet6 addrand its scope, predictably, by theword Scope.

    The types of activity of each interface are listed togetherin the case of eth0 above, it lists UPBROADCAST RUNNING MULTICAST.

    Statistics for received and transmitted packets are listed on lines beginning with RXor TX, respectively.On another line, summary information about the amount of received and transmitted data is listed,including the total number of bytes transmitted and received on that device so far.

    Page 2Copyright 2006 CNET Networks, Inc. All rights reserved.

    For more downloads and a free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html

  • 8/8/2019 Ifconfig Utility in Linux

    3/5

    Linux 101: Use the ifconfig utility in Linux to configure your network

    OptionsA number of options can be specified with the ifconfigcommand to change its behavior:

    -aThis option tells ifconfigto show information about all interfaces, both active and inactive. On erebus,ifconfig -a returns results for eth0, lo, and sit0.

    -sThis is the "short listing" option, which shows a one-line summarized listing of data about each interface.The information returned is about interface activity, and not configuration. The output will be identical towhat is returned by the netstat -i command.

    -vThis "verbose" option returns extra information when there are certain types of error conditions to helpwith troubleshooting.

    [int]Simply follow up your ifconfigcommand with the name of an interface to get only information about thatinterface. For instance, you could issue the command ifconfig eth0 if you only wanted information

    about the eth0 interface, and not the loopback interface. Additionally, there are several options that

    require specifying the interface you wish to configure or get information about. up

    This activates an interface if it is not already active. For instance, ifconfig eth0 up causes eth0 to beactivated.

    down

    The counterpart to up, this deactivates the specified interface. Thus, ifconfig eth0 down causeseth0 to be deactivated if it is currently active.

    netmask [addr]Using the "netmask" option allows you to set the network mask for a given interface. For instance, settingthe network mask for eth0 could be done by entering ifconfig eth0 netmask 255.255.255.0.

    broadcast [addr]

    When the "broadcast" option is accompanied by an address argument, as inifconfig eth0

    broadcast 192.168.2.255, then the broadcast address for the specified interface will be set.

    [addr]

    Simply specifying an address with an interface name, as in ifconfig eth0 192.168.2.103, will setthat interface's IP address.

    ShortcutsThe ifconfig eth0 up command on most Linux systems can be abbreviated to ifup eth0. The same holds

    true for deactivating an interface, so that ifconfig eth0 down can be abbreviated as ifdown eth0. Some

    Linux systems will even have a further abbreviated command for cycling an interface's status called ifupdown,

    which quickly deactivates then reactivates an interface, though this is less common than the individual ifup and

    ifdown abbreviated commands.

    Page 3Copyright 2006 CNET Networks, Inc. All rights reserved.

    For more downloads and a free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html

  • 8/8/2019 Ifconfig Utility in Linux

    4/5

    Linux 101: Use the ifconfig utility in Linux to configure your network

    More informationThe "if" in ifconfig, and also in ifup, ifdown, and ifstatus, is an abbreviation of "interface". It is not related to theprogramming conditional "if". You can get more information about this utility by accessing its manpage, byentering man ifconfigat the command line.

    Other networking utilities of note include:

    arp This gives information about the address mapping cache, and allows you to manipulate itin various ways, such as clearing entries and adding them.

    iptables The iptables utility is actually a firewall configuration interface for the kernel's packetfiltering capabilities.

    Netstat This utility returns information about network connections, routing tables, interfacestatistics, and more.

    Route The route utility can be used to get information from the IP routing table on your machine,or to make changes to the routing table.

    See the manpages for any of these utilities to get more information by entering "man utilityname" at the commandline. For instance, the manpage for the arputility is accessed by entering man arp. You can get more information

    about the manutility by entering man man.

    Page 4Copyright 2006 CNET Networks, Inc. All rights reserved.

    For more downloads and a free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html

    http://techrepublic.com.com/5100-10877_11-5997057.htmlhttp://techrepublic.com.com/5100-10877_11-5997057.html
  • 8/8/2019 Ifconfig Utility in Linux

    5/5

    Linux 101: Use the ifconfig utility in Linux to configure your network

    Additional resources TechRepublic'sDownloads RSS Feed

    Sign up for TechRepublic's Downloads Weekly Update newsletter Sign up for TechRepublic's Linux NetNote newsletter

    Check out all of TechRepublic's free newsletters

    Linux 101: A comprehensive list of Linux services available for all distributions

    Linux 101: Configuring and managing iptables for better network security

    Version historyVersion: 1.0

    Published: February 17, 2006

    Tell us what you think

    TechRepublic downloads are designed to help you get your job done as painlessly and effectively as possible.Because we're continually looking for ways to improve the usefulness of these tools, we need your feedback.Please take a minute to drop us a line and tell us how well this download worked for you and offer yoursuggestions for improvement.

    Thanks!

    The TechRepublic Downloads Team

    Page 5Copyright 2006 CNET Networks, Inc. All rights reserved.

    For more downloads and a free TechRepublic membership, please visit http://techrepublic.com.com/2001-6240-0.html

    http://techrepublic.com.com/5155-22-0.xmlhttp://techrepublic.com.com/5155-22-0.xmlhttp://nl.com.com/MiniFormHandler?brand=techrepublic&list_id=e072http://nl.com.com/MiniFormHandler?brand=techrepublic&list_id=e011http://nl.com.com/acct_mgmt.jsp?brand=techrepublic&return_to=http://techrepublic.com.com/http://techrepublic.com.com/5138-3513-6018189.htmlhttp://techrepublic.com.com/5138-10877-5997053.htmlmailto:[email protected]?subject=Download_Feedback-Linux_101:_Use_the_ifconfig_utility_in_Linux_to_configure_your_network&body=Linux_101:_Use_the_ifconfig_utility_in_Linux_to_configure_your_networkmailto:[email protected]?subject=Download_Feedback-Linux_101:_Use_the_ifconfig_utility_in_Linux_to_configure_your_network&body=Linux_101:_Use_the_ifconfig_utility_in_Linux_to_configure_your_networkhttp://techrepublic.com.com/5138-10877-5997053.htmlhttp://techrepublic.com.com/5138-3513-6018189.htmlhttp://nl.com.com/acct_mgmt.jsp?brand=techrepublic&return_to=http://techrepublic.com.com/http://nl.com.com/MiniFormHandler?brand=techrepublic&list_id=e011http://nl.com.com/MiniFormHandler?brand=techrepublic&list_id=e072http://techrepublic.com.com/5155-22-0.xmlhttp://techrepublic.com.com/5155-22-0.xml