the ifconfig command
DESCRIPTION
A look at this useful command for connecting your computer to a networkTRANSCRIPT
![Page 1: The ifconfig Command](https://reader038.vdocument.in/reader038/viewer/2022100602/55895609d8b42a7d3e8b465b/html5/thumbnails/1.jpg)
ifconfig
Kevin O'BrienWashtenaw Linux Users Group
http://www.lugwash.org
![Page 2: The ifconfig Command](https://reader038.vdocument.in/reader038/viewer/2022100602/55895609d8b42a7d3e8b465b/html5/thumbnails/2.jpg)
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
![Page 3: The ifconfig Command](https://reader038.vdocument.in/reader038/viewer/2022100602/55895609d8b42a7d3e8b465b/html5/thumbnails/3.jpg)
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.
![Page 4: The ifconfig Command](https://reader038.vdocument.in/reader038/viewer/2022100602/55895609d8b42a7d3e8b465b/html5/thumbnails/4.jpg)
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.
![Page 5: The ifconfig Command](https://reader038.vdocument.in/reader038/viewer/2022100602/55895609d8b42a7d3e8b465b/html5/thumbnails/5.jpg)
5
Sample output
eth0 Link encap 10Mbps Ethernet HWaddr 00:0F:20:CF:8B:42inet addr 172.16.1.2 Bcast 172.16.1.255 Mask 255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU 1500 Metric 0RX packets 3136 errors217 dropped 7 overrun 26 TX packets 1752 errors 25 dropped 0 overrun 0
![Page 6: The ifconfig Command](https://reader038.vdocument.in/reader038/viewer/2022100602/55895609d8b42a7d3e8b465b/html5/thumbnails/6.jpg)
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.
![Page 7: The ifconfig Command](https://reader038.vdocument.in/reader038/viewer/2022100602/55895609d8b42a7d3e8b465b/html5/thumbnails/7.jpg)
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.
![Page 8: The ifconfig Command](https://reader038.vdocument.in/reader038/viewer/2022100602/55895609d8b42a7d3e8b465b/html5/thumbnails/8.jpg)
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.
![Page 9: The ifconfig Command](https://reader038.vdocument.in/reader038/viewer/2022100602/55895609d8b42a7d3e8b465b/html5/thumbnails/9.jpg)
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
![Page 10: The ifconfig Command](https://reader038.vdocument.in/reader038/viewer/2022100602/55895609d8b42a7d3e8b465b/html5/thumbnails/10.jpg)
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.
![Page 11: The ifconfig Command](https://reader038.vdocument.in/reader038/viewer/2022100602/55895609d8b42a7d3e8b465b/html5/thumbnails/11.jpg)
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.
![Page 12: The ifconfig Command](https://reader038.vdocument.in/reader038/viewer/2022100602/55895609d8b42a7d3e8b465b/html5/thumbnails/12.jpg)
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.
![Page 13: The ifconfig Command](https://reader038.vdocument.in/reader038/viewer/2022100602/55895609d8b42a7d3e8b465b/html5/thumbnails/13.jpg)
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.☺
![Page 14: The ifconfig Command](https://reader038.vdocument.in/reader038/viewer/2022100602/55895609d8b42a7d3e8b465b/html5/thumbnails/14.jpg)
14
● 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
![Page 15: The ifconfig Command](https://reader038.vdocument.in/reader038/viewer/2022100602/55895609d8b42a7d3e8b465b/html5/thumbnails/15.jpg)
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.
![Page 16: The ifconfig Command](https://reader038.vdocument.in/reader038/viewer/2022100602/55895609d8b42a7d3e8b465b/html5/thumbnails/16.jpg)
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!