Linux Network Express Guide
Level: Getting Started
Chris Walden (cmwalden-at-us.ibm.com) e-commerce architect, IBM Developer Relations 2004 January
IBM e-commerce architect Chris Walden will pass him
The nine series of articles published on DeveloperWorks guides you how to use your Windows operation skills in your Linux environment. This section will explore the network, which is one of the best aspects of Linux.
In this era, running a computer that is not connected to the network is almost unimaginable. Email, web browsing and file sharing are printed and viewed on the screen, all of which are expected.
Fortunately, Liunx is developed from the beginning. In fact, the network is one of the best things for Linux. Linux supports popular network protocols such as TCP / IP and SMB (NetBIOS). Linux also has a mature tool for monitoring and filtering network traffic. Services such as FTP, Windows files, and print sharing, and Web hosting are also available. Linux even provides tools for centralized directory services, virtual private network (VPN), and remote processes.
Network hardware Linux can use any network hardware with drivers. The Linux driver is compiled into the kernel separately or in the form of loadable modules. Linux keys support many popular network cards default. When you select a network hardware, it is best to always use the device listed in the "Hardware Compatibility List" (see links in the reference). Also use the latest Linux distribution.
Under normal circumstances, if you are using a compatible network hardware, the NIC will automatically recognize when installing the system. You can use the ifconfig command to check the network hardware on your system. By default, ifconfig displays the activity network device. Add a -A switch to this command to see 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 MUNTU: 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 TXQuelelen: 100
RX BYTES: 22140365 (21.1 MB) TX bytes: 13519623 (12.8 MB)
Interrupt: 11 Base Address: 0xf000
Lo 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 TXQuelelen: 0
RX BYTES: 183376967 (174.8 MB) TX bytes: 183376967 (174.8 MB)
In the list above, there is only one network card in the system, identifying as eth0. The LO adapter is a loopback, which is used by Linux to communicate with itself. The IFCONFIG command will be discussed later. Network Device Name Linux network device is configured with an alias when configured, which consists of a descriptive thumbnail and a number. Some type of first device number is 0, and other devices are symmetrically numbered 1, 2, 3, and so on. The following will be used when named the device. This information is taken from Linux Network Administrator's Guide (see links in the reference materials at the end of this article).
Eth0, Eth1 ... These are Ethernet card interfaces. They are used for most Ethernet cards, including many parallel port Ethernet cards. TR0, TR1 ... These are the token ring network card interface. They are used in most token ring network cards, including non-IBM production network cards. S10, S11 ... These are SLIP interfaces. The SLIP interface is associated with the serial line, and the association order is the order they are assigned to the SLIP. PPP0, PPP1 ... These are PPP interfaces. 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 datagram via a parallel line. These interfaces are allocated by the PLIP driver when the system starts and is mapped to the parallel port. In the 2.0.x core, there is a direct relationship between the device name and the I / O port of the parallel port, but in the updated version of the kernel, the device name is sequentially assigned, just like SLIP and PPP devices. AX0, AX1 ... These are the AX.25 interface. AX.25 is the main protocol used by amateur radio operators. The allocation and mapping mode of the AX.25 interface is similar to 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.
Since the Ethernet is the most common configuration, you will focus on it. For more information on other types of connections, see the reference information at the end of this article.
Network configuration When you install Linux release, you have to configure your network. You may have an activity Eth0 from the initial configuration. This configuration is sufficient for current use, but you may need to make changes over time. Different configuration items related to IP networks will be described below, as well as files and tools used to use these configuration items.
Webminwebmin offers a set of excellent network configuration tools in Network Configuration under Networking, NetWorking. You can configure a separate interface and adjust their current settings or saved settings. You can also configure routing and gateways, DNS client settings, and local host addresses. After editing all the configurations, you can click Apply Configuration to apply them without having to restart the system.
The localhost local host address is included in the / etc / hosts. This file and C: / Winnt / System32 / Drivers / etc / hosts paid. The entry displays an alias of the IP address for assigning names without querying DNS. 127.0.0.1 localhost.localdomain localhost10.10.10.10 CMW-T30
The tools in different release versions Each release has its own tools to configure network settings. You should refer to the specific release version of the document to determine the tool to use. Each tool provides substantially the same configuration options as Webmin tools. Some of these versions may provide options specific to this release.
Figure 1. Red Hat 8.x and 9.x Using RedHat-Config-Network Tools
Figure 2. SUSE and UNITED Linux use YaST Tools
Manual configuration is also possible, but this is a very deepest theme. Please refer to your distribution document and the references at the end of this article for more information on manual network configuration. Analysis and monitoring tools Linux come with many tools to monitor network tasks.
IfConfig We use the IFConfig command above to view the status of the Ethernet card. However, ifconfig can also configure the device and report the situation of the device. Suppose you want to create a temporary network configuration for testing. You can use the tool in the release to edit the configuration, but you need to pay attention to restore all settings back after completing the test. By using ifconfig, we have no need to affect the saved settings, you can quickly configure the network card:
IpConfig Eth0 192.168.13.13 Netmask 255.255.255.0 Up
The above command uses a Class C IP address to set ETH0 to address 192.168.13.13, and make sure it runs normally.
IPConfig Eth0 Down
The above command will close the ETH0 device. See the INFO ifconfig page about the full detail of IFConfig.
IFUP / IFDown To activate and disable network devices using the saved configuration, use IFUP and IFDown, respectively.
# Bring up eth0 using the saved configurationifup eth0 # Shut down eth0ifdown eth0
NetStat uses the NetStat console command to output a network connection, routing table, interface statistics, camouflage connection, and multicast members. NetStat has multiple command line switches to control their functions. Below is some common switches:
Output network status
NetStat -p Displays the PID or Name NetStat -a of the program to each socket to simultaneously display the listening and non-listening socket netstat -t display TCP connection netstat -u display UDP connection NetStat -e display additional information; use This option can get the most detailed information twice.
Here is an example of NetStat -tp:
Listing 2. Using NetStat
[root @ cmw-t30 root] # NetStat -tp
Active Internet Connections (W / O Servers)
Proto Recv-q Send-Q Local Address Foreign Address State
PID / Program Name
TCP 0 0 localhost.localdo: 29000 *: * listen
2389 / attvpnctl
TCP 0 0 *: 10000 *: * listen
5945 / Perl
TCP 0 0 *: x11 *: * listen
1120 / x
TCP 0 0 *: ftp *: * listen
724 / xinetd
TCP 0 0 *: ssh *: * listen
710 / SSHD
TCP 0 0 *: ipp *: * listen
797 / Cupsd
TCP 0 0 *: 505 *: * Listen
1043 / RCDTCP 0 0 localhost.localdoma: IPP localhost.localdo: 32772 Established
797 / Cupsd
TCP 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 ESTABLISHED
1433 / GAIM
TCP 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 established
1246 / GNOME-CUPS-MAN
TCP 1 0 localhost.localdo: 32774 localhost.localdoma: ipp close_wait
1246 / GNOME-CUPS-MAN
TCP 0 0 10.100.100.101:33019 cs46.msg.sc5.yahoo:5050 ESTABLISHED
1433 / GAIM
TCP 0 0 SIG-9-65-39-140.m: 35061 d03nm119.boulder.i: 1352 Close_Wait
1720 / WineServer
TCP 0 0 10.100.100.101:33021 64.12.30.4:4:5190 Establish
1433 / GAIM
I often use the netstat command to view the connection in the Listen or ESTABLISHED state. Listen is a service on the system that accepts connections from other machines. Establish is an activity connection between your machines and other machines. Make sure you know all Listen programs running. If some unrecognized content, it may be a security concern. NetStat has many options. Please type in Info NetStat in the command line to get the details of the command.
The ROUTEROUTE console command allows you to display and manipulate the IP routing table.
Listing 3. Using ROUTE
[root @ cmw-t30 plugins] # Route | grep -v ipsec
KERNEL IP Routing TableDestination Gateway Genmask Flags Metric Ref Use Iface
204.146.24.42 10.100.100.1 255.255.255.255 UGH 0 0 0 Eth1
10.100.100.0 * 255.255.255.0 U 0 0 0 Eth1
127.0.0.0 * 255.0.0.0 U 0 0 0 LO
Default 10.100.100.1 0.0.0.0 UG 0 0 0 Eth1
Running Route will display the current routing table without command line switches. You can use ROUTE to make very fine modifications to the routing table.
Route Add Default GW 10.10.10.1
The above command adds a default route (it will be used without other routing matches). All packets using this route will pass through the gateway "10.10.10.1". The devices that actually use the route depends on how we reach "10.10.10.1" - to "10.10.10.1" static routes must be pre-set in advance.
Route Add -Net 192.56.76.0 Netmask 255.255.255.0 Dev Eth0
The above command adds a route through "eth0" to the network 192.56.76.x. The Class C network mask modifier is actually not required because 192. * is a Class C IP address. The word "dev" here can also be omitted.
Routing is a very deepest topic. The full information about the route option can be obtained through the Info Route command.
Conclusion Linux is designed for network from the beginning. It has a mature function that has been visible only in high-end enterprise products. However, despite all of these powerful capabilities, the Configuration of Linux networks is far from the configuration of the Windows network. Tools such as Webmin, RedHat-Config-Network, and YaST allow graphical configurations. Tools such as ifconfig and Route allow for viewing and modifying network parameters through console or scripting. Tools such as NetStat allow for viewing a separate network connection and showing their relationship with the process running.
Reference
Read the other parts of Windows to Linux Tour Series (DeveloperWorks, November 2003). Online Linux Network Administrator's Guide, Second Edition is a general reference guide for network management in a 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 which Ethernet devices can be used for Linux, and how to set their information (focus on hardware and Ethernet cards). "Linux Document Plan" also has a list of HOWTO, helping you easily find relevant documents. "Hardware Control List" includes the Red Hat hardware search page, the SUSE Linux component database, and UnitedneTEDLinux authentication and compatible hardware. In the IBM DeveloperWorks tutorial "LPI Certification 102 Exam PREP, PART 3: Networking", you will find more information about the web foundation. IBM DeveloperWorks Tutorial "LPI CERTIFICATION 102 Exam PREP, Part 4: Secure Shell and File Sharing" introduces file sharing and security. System security is a broad and complex topic, but in the world of interconnect, it affects everyone. Fortunately, it is not too late to start to strengthen system security now. Documentation Adding Security To Common Linux Distributions and Strategies for Keeping A Secure Server (this is the first chapter 12 of the Linux Administration Made Easy Guide ") will help you strengthen system security. IBM DeveloperWorks Article "Linux Hardware Stability Guide" shows how to diagnose and fix many potential hardware issues. Learn more about the network in the IBM DeveloperWorks article "Share Computers on Linux (or Heterogeneous) Network. Follow the IBM DeveloperWorks article "Build Network Routers on Linux" to simulate the behavior of the Cisco router. Using a better security - IBM DeveloperWorks article "Connects to use SSH" show how to achieve this. Another important reference is the Linux user technology FAQ for readers who turn to Linux from Windows. To start using IBM software products on Linux, develop refueling for your Linux application will provide you with the best reference. You can find installation prompts and reference information about DB2, Lotus Domino, WebSphere Application Server, WebSphere Studio, etc. You can also log in to get the free Linux Software Evaluation Kit, with trial software and training materials. More reference materials for Linux developers can be found in the developerWorks Linux zone.