Linux Network Administrator Manual (7)

Source: Internet
Author: User
Article title: Linux Network Administrator Manual (7 ). Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Chapter 7 serial line IP
The serial line protocol SLIP and PPP provide Internet connections for those who lack funds. In addition to a modem and a FI
In addition to the serial board (card) of the FO buffer, other hardware is no longer needed. Using it is not more complex than using a mailbox, and
Growing private organizations provide dial-up IP addresses at acceptable prices.
Linux has two drivers: SLIP and PPP. SLIP already exists for a long time, and it works very stably. PPP-driven
The program was recently developed by Michael Callahan and Al Longyear. PPP will be discussed in the next chapter.
7.1 General requirements
To use SLIP or PPP, you must configure some basic network features as discussed in the previous chapter. At least, you must set
Loopback interface, and provide name resolution. When you connect to the Internet, you certainly need to use DNS.
The most convenient method is to write the address of a name server to the resolv. conf file. Once the SLIP link is activated
Query the server. The closer the name server is to the place you dial in, the better.
However, this method is not optimal, because all name searches still need to be linked through your SLIP/PPP. If
You are worried about the bandwidth consumed by doing so. you can also set a server with only a buffer (caching-only) name. And
It does not really serve a domain, but serves as a relay for all DNS queries generated by your host. Advantages of this solution
The point is that it creates a buffer, and most queries only need to be sent once on a serial line. One buffer server
The named. boot File looks like this:
; Named. boot file for caching-only server
Directory/var/named
Primary 0.0.127.in-addr. arpa db.127.0.0; loopback net
Cache. db. cache; root servers
In addition to the name. boot file, you also need to set the db. cache file, which contains
List. These are discussed at the end of the parser configuration chapter.
7.2 SLIP operation
The dial-up (internet access) IP server usually uses a special user account to provide the SLIP service. After logging in to such an account
Instead of entering a common shell program, you execute a program or shell script to activate the server SL of the serial line.
IP driver and configure appropriate network interfaces. Then you need to do the same work on your link.
In some operating systems, the SLIP driver is a user space program; in Linux, it is part of the kernel, which makes
It is faster. However, this requires the explicit conversion of the serial line into the SLIP mode. This is a special tty line procedure
SLIPDISC. When tty is a general line procedure (DISCO), it uses the common read (2) and wri
Te (2) calls only exchange data with user processes, while the SLIP driver cannot read or write data from tty. In SLIPDISC
In practice, the rule is the opposite: now any user space process is blocked from reading and writing from tty.
All data from the interface will be directly transmitted to the SLIP driver.
The SLIP driver itself can identify multiple changes to the SLIP protocol. In addition to the ordinary SLIP, it can also understand CSLIP, which
The output IP package is compressed with the so-called Van Jacson header. [1] This significantly improves the throughput of interactive sessions.
In addition, each of these protocols has a six-bit version.
One simple way to convert a serial line to the SLIP mode is by using the slattach tool. Assume that your modem is connected/
Dev/cua3 and successfully log on to the SLIP server. Then execute:
# Slattach/dev/cua3 &
This converts cua3 line rules into SLIPDISC and connects it to one of the SLIP network interfaces. If this is your first
The line will be connected to sl0, the second will be connected to sl1, and so on. Currently, the kernel supports both
Up to eight SLIP links.
The default compression encapsulation selected by Slattach is CSLIP. You can use the-p switch to select any other mode. To enable
Use the regular SLIP (uncompressed), which can be used
# Slattach-p slip/dev/cua3 &
Other models include cslip, slip6, cslip6 (six-bit version of SLIP), and adaptive SLIP (adaptive S ).
LIP. The latter allows the kernel to identify the SLIP compression encapsulation type used by the remote end.
Note that you must use the same compression encapsulation as your peer. For example, if cowslip uses CSLIP, you must
Use it. If the selection does not match, ping to the remote host will not receive any response packets.
If other hosts ping you, the following error occurs on your console: "You cannot create an ICMP header ."
Uild ICMP header. One way to avoid these problems is to use adaptive SLIP.
In fact, slattach not only allows you to enable SLIP, but also activates other protocols of the serial line, such as PPP or
KISS (another protocol used by radio enthusiasts ). For more information, see the slattach (8) reconnection manual.
After transferring the line to the SLIP driver, you must configure this network interface. Again, we use the standard ifco
The nfig and route commands are used for this configuration. Assume that from vlager, we dial a server named cowslip. That
You want to execute
# Ifconfig sl0 vlager pointopoint cowslip
# Route add cowslip
# Route add default gw cowslip
The first command configures the interface to the point-to-point link of cowslip, while the second and third commands add the path of cowslip.
Use and use cowslip as a default gateway.
When disassembling a SLIP link, you must first use the route command with the del option to remove all routes through cowslip.
, Disable the interface, and send an hangup signal to slattch. Then, you must use your terminal program again to hang up
Modem:
# Route del default
# Route del cowslip
# Ifconfig sl0 down
# Kill-HUP 516
7.3 dip
Now, the above is very simple. However, you may want to make the preceding steps automatically executed so that you can
You can call only one simple command to execute all the steps described above. This is what dip has to do. [2] Writing
The current release version of this manual is 3.3.7. It has been modified by many people, so it is no longer the original
Dip program. These different development changes may be merged in future versions.
Dip provides an interpreter for a simple scripting language, which can process the modem for you, convert the line to the SLIP mode, and
Configuration interface. This is very basic and limited, but it is sufficient for most cases. A new
The dip version will be available in a wider range of languages.
To configure the SLIP interface, dip requires the root permission. Now we can temporarily use dip to set uid to root, so all
Users can dial to a SLIP server without having to grant root permissions to these users. This is very dangerous because dip is used to set
Fake interfaces and default routes may seriously damage the network routing. Worse, it will connect your users to any
He SLIP server's capabilities and brings dangerous attacks on your network. So if you want to allow your users to create
Each SLIP connection writes a small package for each desired SLIP server and allows these packages to call the package.
Including the dip of the specific script used to establish the connection. Then, these programs can be securely set to the root uid. [3]
7.3.1 a simple script program
. 1 lists a simple script program. Dip is called by using the name of the script program as a parameter, which can be used to connect
Cowslip:
# Dip cowslip. dip
DIP: Dialup IP Protocol Driver version 3.3.7 (12/13/93)
Written by Fred N. van Kempen, MicroWalt Corporation.
Connected to cowslip.moo.com with addr 193.174.7.129
#
When SLIP is activated and connected to cowslip, dip will be removed from the terminal and run on the background. Now you can
The common network service is used for IP connection. To terminate a connection, you only need to use the-k option to call dip. This uses/etc/dip.
The process id dip recorded in pid [4] sends a hanging signal to the dip process:
# Kill? K
In the script language of dip, the keyword with the prior dollar sign represents the variable name. Dip has a predefined variable set, which will
It is listed below. For example, $ remote and $ local contain the host names of local and remote hosts related to the SLIP connection.
# Sample dip script for dialing up cowslip
# Set local and remote name and address
Get $ local vlager
Get $ remote cowslip
Port cua3 # choose a serial port
Speed38400 # set speed to max
Modem HAYES # set modem type
Reset # reset modem and tty
Flush # flush out modem response
# Prepare for dialing.
Send ATQ0V1E1X1 \ r
Wait OK 2
If $ errlvl! = 0 goto error
Dial 1, 41988
If $ errlvl! = 0 goto error
Wait CONNECT 60
If $ errlvl! = 0 goto error
# Okay, we "re connected now
Sleep 3
Send \ r \ n
Wait ogin: 10
If $ errlvl! = 0 goto error
Send Svlager \ n
Wait ssword: 5
If $ errlvl! = 0 goto error
Send hey-jude \ n
Wait running 30
If $ errlvl! = 0 goto error
# We have logged in, and the remote side is firing up SLIP.
Print Connected to $ remote with address $ rmtip
Default # Make this link our default route
Mode SLIP # We go to SLIP mode, too
# Fall through in case of error
Error:
Print SLIP to $ remote failed.
. 1 a dip script sample
The first two sentences in the sample script program are the get command, which is the method for setting variables in dip. Here, the local and remote host names are divided
Do not set vlager and cowslip.
The following five sentences are used to set the terminal line and modem. The Reset sends a Reset string to the modem. it is compatible with Hayes.
It is an ATZ command. The next statement clears the modem response so that the login sessions in the following lines
Can work normally. This conversation is very intuitive: it simply dials out the cowslip number 41988 and uses the port
Log on to the Svlager account with hey-jude.

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.