Configuration of TCP / IP under Linux
The topic of doing the year occasionally encountered TCP / IP under Linux, I didn't understand the textbook, I didn't say it to everyone.
The following is program code:
A.TITLE1: LINK {font-size: 17.9px; font-family: arian; font-weight: bold; text-decoration: none; color: #ffff;} a.title1: visited {font-size: 17.9px; FONT-FAMILY: ARIAL; FONT-Weight: bold; text-decoration: none; color: #ffff;} a.title1: active {font-size: 17.9px; font-family: arian; font-weight: bold; text -Decoration: none;} a.title1: hover {font-size: 17.9px; font-family: arial; font-weight: bold; text-decoration: none; color: #ffff;} a. Title2: link {text-decoration: none; color: # 000000; font-size: 12px} a.title2: visited {text-decoration: none; color: # 000000; font-size: 12px} a.title2: active { Text-Decoration: None; color: # ff0000; font-size: 12px} a.title2: hover {text-decoration: none; color: # ff0000; font-size: 12px}
The following is program code:
A.TITLE1: LINK {font-size: 17.9px; font-family: arian; font-weight: bold; text-decoration: none; color: #ffff;} a.title1: visited {font-size: 17.9px; FONT-FAMILY: ARIAL; FONT-Weight: bold; text-decoration: none; color: #ffff;} a.title1: active {font-size: 17.9px; font-family: arian; font-weight: bold; text -Decoration: none;} a.title1: hover {font-size: 17.9px; font-family: arial; font-weight: bold; text-decoration: none; color: #ffff;} a. Title2: link {text-decoration: none; color: # 000000; font-size: 12px} a.title2: visited {text-decoration: none; color: # 000000; font-size: 12px} a.title2: active { Text-Decoration: none; color: # ff0000; font-size: 12px} a.title2: hover {text-decoration: none; color: # ff0000; font-size: 12px} chinaUnix.Net Home | Forum | Essence | | Talent | Salon | Search
ChinaUnix-Linux Discussion Zone Essence Post
Configuring TCP in Linux / IPhttp: //www.chinaunix.net Author: lwj2003429 Posted on: 2003-04-04 14:10:46 configure TCP / IP in Linux
This tutorial first reviews the origin of TCP / IP, then explains the model of TCP / IP development, and finally discusses how TCP / IP works - including IP addresses, subnets, and routing. After taking these theoretical foundations, we will discuss various network profiles needed by Linux and how to initialize network interfaces and how to edit system routing tables. In the end of this tutorial, we will briefly look at how to analyze the network and how to ensure that data is accurate and correct.
TCP / IP brief history
In recent years, with the widespread use of the "Transmission Control Protection Agreement / Internet Protocol (TCP / IP)", it has become a factual standard in network communications. At this point, it is necessary to attribute to the rapid development of the Internet and "language" to understand in different platforms, equipment, and operating systems. Let us first understand the history of TCP / IP.
In the late 1960s, the US Department of Defense (DOD) aware of its internal and prominent communication issues. The growing electronic information traffic between DOD staff, research laboratory, university, and contractors has encountered serious obstacles. Different entities and organizations that make up DOD have computer systems from different computer manufacturers, which run different operating systems and use different network topology and protocols.
Advanced Research Projects Agency, ARPA is an scheme that solves this problem. ARPA has allocated a group of communication standards with universities and computer manufacturers. The alliance determines and constructs 4 nodes of networks, which becomes the foundation of today's Internet. In the 1970s, the network ported to a new, core agreement design, which became the foundation of TCP / IP.
Open System Interconnection (OSI) Model
Now, we use many different types of computers, which have different operating systems, CPUs, and network interfaces, and more. These differences have problems with communication between computer systems. In 1997, the International Standardization Organization (ISO) created a subcommittee to develop data communication standards to promote multi-supplier interoperability. The result is an open system interconnect (OSI) model.
The OSI model did not determine any communication standards or protocols; instead, it only provides some guiding suggestions that the communication task should follow.
Note: The OSI model is just a model or framework, which determines the function to be executed, and it is important to understand this. It does not explain how to perform these features in detail. However, for some OSI models, ISO has indeed accepted some specific protocols that meet the OSI standard. For example, ISO accepts the CCITT X.25 protocol, which provides most of the service of the network layer in the OSI model.
7 OSI layers
For the sake of simplicity, the ISO Subcommittee adopts a method of separation. The complex communication process is divided into a smaller sub-task, and the problem becomes more easily handled, and each subtask can be optimized separately. The OSI model consists of 7 layers:
· Application layer
· Representation
· Conference layer
· Transportation
· Network layer
· data link layer
· Physical layer
A set of specific features are assigned to each layer. Each layer uses the next layer of service and provides services to its upper layer. For example, a network layer uses a data link layer service and provides a service related to a network for the transport layer.
OSI layer, continued
This layer is simple in the concept of a service and serving its adjacent layers. Consider how the company is doing: Secretary writes a memo to the president (adjacent last level) to provide secretarial services. The secretary uses the letter of service (adjacent next floors) to send messages. By separating these services, the Secretary (application) does not have to know how the message is actually transmitted to the receiver. The Secretary only needs to make a letter to send a message to the message. As many secretaries send a memo by using this standard messenger service, the hierarchical network can send this packet by packet to the network layer. Note: Do not confuse the application layer with applications performed on your computer (all words - Application in English). Keep in mind that the application layer is part of the OSI model, which does not specify how the interface between the user and the communication path works, the application is the specific implementation of this interface. The actual application typically performs the service of the application layer, the session layer, and the layer, and leaves the transport layer, the network layer, the data link layer, and the physical layer service to the network operating system.
Cross-layer communication
Each layer communicates with the same layer in other computers. For example, a third layer in a system communicates with another computer system.
When the information passes from a layer to the next layer, one head is added in front of the data to indicate the source and destination of the information. Information blocks consisting of data and heads from a layer have become the next layer of data. For example, when the 4th layer passes the data to a third layer, it adds its own head. When the third layer passes the information to the second layer, the third layer will add the header data from the 4th layer as its data, and add a third layer of the head before the data, and then this "head Data "is transmitted to the next layer.
The name of each layer information unit is different:
Application layer-> message
Transport layer-> segment
Network layer -> Detailed
Data Link Layer -> Frame (also known as packet)
Physical layer->
Before the OSI model appears, the US Department of Defense defines its own network model, namely the DOD model. The DOD model is tightly associated with the TCP / IP protocol suite, which will be explained in the next section.
TCP / IP Protocol Stack (TCP)
The TCP / IP protocol stack indicates a network architecture similar to the OSI model.
However, TCP / IP is not as detailed in detail in the OSI model. OSI's top 3 levels are approximately comparable to the TCP / IP's internet access protocol. Some examples of processing protocols are Telnet, FTP, SMTP, NFS, SNMP, and DNS.
The transport layer of the OSI model is responsible for the transmission of reliable data. In the Internet Agreement Stack, this corresponds to the host to the host protocol. Examples of this are TCP and UDP. TCP is used to convert unordanceless messages from the upper protocol and provide the necessary confirmation and connection-oriented flow control between remote systems.
UDP is similar to TCP, but it is not connected, and does not confirm the data reception. UDP only receives the message and passes it to the upper layer protocol. Because UDP does not overhead related to TCP, it provides a more efficient interface for operations such as remote disk services.
TCP / IP protocol stack (IP)
Internet Protocol (IP) is responsible for communication between inter-system-free communication. It is equivalent to part of the network layer in the OSI model, which is responsible for information on the network. This communication is completed by checking the network layer address, which determines the system and path of sending messages.
IP provides the same function as the network layer and helps get messages between the system, but it does not guarantee that these messages can be successfully transferred. IP can also divide these messages into multiple segments and then reorganize them at the destination. Alternatively, each segment can be transmitted between systems in systems. If these segments arrive, IP will re-constitute these packets into the correct sequence at the destination.
IP address
The Internet protocol requires an address to allocate each device on the network. This address is an IP address, which consists of 4 eight-bit metals. These eight-bit elements each define a unique address that represents a part of this address (sometimes it can also represent subnets), while the other part represents a specific node on the network.
There are several addresses in the TCP / IP network with special meaning:
• Indicates the local node in the current network with zero. For example, 0.0.0.23 refers to a 23rd workstation in the current network. Address 0.0.0.0 refers to the current workstation.
· When troubleshooting and network diagnosis, the address starting with 127 is very important. The network address block 127.x.x.x is defined as a class A address, and the address block is retained for internal loopback.
• A complete address of all bits (that is, value 255) represents "all" addresses. Therefore, 192.18.255.255 means sends a message to 192.18. All nodes on the network; similar, 255.255.255.255 mean that the message is sent to each node on the Internet. These addresses are used for multipoint broadcast messages and service announcements.
Note: When assigning a node number to the system, do not use 0 or 255, they are all retained numbers, with special meanings.
IP address type
Assign an IP address to a certain range, called the IP address classification, depending on the size of the application and organization. Three most common types of addresses are Class A addresses, Class B addresses, and Class C addresses. These three classifications indicate the number of IP addresses that can be allocated local networks.
Class A addresses for a very large network or related network. Class B address is used for large networks of more than 256 nodes (but less than 65536 nodes). Most organizations use C-class addresses. A organization is a good idea because the number of category B addresses is limited. Class D addresses are reserved for multipoint broadcasts for web messages, and the E class addresses are reserved for experimentation and development.
Class address
A from 0.x.x.x to 126.x.x.x
B from 128.0.x.x to 191.255.x.x
C from 192.0.0.x to 223.255.255.x
D from 224.0.0.1 to 239.255.255.255
E from 240.x.x.x to 255.255.255.255
"Special" IP address
If your network is not connected to the Internet, you can freely select any legal network addresses. Just make sure your internal network packet will not run to the actual Internet. To ensure that even if the packet does run out, there will be no hazards, and you should use a number of those network addresses that are reserved for dedicated. Internet Assigned Numbers Authorit, IANA has retained some of the network numbers in A, B, and Class C class addresses, you can use these addresses without registration. These addresses are only valid in the dedicated network, and (theoretically) will not route the actual Internet site.
A 10.0.0.0
B 172.16.0 - 172.31.0.0
C 192.168.0 - 192.168.255.0
Please note that the second block and the third block contain 16 and 256 networks, respectively.
Selecting an address from these network numbers for those networks that are completely unconnected to the Internet are useful. You can still access another network (such as the Internet) by using a single host to do a gateway. For local networks, you can access the gateway through an internal dedicated IP address, and the external world knows the gateway by formally registered address (assigned by bandwidth vendor).
Subnet and subnet mask
The division subnet is a process of dividing large, actual network into smaller logical networks. The reasons for dividing the network have the following points: the electrical (physical layer) of the networked technology restrictions; Reduce network segment loads; or need to connect remote locations with high speed lines. The result of dividing the network segment is to make the entire network into a network consisting of some small subnet blocks, which is easy to manage. Communication between these smaller subnets is performed through the gateway and the router. Similarly, an organization can have several subnets physically in the same network to logically divide the network function into multiple workgroups.
Separate subnets are branches of the entire network. In conavoit, a Class B network is divided into 64 separate subnets. To complete this subnet division, you need to treat IP addresses as two parts: network and host. The network part consists of allocated IP addresses and subnet information bits. In fact, these bits are the address part of the host. Assigned to the B network to indicate that the number of bits of the network part is 16, plus 6 bits of the subnet portion, and a total of 22 districts. The result of this division is 64 networks, 1024 nodes per network. The network portion in the IP address can be large, depending on the number of hidden networks or the number of nodes of each network.
Subnet, second part
Setting the subnet mask is actually determined where the network address ends and where the host address is started. The subnet mask is included in the network portion of the entire 1 and the host part of the entire zero.
Make a C-network network by the following information:
N = network
H = host
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN. Hhhhhhhh
Each location represents one of the 32-bit address space. If this C-class network is divided into four C-class networks, its representation is as follows:
Nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnhhhhhh
The subnet mask is as follows:
111111111.111111111111111111111.11111111111.1111111.11.1111111.11.11.11000000
If you use a decimal number and point symbol (ie, a dotted quad) this address, the subnet mask is 255.255.255.192. This mask is used in communication between nodes on all subnets in this particular network.
Subnet, example
Conversely, if three digits from the host portion of the IP address, eight networks can be formed, and its network mask is as follows:
111111111.111111111111111111111111111111111111111111100000
The subnet mask is 255.255.255.224. Each of these eight networks can have 30 nodes because there are 5 address bits to be used. (This should be 32, but because all 1 and all 0 are unhanective host addresses, they cannot be used).
Network host address range broadcast
192.168.1.0 192.168.1.0 to 192.168.1.30 192.168.1.30
192.168.1.32 192.168.1.32 to 192.168.1.63 192.168.1.63
192.168.1.64 192.168.1.64 TO 192.168.1.95 192.168.1.95
192.168.1.96 192.168.1.96 to 192.168.1.127 192.168.1.127
192.168.1.128 192.168.1.159 192.168.1.159
192.168.1.110 192.168.1.191 192.168.1.191 192.168.1.191
192.168.1.192. 192.168.1.223 192.168.1.223
192.168.1.224 192.168.1.224 192.168.1.254 192.168.1.254 Tip: If you need some help, you can find online subnet calculars on www.cotse.com/networkcalculator.html.
Cross-network communication: gateways and routing
Since IP addressing has this structure, the host can only communicate with other hosts on the same network. To overcome this limit, we add routes and gateways to the network. Routing is the mechanism of determining the packet from the path source to the destination. Create a path or route by looking for the IP address of the destination in the routing table. If you find this address, send the packet to that network; if you don't find it, send packets to items called the default route, which is the IP of all "unknown" addresses. address.
The machine or device that performs route and / or forwarding features is called a gateway or router. Sometimes these two terms can also be used interchangeably. From a technical point of view, the gateway describes such a system or device that sends a message between different types of networks; and the router sends a message between the same type of network. Because we only discuss the use of TCP / IP protocol, we don't consider this fine difference, but it is aware of the difference between the two.
It is also worth noting that by definition, we know that the gateway is equipped with more than one network interface (ie, A and B), each configuration of different IP or IP / subnets. This is the reason why "network bridge" is achieved. The packet reaches the interface A and then performs one of the following four operations based on the various items in the table in this device that acts as a gateway. You can:
· Host sent to network A
· Transfer to "upstream" default routing equipment on network A
· Host sent to network B
· Transfer to "upstream" default routing device on the network B
Routing configuration
There are four common routing configurations:
• Minimum - The network that is completely separated from all other networks only requires the smallest route. Usually established the smallest routing table when initializing the network interface. If you don't need to communicate with other TCP / IP networks, and don't use the subnet, this is all the routing information required for the system.
· Static-network has one or two gateways, usually use static routes to configure the network. The static routing table is automatically created by the network configuration script (IP provided by the user) or manually created by the system administrator (using the / sbin / route command discussed in Section 5). This table is like a name that is referred to as it is static. It does not adjust with the network changes. When the network changes, the routing table must be manually configured.
· Dynamic-large networks typically have multiple routers and / or gateways, for redundant / fault recovery purposes, they may point to the same remote network. This is the land of the dynamic route. Dynamic routing allows the use of a protocol - Yes, you guessed - called a routing protocol, dynamically constructively (concurrently updated) routing table according to the information exchanged between routing devices. This continuous information exchange provides a mechanism that uses this mechanism to automatically adjust the route to adapt to the changing network conditions -, for example, the traffic is too large or run interrupt. The maximum disadvantage of dynamic routes is that routing information between devices will consume considerable bandwidth.
• The fourth option is a combination of static and dynamic routing. The machines on each subnet use static routes to reach the machines close to them. The default routing - the routes used by the packets that are not assigned by the routing table - are set to a gateway machine, which is configured to provide dynamic routing, so it is known to understand the network other than its subnet.
Dynamic routes are based on these routing protocols (internal protocols, such as RIP, Hello, and OSPF, external protocols, such as EGP and BGP), to enable dynamic routing through gateway route daemon Gated. Dynamic routes are not the scope discussed in this tutorial. For more information about this, see the TCP / IP Network Administration book listed in the Craig Hunt of "Concluding, References, and Feedback" in the end of this tutorial. carry on……
It will now be put into practice in all theoretical knowledge. In the next chapter, we will explore:
· RED HAT 7.0 is responsible for network interface configuration files
· Use ifconfig check and configure interface
· Add and edit static routes
· Use NetStat to monitor / exclude faults on the network interface
Key files and scripts
The actual process of the network interface initialization (sometimes called "starting interface") is controlled by a set of configuration files and scripts, most of these files and scripts in / etc directory. These profiles tell Linux its IP address, host name, and domain name; script is responsible for the initialization of network interfaces.
Unfortunately, there is no unified standard in the different distribution (Distribution). To provide specific examples of this paper, a description is made based on widely used Red Hat 7.0 packages. Keep in mind that if your distributed version is not using Red Hat or is not based on Red Hat conventions (such as Mandrake Distribution Edition), some files referenced here will be in other directories or have other names. However, the network effect and the actual effect are the same - passed the network information stored in a series of configuration files to the script and then initialize the interface and network route with the script.
Key files involving initializing and configuring network interfaces:
· / Etc / hosts (map hostname to IP address)
· / Etc / networks (map domain names to the network address)
· / Etc / sysconfig / network (open or close networked, set host name and gateway)
· /Etc/resolv.conf (setting the IP address of the name server or DNS server)
· /Etc/rc.d/rc3.d/s10NetWork (activated the configured Ethernet interface during boot, the symbolic link in the run level directory /etc/rc.d/rcn.d/)
· / Etc / sysconfig / network-scripts collection of some files. These files include the main configuration of the network connection, as well as a symbolic link to interface status and control functions.
/ etc / hosts
/ etc / hosts is a simple text file that links the IP address and hostname. Each computer in the TCP / IP network must have a unique IP address. The hosts file only allows users to link hostnames with IP addresses to use this name when accessing your computer without entering a long string number. Each of / etc / hosts sequentially contains an IP address, blank and hostname and / or alias. The well number (#) indicates the comment start. E.g:
# / etc / hosts
# Last Updated 12/3/2000
127.0.0.1 Loopback Localhost # loopback (LO0) Name / AddRESS
192.168.1.5 janus.syroidmanor.com Janus
192.168.1.6 thumper.syroidmanor.com thumper
192.168.1.7 Donovan.syroidmanor.com Donovan192.168.1.8 RaidServer
192.168.1.20 Phoenix.Syroidmanor.com Phoenix
192.168.1.15 Hydras.Syroidmanor.com Hydras
In the HOSTS file displayed above, IP address 192.168.1.5 is mapped to host Janus.SyroidManor.com, and assigned to it an alternate hostname (or alias) Janus. Although DNS has replaced this host file, it still uses it for the following reasons:
· Most systems have a small host table containing the names and address information of a critical host on the local network. When the DNS is not running, for example, the table is used during the initial system startup. Even if the local DNS server is running, there should be a small HOSTS file on each system, which contains a host itself, a localhost entry, and any major gateway and server items on the LAN.
• Small networks that are not connected to the Internet or other networks do not require DNS services. However, hosts on these networks also need to know how to locate other hosts on the same network.
/ ETC / NetWorks
Just like the host has a name and address, it can be naming for the network and subnets for convenience. The / etc / networks file is very similar to / etc / hosts on the layout, but the name and address are interchanged.
# / etc / networks for syroidmanor.com
LocalNet 127.0.0.0 #loopback
Syroid-c1 192.168.1 #development, Class C
Syroid-c2 192.168.2 #support, Class C
In the above example, the network name Syroid-C1 can be used in the script or any command line utility to reference 192.168.1 this C-network.
/ etc / sysconfig / network
Unlike the / etc / sysconfig / network (see the / etc / networks file, this network is singular instead of multiple) to specify the desired network configuration information; when booting, there are several scripts to use it. This file can contain one or more keywords / values shown in the following:
Networking = yes | no - yes means a network; NO means that you don't need to configure the network.
Hostname = hostname - The host's full-defined domain name; for compatibility with older programs, this should match the host item in / etc / hosts.
Gateway = GW-IP - IP address of the network gateway.
GatewayDev = GW-DEV - Name of the gateway device (for example, Eth0).
NisDomain = DOM-NAME - indicates the NIS domain, if any.
Here is an example of / etc / sysconfig / network minimum configuration:
Networking = yes
Hostname = phoenix.syroidmanor.com
Gateway = 192.168.1.1
/etc/resolv.conf and /etc/rc.d/rc3.d/s10Network
/etc/resolv.conf is one of the key files used to determine the host resolution. You can identify up to three name servers here; if the first bit of the server does not respond to the query, the next two functions. Domain item defines the default domain name. The parser (by way of inciting, the parser is not a separate process, but the routine library called by the network process) to attach the domain name listed here in any host query that does not contain the period. # /etc/resolv.conf
# Domain Name Resolver config file
Domain syroidmanor.com
Nameserver 192.168.1.7
Nameserver 192.168.1.10
Nameserver 165.142.268.19
In the example shown above, if the query submitted to the parser is to find the host phoenix (note, no points), then the domain is attached to this request, which will extend the query to Phoenix.Syroidmanor. COM. If you need more details and options that can be used, enter man resolv.conf.
/etc/rc.d/rc3.d/s10Network is a symbolic link to the /etc/rc.d/init.d/neetwork script. When the system reaches the run level 3, it is responsible for initializing all configured network interfaces. Here we don't want to spend time to discuss the logic behind this document, because the file is mainly called other scripts and programs mentioned in this section. However, if you are interested in the order of various network components and services in S10Network, you can use the LESS / Etc/rc.d/rc3.d/s10Network command to study it carefully.
/ etc / sysconfig / network-scripts / directory
Finally, you can usually find the following files in the / etc / sysconfig / network-scripts / directory:
· / Etc / sysconfig / network-scripts / iFUP
· / Etc / sysconfig / netWork-scripts / ifdown
· / Etc / sysconfig / network-scripts / network-functions
· / Etc / sysconfig / network-scripts / ifcfg-interface-name
· / Etc / sysconfig / network-scripts / ifcfg-interface-name: Clone-name
· / Etc / sysconfig / network-scripts / chat-interface-name
· / Etc / sysconfig / network-scripts / dip-interface-name
· / Etc / sysconfig / network-scripts / iFup-post
In the subsequent pages, we will briefly look at these key files to understand what they do and contain anything.
... / network-scripts /, the first part
The IFUP and IFDown items in / etc / sysconfig / network-scripts are actually pointing to the symbolic link to / sbin / ifup and / sbin / ifdown, respectively. These two scripts are the only scripts that should be called directly in this directory, and they call all other scripts as needed.
IFUP and IFDown typically bring only one parameter: device name (eg, Eth0). The system calls them with parameters "boot" during the boot process so that it is not activated that is not initialized in the system startup (see ONBOOT = No) in the interface-name description below).
Network-function is not a public file. It contains the functions required for several scripts in this directory. Specifically, it contains most of the code for processing alternative interface configuration. ... / network-scripts /, second part
Profile ifcfg-interface-name and ifcfg-interface-name: clone-name contains most of the details required to initialize the interface. The first file defines the interface, and the second file contains only partially definitions associated with the "alias" (or alternative) interface. For example, the network address may be different, but others may be the same.
The items defined in the IFCFG file depends on the interface type; the following value is very common:
· Device = name, where Name is a physical device name
· Ipaddr = addr, where addr is an IP address
· Netmask = Mask, where MASK is a network mask value
· NetWork = addr, where addr is the network address
· Broadcast = addr, where addr is a broadcast address
· Gateway = addr, where addr is the gateway address
ONBOOT = ANSWER, where Answer is "YES" (boot activation device) or "NO"
Userctl = answer, where Answer is "YES" (non-root user can control the device) or "NO"
· Bootproto = proto, where proto takes one of the lower values: "None" (not using protocol when boot) "bootp" (using Bootp protocol) or "DHCP" (using DHCP protocol)
In addition, the following values are common to all SLIP (serial line IP) files:
Persist = answer, where answer is "YES" (even if the modem has hang up, keeping the device in an activation state) or "no" (not maintained)
· ModeMport = Port, where port is the device name of the modem port (for example, / dev / modem)
· Linespeed = Baud, where BAUD is the line speed of the modem
· Defabort = answer, where Answer is "YES" (when you create / edit the script of the interface, insert the default exception termination string) or "no" (not inserted into the default exception termination string)
... / NetWork-Scripts /, Part III
The Chat-Interface-Name file is a chat script for the SLIP connection. Its function is to start the SLIP connection. For SLIP devices, the DIP script is written according to this script.
Chat-interface-name is only written script, which is created by the program Netcfg based on the conversation script. Don't modify the file.
When any network device (except SLIP device) is initialized, the / etc / sysconfig / network-scripts / ifup-post is called. It calls / etc / sysconfig / network-scripts / ifup-routes to initiate a static route that depends on the device, which also launches any alias configured for the device, and if there is no host name, set the host name - so Find the host name that matches the device IP address. Finally, IFUP-POST sends a signal (SIGIO) requesting to notify the network event. IFCONFIG program
Ifconfig command setting, check, or monitor the configuration value of the network interface. It can also be used to set "status" of the interface - "UP" or "Down". A simple call to ifconfig is:
Ifconfig interface-name ip-address up | DOWN
This activates the specified interface and assigns the supplied IP address to it.
IfConfig has many available options (Metric, MTU, and PointTopoint, etc.) The IP address and the network mask are sufficient. E.g:
Ifconfig eth0 192.168.1.5 Netmask 255.255.255.0 Up
The IP assigned to the interface ETH0 is 192.168.1.5, the network mask is 255.255.255.0 and "start the interface" or initialize it. Similarly, if you "off", type ifconfig eth0 down; do not need to specify the IP and network mask.
Check the interface using the IFCONFIG
IFConfig running without parameters will display the program to display all network interfaces. To check the status of a particular interface, the name of this interface is attached after IFConfig. E.g:
[Tom @ phoenix Tom] $ / sbin / ifconfig eth0
Eth0 Link ENCAP: Ethernet Hwaddr 00:10: 5A: 00: 87: 22
INET Addr: 192.1.20 Bcast: 192.168.1.255 mask: 255.255.255.0
Up Broadcast Running Multicast MUNTU: 1500 metric: 1
RX Packets: 9625272 Errors: 0 Dropped: 0 overruns: 0 frame: 0
TX Packets: 6997276 Errors: 0 Dropped: 0 overruns: 0 Carrier: 0
Collisions: 0 TXQuelelen: 100
Interrupt: 19 Base Address: 0xc800
The output display MAC address (HWADDR), allocated IP address (INET ADDR), Broadcast Address (BCAST), and Mask). It is also possible to see that the interface is in a UP state, its MTU is 1500 and Metric is 1. The next two lines give statistics on receiving (RX) and sent (TX) packets, and errors, discard, and overflow packets. The last two lines show the number of conflict packets, send queuelelelen and IRQ, and the base address of this card.
Configure routing
Let's take a look at how to configure routing by looking at the network interface that has not been configured. As you can see, use the Route command without parameters will display the kernel routing table. [root @ phoenix Tom] # / sbin / route
Kernel IP Routing Table
Destination Gateway Genmask Flags Metric Ref Use Iface
127.0.0.0 127.0.0.1 255.0.0.0 U 0 0 0 LO
192.168.1.0 192.168.1.5 255.255.255.0 U 0 0 0 Eth0
The first item is to the loop routing of localhost, which is automatically created when configuring LO. The second item is routed by interface ETH0 to network 192.168.1.0. Address 192.168.1.5 is not a remote gateway address. It is the address assigned to the Phoenix Eth0.
Pay attention to each item. They all set a U (start) flag, which means that they are ready to use, but they have not set the G (gateway) flag. The G mark is not set because the two routes are through the local interface, not direct routes of the external gateway.
The above example contains only one network route 192.168.1.0. Thus phoenix can only communicate with hosts located in the 192.168.1.0 network.
Add a static route
The smallest routing table only allows hosts to communicate with each other in the same network. To communicate with the remote host, the route to the external gateway must be added to the routing table. One way to achieve this is by using the / SBIN / ROUTE command. For examples in the page, we will now add routing 192.168.1.1 to the network configuration.
[root @ phoenix Tom] # / sbin / route add default 192.168.1.1 1
In this example, the first parameter after the route command is the keyword Add. The first keyword on the route command either add or Del (delete routing). The next value is the destination address, which is the address that the route arrives. If the keyword default is used for the destination address, the default route is created. Using the default route as long as there is no specific route from the destination; usually, this is the only item you need in the routing table. If there is only one gateway in the network, use the default routing to boot all data traffic to the remote network through that gateway.
The next parameter of this command line is the gateway address. This address must be the gateway address of the network where the unit is located. In the network path to the remote destination, the TCP / IP routing is to specify the next hop (NEXT-Hop). This next transaction must be that the unit can be directly accessed; thus, it must be in the network where the unit is located directly.
Note: Because most routes are added early in the system startup process, it is recommended to replace the host name with the number of IP addresses. Doing so ensures that the routing configuration does not depend on the status of the name server. Moreover, make sure you always use a complete digital address (a total of 4 bytes); if you don't have a complete IP address, the route can only guess some IP addresses, which may result in incorrect configuration.
Static route, continued
In the route command on the previous page, the last parameter is a number 1, called the routing metric. This metric parameter is not required when deleting the route, but many systems need it when adding a route. Although the metric is required, Route uses only it to determine whether the route is connected to the interface directly through the external gateway. If Metric is 0, this route created is through the native interface and does not set the G flag; if the metric value is larger than 0, the routing with the G flag and the gateway address is considered to be external. Static routing does not use other metric values. It is necessary to truly use multiple Metric values that dynamic routing. To display a new routing table, enter / sbin / route or use the netstat -rn command (we will discuss this command again):
[root @ phoenix Tom] # netstat -rn
Kernel IP Routing Table
Destination Gateway Genmask Flags MSS WINDOW IRTT IFACE
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 Eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 LO
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 Eth0
Finally, make a test to prove that everything is as follows, and ping the host on another network; you should receive a response. If you do not receive a response, you retrieve your configuration.
To be familiar with the other options and parameters of Route, enter Man Route.
NetStat program
If you manage any size TCP / IP network, the NetStat program is a fairly valuable tool. It can display the kernel routing table, the status of the active network connection, and some useful statistics for each installed network interface.
Like most Linux management command lines, NetStat can select the number of details and / or information of the displayed information through its additional options or flags. Some common options are:
-a - Show all connections, including those who are listening
-i - Show all statistics of all configured network devices
-c - Continuously update the network status (once every second) until it is aborted (^ c)
-r - display kernel routing table
-n - Display remote and local addresses in digital (original) format rather than resolved names
-T - only TCP socket information (excluding any UCP socket information)
-v - Display NetStat version information
Enter Man NetStat to get a complete list of all available flags and the purpose of each flag. Please note that these logos can also be combined, so entering netstat -rn will display system routing tables (R) on local and remote hosts (N) in the original IP address format.
Display the network connection
NetStat supports a set of options for displaying active or non-active sockets: -t, -u, -w and -x displays active TCP, UDP, RAW, and UNIX socket connections. If you add -a flag, you will also display (in other words, it is listening) socket. This will display all servers that are now running on the system.
For example: Enter netstat -ta on the host Phoenix will display the following: [Tom @ phoenix Tom] $ netstat -ta
Active Internet Connections (Servers and Established)
Proto Recv-q Send-Q Local Address Foreign Address State
TCP 0 40 Phoenix.Syroidmanor: ssh 192.168.1.5:1132 Establish
TCP 0 0 *: ssh *: * listen
TCP 0 0 Phoenix.Syroidman1028 Hydras.SyrNetBios-SSN Establish
TCP 0 0 Phoenix.Syroidman1027 RAIDSERVER: NetBIOS-SSN Establish
TCP 0 0 *: Printer *: * listen
TCP 0 0 *: auth *: * listen
TCP 0 0 *: 1024 *: * Listen
TCP 0 0 *: sunrpc *: * listen
The above output shows that most of the servers are only waiting for the connection (LISTEN). However, the first line shows the connection between the host Phoenix and IP addresses 192.168.1.5; the third and fourth lines displays two NetBIOS connections (Samba SMB sharing).
View routing table with NetStat
When using the -R flag, NetStat displays the routing table in the kernel, which is similar to input / sbin / route:
[Tom @ phoenix Tom] $ netstat -nr
Kernel IP Routing Table
Destination Gateway Genmask Flags MSS WINDOW IRTT IFACE
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 Eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 LO
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 Eth0
-n option Forced NetStat to point four sets of IP numbers in the form of an IP number, not the host and network name output address. This option is especially useful when you don't want to perform address queries over the network (eg, with DNS or NIS servers).
The second column displays the gateway points to the routing item. If there is no gateway, an asterisk will be displayed. The third column is the network mask of the route. The kernel performs the GenMask value with the IP address of the packet with the IP address of the packet with the IP address of the packet with the IP address of the packet, so that the route "universal".
The fourth column shows the sign of the route: u indicates the active state, H represents the host, g represents the gateway, and D represents the dynamic routing, and M indicates that has been modified.
View the routing table with NetStat, continue
[Tom @ phoenix Tom] $ netstat -nr
Kernel IP Routing TableDestination Gateway Genmask Flags MSS WINDOW IRTT IFACE
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 Eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 LO
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 Eth0
The next three columns displays MSS, Window, and IRTT, which will be applied to TCP connections created through the route. MSS (Maximum Segment Size) represents "maximum segment size" and is built by the kernel to pass through the datagram of the route. WINDOW indicates that the system receives burst of data from the remote host once.
The initial alphabet word IRTT represents "Initial Round Trip Tim". The TCP protocol ensures reliable transmission of data between hosts. If the data has been lost, it will be resent. The TCP protocol has been modified for the time spent on the data report sent to the remote endpoint and the received confirmation, in order to know the time to wait for the time you need to reuse the data report; this process is called round trip time. The TCP protocol will use the time used as the initial round trip time when the first establishment is established. For most types of networks, it is enough to use a default value, but for some speeds of speeds (especially some amateur packet wireless networks), this time is too short, which will cause unnecessary retransmission. You can use the route command to set the IRTT value. In this routing table, these fields are zero, which indicates that the default value is being used.
Finally, the final field represents the network interface used by the routed routes.
Show some network interface usage statistics with NetStat
Calling NetStat with -i option to display some useful statistics for all configured interfaces - this is a very useful tool for excluding network failures. With this command, it is easy to check the status of the connection and whether it is "normal".
[Tom @ phoenix Tom] $ netstat -i
KERNEL Interface Table
Eth0 Link ENCAP: Ethernet Hwaddr 00:10: 5A: 00: 87: 22
INET Addr: 192.1.20 Bcast: 192.168.1.255 mask: 255.255.255.0
Up Broadcast Running Multicast MUNTU: 1500 metric: 1
RX Packets: 10554374 Errors: 0 Dropped: 0 overruns: 0 frame: 0
TX Packets: 8528339 Errors: 0 Dropped: 0 overruns: 0 Carrier: 0
Collisions: 0 TXQuelelen: 100
Interrupt: 19 Base Address: 0xc800
Lo Link Encap: Local Loopback
INET Addr: 127.0.0.1 Mask: 255.0.0.0
Up loopback running mtu: 3924 metric: 1
Rx Packets: 5612 Errors: 0 Dropped: 0 overruns: 0 frame: 0
TX Packets: 5612 Errors: 0 Dropped: 0 overruns: 0 Carrier: 0
Collisions: 0 TXQuelelen: 0
The RX Packets and TX Packets rows show the received packets or the number of packets that have been sent and the error packet, lost packet, and overflowed RX / TX statistics. The most common interface errors are stem from incorrect configuration, so if you have encountered some difficulties, it is best to check all settings for diagnosis. If the interface has been started, there should be no packet queue to wait for the TXQueueler - if there is, it may be problematic due to the network cable or network card. First change your backlight and re-check the connection. The RX / TX error should be almost zero. If the TX error is too much, it means that the network has saturated or physically connected; if the RX error is too much, the network is already saturated, physical connection is problematic or host overload. If you encounter too high conflictivity (the conflict rate is the percentage of the output packet), not the result of the total number of send / receive packets, it may also also indicate that the network is saturated; through the same child Another host on the Internet executes netstat -i commands and compares this.
To resolve errors in the network, you must carefully and systematically analyze all aspects (hardware and software) of the interface, it is necessary. Don't hurry, ... ah ... we mentioned that you always check the network cable. At this point, I believe me.
Conclude
In this tutorial, we have discussed the history of TCP / IP, OSI model, and its relationship with TCP / IP design, IP addressing, subnet division and routing - all of which are elaborated from theoretical perspective. Then we started to study how to initialize the TCP / IP network in Red Hat 7.0, and what files under Red Hat are used. Next, we explore how to configure network interfaces and how to specify routing between local LAN and "external world". Finally, this tutorial explores the NetStat program and how to use the program to check if the network is normal.
Indeed, you need to draw a lot of knowledge, but TCP / IP is a big topic, there are hundreds of branches, one person is impossible to fully grasp it in two or three days. The fact is still: TCP / IP is the main network of the Internet, the route is "adhesive" that "sticks" together with the network, and the IP address represents the place where we have to visit when we "surf" in this world. When you think of this, and considering the past three, four years of people's computer sectors, especially the speed of the Internet, you will feel that these infrastructure is really well supported.
Online:
· Linux system administrator's guide
· Learn how Easily Configure TCP / IP ON Your Aix SYSTEM
· IBM provides some tools for network monitoring, such as Tivoli NetView Performance Monitor for TCP / IP
· Homepage to TCP / IP for OS / 40o
· Please read the TCP / IP and Internet Access to the implementation of ISERIES and AS / 400
· If you can search and refer to online online, I strongly recommend O'Reilly's new Safari subscription service. You can search and select some of the best books that have been published on the network.
The book published is:
· TCP / IP Network Administration, 2nd Edition, Craig Hunt (O'Reilly) ISBN: 1-56592-322-7
· Linux in a nutshell, 3rd Edition, Siever, Spainhour, Figgins, and Hekman (O'Reilly) ISBN: 0-596-00025-1 · Running Linux, 3rd Edition, Welsh, Dalheimer, And Kaufman (O'Reilly) ISBN 1-56592-469-x