A look at this useful command for connecting your computer to a network
Size: 117.84 KB
Language: en
Added: Jan 23, 2010
Slides: 16 pages
Slide Content
ifconfig
Kevin O'Brien
Washtenaw Linux Users Group
http://www.lugwash.org
2
ifconfig
●... stands for interface configurator
●... is part of the original internet toolkit
http://www.faqs.org/docs/linux_network/x-
087-2-iface.interface.html
●... has versions available for Linux, BSD,
Solaris, and Mac OSX
3
man page
●Ifconfig is used to configure the kernel-resident
network interfaces. It is used at boot time to set
up interfaces as necessary. After that, it is
usually only needed when debugging or when
system tuning is needed.
4
man page 2
●If no arguments are given, ifconfig displays
the status of the currently active interfaces. If
a single interface argument is given, it
displays the status of the given interface
only; if a single -a argument is given, it
displays the status of all interfaces, even
those that are down. Otherwise, it configures
an interface.
6
What is it saying?
●eth0 is the interface it is reporting on. It is the
first of the ethernet interfaces on this
computer.
●The Hardware Address is 00:0F:20:CF:8B:42.
This is sometimes called the MAC address
(Media Access Control), and is a
hexadecimal number assigned to the
ethernet card at the factory.
●The internet address is 172.16.1.2. This is
the address assigned to this computer.
7
What is it saying? 2
●The Broadcast Address is 172.16.1.255. This
is an address that can be used to send
messages to every computer on the same
subnet as this computer.
●The Subnet Mask is 255.255.255.0. This can
be thought of as defining or identifying the
subnet this computer is part of.
●The rest of it tells about packets sent,
received, dropped, etc.
8
Use for information
●The first thing most beginners will want to do
is use this for information.
●If you find you are not connected to the
Internet, use this command to see if your
interface is configured and active.
●You can use this to check on your IP
address and subnet mask.
●There is an equivalent for wireless
interfaces, called iwconfig.
9
Parallels for newbies
●Windows 95 through ME had a command
called winipcfg
●Windows NT through Windows Vista have
ipconfig
●These are essentially similar to the Unix
command ifconfig
10
Syntax
●ifconfig interface [address [parameters]]
●interface is the interface name, such as eth0
(first ethernet device) or lo (local host)
●address is the IP address assigned to the
interface. This can be specified as a dotted
quad address, or as a name that can be
looked up in /etc/hosts.
11
Parameters
●up – Makes an interface accessible to the IP
layer.
●down – Makes an interface inaccessible to
the IP layer, i.e. stops all traffic through this
interface.
●netmask mask – Sets the subnet mask to be
used by the interface.
●broadcast address – Sets the broadcast
address.
12
Warning!
●If you are not a network administrator, be
very careful about setting addresses from the
command line. Even people with some
experience can get confused setting a
subnet mask. You don't want your interface
to stop working in some mysterious way.
●Using this command to get information is
completely safe.
13
Warning! 2
●If you do want to experiment (a very good
way to learn about these things), just make
sure you are not using a mission-critical
computer. Whatever you screw up you will
need to unscrew.☺
14
More on this command
●There are other parameters and options
available for this command, but they go
beyond the requirements for this
presentation. Consult Google or the man
page for more information.
●A good readable guide to the basics can be
found at http://tldp.org/LDP/nag2/x-087-2-
iface.ifconfig.html
15
Examples
●ifconfig eth0 – View the network settings on
the first Ethernet adapter installed in the
computer.
●ifconfig -a – Display information on all
network interfaces on the computer, active or
inactive.
●ifconfig eth0 down – Would take down the
interface, and no packets would be sent or
received.
●ifconfig eth0 up – Would bring the interface
back up so it could send and receive data.
16
Examples 2
●ifconfig eth0 192.168.1.102 netmask
255.255.255.0 broadcast 192.168.1.255 –
This would assign these values to the first
Ethernet device installed in the computer. Be
careful here!