Выбрать главу

ifconfig lo 127.0.0.1

route add 127.0.0.1 lo

These commands create the localhost interface in memory (all interfaces, such as eth0 or ppp0, are created in memory with Linux), and then add the IP address 127.0.0.1 to an internal (in-memory) table so that the Linux kernel's networking code can keep track of routes to different addresses.

Use the ifconfig command as shown previously to test the interface.

You should now be able to use ping to check that the interface is responding properly like this (using either localhost or its IP address):

$ ping -c 3 localhost

PING localhost.localdomain (127.0.0.1) from 127.0.0.1 : 56(84) bytes of data.

64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=0 ttl=255 time=212 \

usec

64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=1 ttl=255 time=80 usec

64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=2 ttl=255 time=50 usec

--- localhost.localdomain ping statistics ---

3 packets transmitted, 3 packets received, 0% packet loss

round-trip min/avg/max/mdev = 0.050/0.114/0.212/0.070 ms

The -c option is used to set the number of pings, and the command, if successful (as it was previously), returns information regarding the round-trip speed of a test packet sent to the specified host.

Networking with TCP/IP

The basic building block for any network based on UNIX hosts is the Transport Control Protocol/Internet Protocol (TCP/IP) suite of three protocols. The suite consists of the Internet Protocol (IP), Transport Control Protocol (TCP), and Universal Datagram Protocol (UDP). IP is the base protocol. The TCP/IP suite is packet-based, which means that data is broken into little chunks on the transmit end for transmission to the receiving end. Breaking data up into manageable packets allows for faster and more accurate transfers. In TCP/IP, all data travels via IP packets, which is why addresses are referred to as IP addresses. It is the lowest level of the suite.

TCP is a connection-based protocol. Before data is transmitted between two machines, a connection is established between them. When a connection is made, a stream of data is sent to the IP to be broken into the packets that are then transmitted. At the receiving end, the packets are put back in order and sent to the proper application port. TCP/IP forms the basis of the Internet; without it, the Internet would be a very different place indeed, if it even existed!

On the other hand, UDP is a connectionless protocol. Applications using this protocol just choose their destination and start sending. UDP is normally used for small amounts of data or on fast and reliable networks. If you are interested in the internals of TCP/IP, see the "Reference" section at the end of this chapter for places to look for more information.

Fedora and Networking

Chances are that your network card was configured during the installation of Fedora. You can, however, use the ifconfig command at the shell prompt or Fedora's graphical network configuration tools, such as system-config-network, to edit your system's network device information or to add or remove network devices on your system. Hundreds of networking commands and utilities are included with Fedora — far too many to cover in this chapter and more than enough for coverage in two or three volumes.

Nearly all ethernet cards can be used with Linux, along with many PCMCIA wired and wireless network cards. The great news is that many USB wireless network devices also work just fine with Linux, and more will be supported with upcoming versions of the Linux kernel. Check the Linux USB Project at http://www.linux-usb.org/ for the latest developments or to verify support for your device.

After reading this chapter, you might want to learn more about other graphical network clients for use with Linux. The GNOME ethereal client, for example, can be used to monitor all traffic on your LAN or specific types of traffic. Another client, NmapFE, can be used to scan a specific host for open ports and other running services.

Advanced Wireless Networking

As stated earlier, Linux has had support for wireless networking since the first standards were developed in the early 1990s. With computers getting smaller and smaller, the uses for wireless networking have increased; meanwhile, the transmission speeds also are increasing all the time. There are several different ways to create a wireless network. The following sections introduce you to several Linux commands you can use to initialize, configure, and manage wireless networking on your Fedora system.

Support for Wireless Networking in Fedora

The Linux kernel that ships with Fedora provides extensive support for wireless networking. Related wireless tools for configuring, managing, or displaying information about a wireless connection include the following:

► iwconfig — Sets the network name, encryption, transmission rate, and other features of a wireless network interface

► iwlist — Displays information about a wireless interface, such as rate, power level, or frequency used

► iwpriv — Uses i to set optional features, such as roaming, of a wireless network interface

► iwspy — Shows wireless statistics of a number of nodes

Support varies for wireless devices — most likely in the form of a PCMCIA adapter — although some USB wireless devices now work with Linux. In general, Linux wireless device software (usually in the form of a kernel module) supports the creation of an ethernet device that can be managed by traditional interface tools such as ifconfig — with wireless features of the device managed by the various wireless software tools.

For example, when a wireless networking device is first recognized and initialized for use, the driver will most likely report a new device:

wvlan_cs: WaveLAN/IEEE PCMCIA driver v1.0.6

wvlan_cs: (c) Andreas Neuhaus <andy@fasta.fh-dortmund.de>

wvlan_cs: index 0x01: Vcc 3.3, irq 3, io 0x0100-0x013f

wvlan_cs: Registered netdevice eth0

wvlan_cs: MAC address on eth0 is 00 05 5d f3 1d da

This output (from the dmesg command) shows that the eth0 device has been reported. If DHCP is in use, the device should automatically join the nearest wireless subnet and be automatically assigned an IP address. If not, the next step is to use a wireless tool such as iwconfig to set various parameters of the wireless device. The iwconfig command, along with the device name (eth0 in this example), shows the status:

# iwconfig eth0

eth0 IEEE 802.11-DS ESSID:"GreyUFO" Nickname:"Prism I"

     Mode:Managed Frequency:2.412GHz Access Point: 00:02:2D:2E:FA:3C