Article title: a practical technology: PPP connection in Linux. 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.
In the home network and "Home Office" families, PPP connection is a very practical technology. This article will explain in detail how to dial out and dial in the Linux LAN server, that is, how to make the Linux server a PPP client and server, and how to set up the callback service.
How to dial up internet access in Linux
Set PPP on a Linux server so that it can dial and connect to the ISP to connect the computer to the Internet. The following describes how to configure the Linux PPP client.
1. Compile the kernel to support PPP
In most cases, you do not need to recompile the kernel. If you cannot confirm whether or not Linux needs to be compiled, check the instructions and check whether the kernel supports PPP.
2. set the serial port and modem
(1) serial device files
In Linux, the relationship between the names of serial port device files and DOS is as follows:
DOC COM1 = Linux/dev/cua0 (and/dev/ttyS0)
DOC COM2 = Linux/dev/cua1 (and/dev/ttyS1)
In general,/dev/cua * is used for dial-out, and/dev/ttyS * is used for dial-in. However, you can skip this step and use/dev/ttyS *. If there is no/dev/ttyS * on the computer, you need to use mknod to create these device files. There is a script program MAKEDEV to simplify this work:
# Cd/dev
#./MAKEDEV ttyS0
(2) set the interrupt number and I/O address
Run the following command to set the interrupt number:
/Sbin/setserial/dev/ttyS0 ieq 3 # serial mouse
/Sbin/setserial/dev/ttyS1 ieq 4 # MODEM1
Run the following command to view the interruption settings of the system to ensure that there is no interruption conflict:
Cat/proc/interrupts
The I/O address must be the same as the interrupt address. you can set a hardware jumper to change the I/O address. Generally, the I/O address of a serial port is as follows:
TtyS0 address 0x3f8
You can run the following command to view the system's I/O address settings to ensure that no conflict exists:
Cat/proc/ioports
(3) set the modem
Generally, the factory settings of the modem do not need to be changed.
3. understand ISP Information
You need to know some basic ISP information, especially the DNS address, and set your own DNS. For Linux, it cannot dynamically specify the dns ip address when connecting lines.
4. install software required for dialing
The programs required by PPP customers include chat and pppd. There is also a terminal communication program, minicom, which is used to test dial-up. it must also be installed.
The purpose of the chat program is to dial and wait for a prompt. enter the user name, password, and other logon information as prompted. Pppd is used to establish and maintain PPP connections with servers and transmit data.
5. establish a ppp connection manually
The entire ppp connection can be divided into two steps:
(1) use pppd to establish a ppp connection
Test whether the dial-up is successful. exit and run the pppd program as follows:
Run the following code on a separate virtual console:
Tail-f/var/log/messages
Dynamically observe various log information, including the debugging information of pppd. If the following information is displayed, the PPP connection is successful:
Jun23 16: 10: 31hxf pppd [1234]: local IP address210.88.131.151
Jun23 16: 10: 31hxf pppd [1234]: remote IP address192.168.10.21
(2) disconnect
After the test is passed, you need to disconnect the connection and use the following command:
Killall pppd
6. automate PPP connections
After the manual connection test, you need to turn this into automatic, in order to achieve dial-up connections with only one command.
To automate dialing, two programs are required: chat and pppd. For the effect of automatic dialing, you can view the relevant information.
7. set domain name resolution (DNS)
In Linux, setting domain name resolution is not convenient, and the domain name server needs to be set by itself.
(1) set the domain name server
The/ect/resolv. conf file stores the domain name server address, and its content is as follows:
Domain your. isp. domain. name
Nameserver202.106.196.152
Nameserver202.106.196.115
You need to fill in the ISP domain name server address in this file.
(2) Automation
You may only need to add the domain name server address when dialing. this is not required for other times. Therefore, you can also automate this process in addition to manual configuration. You can create two script files for execution in/etc/ppp/ip-up.local and/etc/ppp/ip-down.local. After pppd is started, the command in/etc/ppp/ip-up.local is executed; when pppd ends, the command in/etc/ppp/ip-down.local is executed. You can make a file that contains the domain name server, change it to/etc/resolv. conf in the ip-up.local, and save/etc/resolv. conf. Restore the saved/etc/resolv. conf in the ip-down.local. In this way, you can automatically add domain name servers.
Set the dial-in server in the Lan
The purpose of configuring the dial-in server in the Lan is to set the Linux Lan to the same dial-up server as the ISP. Assume that you have set up a dial-up server in Linux, and then connect to the company's dial-up server at home to access the company's LAN. in this way, you can achieve "home office ". If your company's servers are connected to the Internet, you can browse the Internet. "Setting basic dial-up servers" will tell you how to implement this function. "Callback" describes how to save the telephone fee required for networking.
This section describes how to use a Linux server as a PPP client.
1. set basic dial-up servers
If the PPP service is installed, change FORWARD_IPV4 = false in the/etc/sysconfig/network file to true. Then restart to activate IP forwarding.
(1) enable Liunx to receive incoming calls
What we need to do now is to make the serial port connected by the Modem accept external connections. Open the/etc/inittab and you will see the following lines of code:
# Run gettys in standard runlevels
1: 2345: respawn:/sbin/mingetty tty1
2: 2345: respawn:/sbin/mingetty tty2
After these lines, add the following line of code:
3: 2345: respawn:/sbin/mgetty ttyS1
It means to listen to Mgetty's serial port ttyS1 and wait for the connection. if there is a connection request, Mgetty will prompt the user to enter the user name and password.
After modification, you can run the following code to make the modification valid:
Init q
To log on from the remote end, you also need an account. use the useradd command to add a user named ppp and use the passwd command to set a password for the user.
(2) start pppd to establish a PPP connection with the customer
Open the/etc/passwd file and find the line of the user's ppp, which should be like this:
Ppp: x: 500: 500:/home/ppp:/bin/bash
From this we can see that the shell program used by ppp is bash. now we need to replace this bash with pppd. In this way, pppd is executed instead of bash when you log on with ppp. In this way, pppd is started on the server.
You can create a ppplogin file in/etc/ppp as follows:
Use ppplogin to replace the user's ppp login shell, as shown in the following code:
Ppp: x: 500: 500:/home/ppp:/etc/ppp/ppplogin
Since pppd must be run with the root permission, you must set pppd to run with the root permission:
Chmod u + s/usr/sbin/pppd
If you have replaced the logon shell and modified the pppd attributes, try again. As described above, the server-side pppd is enabled after you enter the user name and password. Click "continue", that is, start the pppd of the client and shake hands with the pppd of the server. After a while, you will see a successful login to the network, marked as a familiar green computer.
(3) Special settings for Windows 98 customers
Windows 98 requires the domain name server to pass it over when it is connected. Pppd has a parameter ms-dns, which is used to transmit DNS to the customer. Add this parameter to ppplogin, for example:
Among the two DNS, the first DNS is the primary DNS, and the second DNS is the secondary DNS.
2. Callback)
Callback means that when a user connects to a dial-up server, the server disconnects the connection and then calls it back to the user. The user's Modem receives the call to establish a dial-up connection. In this way, "Home Office" is created with favorable conditions and can be connected to the company for work at home by means of callback.
(1) server side settings
Before setting, make sure that the Callback program of Mgetty is installed. Add the following line to/etc/mgetty + sendfax/login. config:
The preceding call-hxf refers to adding a user portal named call_hxf to Mgetty. This user is only Mgetty used to start the Callback program, rather than Linux users. do not use useradd to add a call_hxf user. this call_hxf user name is only used by Mgetty, not the system. When a user connects to Linux through Modem, Mgetty prompts the user name to be input. if call_hxf is entered, Mgetty calls the/usr/sbin/callback program to process the callback. Parameter-B refers to/var/log/mgetty. ttyS1 leaves debugging information;-1 ttyS1 indicates that ttyS1 is used as the outbound device;-s 115200 indicates the serial speed;-S 62345678 indicates the specified callback phone number. If no-S
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