Tutorial: Windows to Linux: Part 1 Network

Source: Internet
Author: User
Tags web hosting websphere application server
Linux network speed-up guide

Level: Entry

Chris Walden (cmwalden-at-us.ibm.com)
E-commerce architect, IBM Developer Relations
January 2004

IBM e-commerce architect Chris Walden willDeveloperworksThe nine articles published in this article will guide you how to use your Windows Operating Skills in Linux. This section will discuss the network, which is one of the best aspects of Linux.

In today's era, running a computer without a network is almost unimaginable. Email, Web browsing, and file sharing are what users expect, just like printing and viewing information on the screen.

Fortunately, Liunx was developed for the network from the very beginning. In fact, network is one of the best things for Linux. Linux supports popular network protocols such as TCP/IP and SMB (NetBIOS. Linux also provides mature tools for monitoring and filtering network traffic. Services such as FTP, Windows file and print sharing, and Web hosting are also available. Linux even provides tools for centralized directory services, virtual private network (VPN), and remote process calls.

Network hardware
Linux can use any network hardware with a driver. The Linux driver is compiled into the kernel either independently or in the form of a load module. The Linux kernel supports many popular NICs by default. When selecting network hardware, it is best to always use the devices listed in "hardware compatibility list" (see the link in reference. In addition, you must use the latest Linux release version.

Generally, if compatible network hardware is used, the NIC is automatically recognized when the system is installed. AvailableifconfigCommand to check the network hardware on the system. By default,ifconfigDisplays active network devices. Add-aSwitch to view all devices.

Listing 1. Using ifconfig

refname: ifconfig-a[root@cmw-t30 root]#  ifconfig -a eth0      Link encap:Ethernet  HWaddr 00:09:6B:60:8B:1E          inet addr:9.41.209.160  Bcast:9.41.209.255  Mask:255.255.255.0          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1          RX packets:47255 errors:0 dropped:0 overruns:0 frame:0          TX packets:32949 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:100          RX bytes:22140365 (21.1 Mb)  TX bytes:13519623 (12.8 Mb)          Interrupt:11 Base address:0xf000lo        Link encap:Local Loopback          inet addr:127.0.0.1  Mask:255.0.0.0          UP LOOPBACK RUNNING  MTU:16436  Metric:1          RX packets:1308081 errors:0 dropped:0 overruns:0 frame:0          TX packets:1308081 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:0          RX bytes:183376967 (174.8 Mb)  TX bytes:183376967 (174.8 Mb)

In the above list, there is only one network card in the system, which is identified as eth0.loThe adapter is a loopback (lookback), which is used by Linux to communicate with itself. We will discuss it further later.ifconfigCommand.

Network Device Name
A Linux network device is assigned an alias during configuration. The alias consists of a descriptive acronyms and a number. The first device of a certain type is numbered 0, and other devices are numbered 1, 2, 3, and so on. The following conventions are used to name a device. This information is taken from the Linux Network Administrator's Guide (see the link at the end of this Article ).

  • Eth0, eth1...
    These are Ethernet interfaces. They are used for most Ethernet cards, including many parallel port Ethernet cards.
  • Tr0, tr1...
    These are the interface interfaces of the ring card. They are used for most card ring NICs, including non-IBM network adapters.
  • S10, S11...
    These are the SLIP interfaces. The SLIP interface is associated with the serial line. The association sequence is the order in which they are allocated to the SLIP.
  • Ppp0, ppp1...
    These are PPP interfaces. Just like the SLIP interface, once the PPP interface is converted to the PPP mode, it is associated with the serial line.
  • Plip0.plip1...
    These are PLIP interfaces. The PLIP interface transmits IP data through a parallel line. These interfaces are allocated by the PLIP driver at system startup and mapped to parallel ports. In2.0.xIn the kernel, there is a direct relationship between the device name and the parallel port I/O port, but in the kernel of the updated version, the device name is allocated sequentially, just like SLIP and PPP devices.
  • Ax0, ax1...
    These are the AX.25 interfaces. AX.25 is the main protocol used by amateur radio operators. The method for allocating and ing the AX.25 interface is similar to that of the SLIP device.

There are many other interface types that can be used for other network drivers. We only list some of the most common ones.

Since Ethernet is the most common configuration, we will focus on it below. For more information about other types of connections, see references at the end of this article.

Network Configuration
When installing the Linux release version, you must configure the network. You may already have an activity eth0 from the initial configuration. This configuration may be sufficient for the current use, but you may need to make changes over time. The following describes different configuration items related to the IP network and the files and tools used to use these configuration items.

Webmin
Webmin inNetworkingProvides a set of excellent Network Configuration tools. You can configure separate interfaces and adjust their current settings or saved settings. You can also configure routes and gateways, DNS Client settings, and local host addresses. After editing all the configurations, you can clickApply ConfigurationYou do not have to restart the system.

Localhost

The local host address is included in/etc/hosts. This file andC:/winnt/system32/drivers/etc/hostsFile equivalent. The entry displays the alias of the IP address, which is used to assign a name without querying DNS.

127.0.0.1 localhost.localdomain localhost
10.10.10.10 cmw-t30

Tools in different release versions
Each release version has its own tool for configuring network settings. Refer to the document of a specific release to determine the tool to be used. Each tool provides the same configuration options as Webmin. Some versions may provide options specific to the release version.

Figure 1. Red Hat 8.x and 9.x use the RedHat-config-network Tool
Tool "src =" http://www-900.ibm.com/developerWorks/cn/linux/l-roadmap/part7/redhatconfnet.jpg "width =" 518 ">

Figure 2. SuSE and United Linux use the YAST Tool

Manual configuration is also possible, but this is a very profound topic. For more information about manual network configuration, see your release document and reference at the end of this article.

Analysis and monitoring tools
Linux comes with many tools to monitor network tasks.

Ifconfig
We have usedifconfigCommand to view the status of the Ethernet Card. However,ifconfigYou can also configure the device and report information about the device. Suppose you want to create a temporary network configuration for testing. You can use the tool in the release version to edit the configuration, but note that after the test is completed, all the settings are restored. UseifconfigYou can quickly configure the NIC without affecting the saved settings:

ipconfig eth0 192.168.13.13 netmask 255.255.255.0 up

The preceding command uses a class c ip address to set eth0 to address 192.168.13.13, and ensures that eth0 runs properly.

ipconfig eth0 down

The above command will disable the eth0 device. Usage ifconfigFor more information, seeinfo ifconfigPage.

Ifup/ifdown
To use saved configurations to activate and disable network devices, useifupAndifdown.

# Bring up eth0 using the saved configuration
ifup eth0

# Shut down eth0
ifdown eth0

Netstat
UsenetstatConsole Commands are used to output network connections, route tables, interface statistics, disguised connections, and multicast members.netstatIt has multiple command line switches to control its functions. Below are some common switches:

Output network status

netstat -p Display the PID or name of the program to which each socket belongs
netstat -a Displays both listener and non-listener sockets
netstat -t Show TCP connections
netstat -u Display UDP connections
netstat -e Display additional information. Use this option twice to obtain the most detailed information.

Below isnetstat -tpExample:

Listing 2. Using netstat

[root@cmw-t30 root]# netstat -tpActive Internet connections (w/o servers)Proto Recv-Q Send-Q Local Address           Foreign Address         StatePID/Program nametcp        0      0 localhost.localdo:29000 *:*                     LISTEN2389/attvpnctltcp        0      0 *:10000                 *:*                     LISTEN5945/perltcp        0      0 *:x11                   *:*                     LISTEN1120/Xtcp        0      0 *:ftp                   *:*                     LISTEN724/xinetdtcp        0      0 *:ssh                   *:*                     LISTEN710/sshdtcp        0      0 *:ipp                   *:*                     LISTEN797/cupsdtcp        0      0 *:505                   *:*                     LISTEN1043/rcdtcp        0      0 localhost.localdoma:ipp localhost.localdo:32772 ESTABLISHED797/cupsdtcp        0      0 sig-9-65-39-140.m:44916 sdoprods2.austin.i:1352 TIME_WAIT-tcp        0      0 10.100.100.101:33020    64.12.29.100:5190       ESTABLISHED1433/gaimtcp        0      0 localhost.localdo:44954 localhost.localdoma:ipp TIME_WAIT-tcp        0      0 localhost.localdo:44955 localhost.localdoma:ipp TIME_WAIT-tcp        0      0 localhost.localdo:44897 localhost.localdoma:ipp TIME_WAIT-tcp        0      0 localhost.localdo:44902 localhost.localdoma:ipp TIME_WAIT-tcp        0      0 localhost.localdo:44903 localhost.localdoma:ipp TIME_WAIT-tcp        0      0 localhost.localdo:44900 localhost.localdoma:ipp TIME_WAIT-tcp        0      0 localhost.localdo:44901 localhost.localdoma:ipp TIME_WAIT-tcp        0      0 10.100.100.101:44888    cs9336-61.austin.r:pop3 TIME_WAIT-tcp        0      0 localhost.localdo:32772 localhost.localdoma:ipp ESTABLISHED1246/gnome-cups-mantcp        1      0 localhost.localdo:32774 localhost.localdoma:ipp CLOSE_WAIT1246/gnome-cups-mantcp        0      0 10.100.100.101:33019    cs46.msg.sc5.yahoo:5050 ESTABLISHED1433/gaimtcp        0      0 sig-9-65-39-140.m:35061 d03nm119.boulder.i:1352 CLOSE_WAIT1720/wineservertcp        0      0 10.100.100.101:33021    64.12.30.4:5190         ESTABLISHED1433/gaim

I use most oftennetstatCommand to view the connections in the LISTEN or ESTABLISHED status. LISTEN is a service on the system that accepts connections from other machines. ESTABLISHED is an active connection between your machine and other machines. Make sure that you know all the LISTEN programs that are running. If you see some unidentifiable content, it may be a security concern.netstatThere are many options. Enterinfo netstatTo obtain the details of the command.

Route
routeConsole Commands allow you to display and operate IP Route tables.

Listing 3. Using route

[root@cmw-t30 plugins]# route|grep -v ipsecKernel IP routing tableDestination     Gateway         Genmask         Flags Metric Ref    Use Iface204.146.24.42   10.100.100.1    255.255.255.255 UGH   0      0        0 eth110.100.100.0    *               255.255.255.0   U     0      0        0 eth1127.0.0.0       *               255.0.0.0       U     0      0        0 lodefault         10.100.100.1    0.0.0.0         UG    0      0        0 eth1

Run without the command line switchrouteThe current route table is displayed. AvailablerouteModify the route table in a very fine-grained manner.

route add default gw 10.10.10.1

The preceding command adds a default route (it will be used if no other route matches ). All groups using this route will pass through the gateway "10.10.10.1 ". The device that will actually be used for this route depends on how we reach "10.10.10.1" -- the static route to "10.10.10.1" must be set in advance.

route add -net 192.56.76.0 netmask 255.255.255.0 dev eth0

The preceding command adds a route from "eth0" to "192.56.76.x. The Class C network mask modifier is not actually necessary because 192. * is a class c ip address. The word "Dev" can also be omitted here.

Routing is a very profound topic. AboutrouteYou can useinfo routeCommand.

Conclusion
Linux was designed for the network from the very beginning. It has built-in mature functions that were previously only visible in high-end enterprise products. However, despite all these powerful capabilities, the configuration of the Linux network is far less complex than that of the Windows network. Tools such as Webmin, RedHat-config-network, and YaST allow graphical configuration. SuchifconfigAndrouteSuch a tool allows you to view and modify network parameters through the console or script. SuchnetstatSuch a tool allows you to view individual network connections and display their relationships with running processes.

References

  • Read Other sections of the Windows to Linux journey series (Developerworks, January 1, November 2003 ).

  • Online Linux Network Administrator's Guide, Second Edition is a general reference Guide for Network management in the Liunx environment. Beginners and experienced users can find information about almost every important management activity, which is necessary to manage Linux network configurations.
  • Linux Ethernet HOWTO contains information about which Ethernet devices can be used in Linux and how to set them (focusing on hardware and low-level drivers for Ethernet cards ).
  • The "Linux document plan" also has a HOWTO list to help you easily find relevant documents.
  • The "hardware control list" includes the Red Hat hardware search page, SuSE Linux component database, and UnitedLinux certified and compatible hardware.
  • At IBMDeveloperworksIn the "LPI certification 102 exam prep, Part 3: Networking" tutorial, you will find more information about the network base.
  • IBMDeveloperworksThe "LPI certification 102 exam prep, Part 4: Secure shell and file sharing" tutorial introduces file sharing and security.
  • System security is a broad and complex topic, but in the world of interconnection, it affects everyone. Fortunately, it is not too early or too late to start strengthening system security. Adding Security to Common Linux Distributions and Strategies for Keeping a Secure Server (as mentioned above)Linux administration made easyChapter 1 of guide will help you enhance system security.
  • IBMDeveloperWorksThe "Linux hardware stability Guide" explains how to diagnose and fix many potential hardware problems.

  • At IBMDeveloperWorksThe article "Sharing computers on Linux (or heterogeneous) Networks" learns more about networks.

  • Compliance with IBMDeveloperWorksThis document describes how to build a network router on Linux to simulate the behavior of a Cisco router.
  • Adopt better security-IBMDeveloperWorksThe article "Using SSH for secure connections" shows how to achieve this.
  • For those who have switched from windows to Linux, another important reference is the Linux User Technical FAQ.
  • To start using IBM software on Linux, speeding up your Linux application development will provide you with the best reference materials. You can find installation tips and references for various applications such as DB2, Lotus Domino, WebSphere Application Server, and WebSphere Studio. You can also log on to get the free Linux software evaluation kit, which contains trial software and training materials.
  • InDeveloperWorksYou can find more references for Linux developers in the Linux area.
About the author
Chris Walden is an IBM Developer Relations Technical Consulting (also knownDragonslayersE-commerce architect, which provides education, implementation, and consulting for IBM business partners. He is dedicated to Linux-related work and will publicize the benefits of Linux to people around him as soon as he has the opportunity. In addition to fulfilling the responsibilities of his architect, he is also proficient in various fields of Linux infrastructure servers, including files, printing and other application services in the hybrid platform user environment. Chris has 10 years of experience in the computer industry. From field support to Web application development and consulting, he has been involved in various fields. You can contact Chris via cmwalden-at-us.ibm.com.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.