How to use Linux to establish a dial-up server

  

First, the goal of this document is to use Redhat Linux to establish a dial-up server.

Second, test environment software: 1, Redhat Linux AS5 is fully installed. Hardware: 1, 56K Modem. Note that the soft cat (win-modem) cannot be used under Linux

Third, after the server is set up to connect the modem to the server, the modem is powered on. The programs to be used on Linux are mgetty and pppd. 1. Use minicom to test Modem to connect to the server. Run: minicom -s appears the following interface: Filenames and pathsFile transfer protocolsSerial port setupModem and dialingScreen and keyboardSave setup as dflSave setup as..ExitExit from Minicom in the choices that appear: Serial port setup

The following interface appears: A - Serial Device : /dev/ttyS0B - Lockfile Location : /var/lockC - Callin Program :D - Callout Program :E - Bps/Par/Bits : 57600 8N1F - Hardware Flow Control : YesG - Software Flow Control : No

Change which setting? Generally only need to modify A and E. After the modification, press Enter to return. Select Exit and press Enter. If the settings are correct, you will see the AT and OK characters as follows: AT S7=45 S0=0 L1 V1 X4 &c1 E1 Q0OK

Press Ctrl-A Z X to exit minicom.

2, set the mgetty to run automatically: Run the following command: echo "S0:2345:respawn:/sbin/mgetty ttyS0" >> /etc/inittab

Note the ttyS0 For the serial port connected to the modem, please modify it as needed.

3, make mgetty automatically run pppd: Run the following command: echo "/AutoPPP/- a_ppp /usr/sbin/pppd file /etc/ppp/options" >> /etc/mgetty+sendfax /mgetty.config

Remove the line for the line 'AutoPPP' in the /etc/mgetty+sendfax/login.config file: /AutoPPP/- a_ppp /usr/sbin/pppd auth -chap +pap login debug

4. Modify the pppd run parameters: Run the following command: echo "-chap +pap login debug modem crtscts proxyarp lock lcp-max-terminate 30 lcp-max-failure 30 lcp-echo-interval 5 passive" > /etc/ppp/options

4, IP allocation: Run the following command: echo "192.168.1.3:192.168.1.201" > /etc/ppp/options.ttyS0 echo "noauth" >> /etc/ppp/options.ttyS0

5, set pppd to use system user authentication login: echo "* * "" *" /etc/ppp/pap-secrets

6, create new users and groups, and set the password: run the following command: groupadd -g 1001 pppadduser thinkerpasswd thinker

7, modify the user shell: edit /etc/passwd file, thinker The user line is changed to the following content: thinker:x:1001:1001:,,,:/home/thinker:/usr/sbin/ppplogin specifies that the thinker shell is /usr/sbin/ppplogin

8, new The /usr/sbin/ppplogin file has the following contents: #!/bin/shexec /usr/sbin/pppd debug passive asyncmap 0 proxyarp lock modem crtscts lcp-max-terminate 30 lcp-max-failure 30 lcp-echo-interval 5< Br>

Modify the ppplogin owner for use by other users and use it or execute: chown root.ppp /usr/sbin/ppploginchmod +x /usr/sbin/ppplogin

9, make non-root users You can run the pppd program: Run the following command: chmod +s /usr/sbin/pppd

10, make init run mgetty: run the following command: init q

11, enable packet forwarding and iptables The NAT function allows the client to access the target network: edit the /etc/sysctl.sys file and change "net.ipv4.ip_forward = 0" to "net.ipv4.ip_forward = 1"Run: sysctl -p

Enable iptables NAT function, run: iptables -F iptables -Xiptables -F -t natiptables -t nat -A POSTROUTING -o eth0 -j SNAT --to 192.16.11.107 iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

Description: eth0 is the network port of the dial-up server connection directory network, and 192.16.11.107 is the IP address of eth0. Please modify as needed. Add the above lines to the /etc/rc.local file to make the machine run automatically when it starts.

3. After testing the client, you can view the /var/log/message, /var/log/secure, and /var/log/mgetty.log.ttyS0 log files.

Content of the /var/log/message file when dialing normally: Mar 7 15:37:20 web2 pppd[7195]: pppd 2.4.4 started by a_ppp, uid 0Mar 7 15:37:20 web2 pppd [7195]: Using interface ppp0Mar 7 15:37:20 web2 pppd[7195]: Connect: ppp0 <--> /dev/ttyS0Mar 7 15:37:23 web2 pppd[7195]: user thinker logged inMar 7 15 :37:23 web2 pppd[7195]: PAP peer authentication succeeded for thinkerMar 7 15:37:24 web2 pppd[7195]: Cannot determine ethernet address for proxy ARPMar 7 15:37:24 web2 pppd[7195]: local IP address 192.168.1.3Mar 7 15:37:24 web2 pppd[7195]: remote IP address 192.168.1.201Mar 7 15:37:28 web2 pppd[7195]: LCP terminated by peer (^WM-H^CM-Z^@ <M-Mt^@^@^@^@)Mar 7 15:37:28 web2 pppd[7195]: Connect time 0.1 minutes.Mar 7 15:37:28 web2 pppd[7195]: Sent 33 bytes, received 1828 bytes.Mar 7 15:37:31 web2 pppd[7195]: Connection terminated.Mar 7 15:37:31 web2 pppd[7195]: Modem hangupMar 7 15:37:31 web2 pppd[7195]: Exit.

Content of the mgetty.log.ttyS0 file when dialing normally: 03/04 13:25:51 yS0 mgetty: Interim release 1.1.33-Apr1003/04 13:25:51 yS0 check for lockfiles03/04 13:25:51 yS0 locking the line03/04 13:25:52 yS0 lowering DTR to reset Modem03/04 13:25:52 yS0 Send: \\dATQ0V1H0[0d]03/04 13:25:53 yS0 waiting for ``OK'' ** found **03/04 13:25:53 yS0 send: ATS0=0Q0&D3&C1[0d]03 /04 13:25:53 yS0 waiting for ``OK'' ** found **03/04 13:25:53 yS0 mdm_send: 'ATI'03/04 13:25:53 yS0 non-numeric ID string: ' TP560 Data/Fax/Voice 56K Modem'03/04 13:25:53 yS0 mdm_send: 'AT+FCLASS=2.0' -> ERROR03/04 13:25:53 yS0 mdm_send: 'AT+FCLASS=2' -> ; ERROR03/04 13:25:54 yS0 waiting...03/04 13:26:20 yS0 wfr: waiting for ``RING''03/04 13:26:20 yS0 send: ATA[0d]03/04 13:26:20 yS0 waiting for ``CONNECT'' ** found **03/04 13:26:34 yS0 send: 03/04 13:26:34 yS0 waiting for ``_'' ** found ** 03/04 13:26:37 ##### data dev=ttyS0, pid=29338, caller='none', conn='28800/V44', name='', cmd='/bin/login', User='/AutoPPP/'

Normal dialing into the /var/log/secure file: Mar 4 14:27:38 web2 login: pam_unix (login:session): session opened for user thinker by LOGIN(uid=0)Mar 4 14:27:38 web2 login: DIALUP AT ttyS0 BY thinkerMar 4 14:27:38 web2 login: LOGIN ON ttyS0 BY thinker--- -------------------------------------------------- ---------

The above experiments have been tested and can be used normally

Copyright © Windows knowledge All Rights Reserved