Linux與Linux之間的互拔
2024-07-21 02:37:41
供稿:網友
一.linux與Linux之間的互拔:
請看圖一:
我家里: 辦公室:
機器名:j128 機器名:vms68
OS: RedHat5.1 OS: RedHat5.1
ip: 192.168.88.128 <----電話網----> IP: 192.168.89.68 <--->
Internet
[ttyS0] [ttyS1] [ttyS0]
網線
機器名:j003
OS: Win98
IP: 192.168.88.3
第一步要配置Linux為ppp服務器,答應拔入,如姚飛所說:
使用mgetty
(以下假設modem裝在ttyS0)
cd /etc
vi inittab
add :
d1:2345:respawn:/sbin/mgetty ttyS0 # COM1口答應拔入
d2:2345:respawn:/sbin/mgetty ttyS1 # COM2口答應拔入
then: init q # 重讀配置文件/etc/inittab
注重, 假如想拔號出去, pppd 使用的設備也必須是/dev/ttyS0或/dev/ttyS1,
而不是/dev/modem, 要不然是撥不出去的.
我這樣做后,j128和vms68都可答應拔入,但還不是ppp server,還需要以下幾步:
在vms68里:
adduser ppp #新加一個用戶
passwd ppp #為ppp起個密碼
在/home/ppp下建一個腳本ppplogin,內容如下:
exec /usr/sbin/pppd 115200 modem asyncmap 0 PRoxyarp
192.168.89.68:192.193.89.69
##### LOCALIP:REMOTEIP
vi /etc/passwd
將這行ppp:xxxx:505:505:ppp acount:/home/ppp:/bin/bash
改為ppp:xxxx:505:505:ppp acount:/home/ppp:/home/ppp/ppplogin
在j128里:
adduser ppp #新加一個用戶
passwd ppp #為ppp起個密碼
在/home/ppp下建一個腳本ppplogin,內容如下:
exec /usr/sbin/pppd 115200 modem asyncmap 0 proxyarp
0.0.0.0:0.0.0.0.0 ###等vms68分配ip地址
vi /etc/passwd
將這行ppp:xxxx:505:505:ppp acount:/home/ppp:/bin/bash
改為ppp:xxxx:505:505:ppp acount:/home/ppp:/home/ppp/ppplogin
下一步要配j128拔到vms68,這很簡單,
跟拔到Internet是一樣的,文件ppp-onvms68如下:
# Script to initiate a ppp connection. This is the first part of the
# pair of scripts. This is not a secure pair of scripts as the codes
# are visible with the 'ps' command. However, it is simple.
#
# These are the parameters. Change as needed.
TELEPHONE=xxxx # The telephone number for the connection
ACCOUNT=ppp # The account name for logon (as in 'George Burns')
PASSWord=xxxx # The password for this account (and 'Gracie Allen')
LOCAL_IP=0.0.0.0 # Local IP address if known. Dynamic = 0.0.0.0
REMOTE_IP=0.0.0.0 # Remote IP address if desired. Normally 0.0.0.0
NETMASK=255.255.255.0 # The proper netmask if needed
#
# EXPort them so that they will be available at 'ppp-on-dialer' time.
export TELEPHONE ACCOUNT PASSWORD
#
# This is the location of the script which dials the phone and logs
# in. Please use the absolute file name as the $PATH variable is not
# used on the connect option. (To do so on a 'root' account would be
# a security hole so don't ask.)
#
DIALER_SCRIPT=/home/ppp/ppp-on-dialer
#
# Initiate the connection
#
# I put most of the common options on this command. Please, don't
# forget the 'lock' option or some programs sUCh as mgetty will not
# work. The asyncmap and escape will permit the PPP link to work with
# a telnet or rlogin connection. You are welcome to make any changes
# as desired. Don't use the 'defaultroute' option if you currently
# have a default route to an ethernet gateway.
#
exec /usr/sbin/pppd /dev/ttyS0 115200 modem $LOCAL_IP:$REMOTE_IP
defaultroute lock crtscts asyncmap 0 connect $DIALER_SCRIPT
debug
現在配vms68拔到j128,文件ppp-onj128如下:
# Script to initiate a ppp connection. This is the first part of the
# pair of scripts. This is not a secure pair of scripts as the codes
# are visible with the 'ps' command. However, it is simple.
#
# These are the parameters. Change as needed.
TELEPHONE=xxxx # The telephone number for the connection
ACCOUNT=ppp # The account name for logon (as in 'George Burns')
PASSWORD=xxxx # The password for this account (and 'Gracie Allen')
LOCAL_IP=192.168.89.68 # Local IP address if known. Dynamic = 0.0.0.0
REMOTE_IP=192.168.89.69 # Remote IP address if desired. Normally 0.0.0.0
NETMASK=255.255.255.0 # The proper netmask if needed
#
# Export them so that they will be available at 'ppp-on-dialer' time.
export TELEPHONE ACCOUNT PASSWORD
#
# This is the location of the script which dials the phone and logs
# in. Please use the absolute file name as the $PATH variable is not
# used on the connect option. (To do so on a 'root' account would be
# a security hole so don't ask.)
#
DIALER_SCRIPT=/home/ppp/ppp-on-dialer
#
# Initiate the connection
#
# I put most of the common options on this command. Please, don't
# forget the 'lock' option or some programs such as mgetty will not
# work. The asyncmap and escape will permit the PPP link to work with
# a telnet or rlogin connection. You are welcome to make any changes
# as desired. Don't use the 'defaultroute' option if you currently
# have a default route to an ethernet gateway.
#
exec /usr/sbin/pppd /dev/ttyS1 115200 modem $LOCAL_IP:$REMOTE_IP
lock crtscts asyncmap 0 connect $DIALER_SCRIPT
debug
這里要注重LOCAL_IP和REMOTE_IP要給值,還有的是在pppd里沒有defaultroute。
因為vms68還要拔上Internet,所以不要defaultroute。
在j128上用ppp-onvms68拔上vms68,連通后telnet vms68,執行以下命令:
nohup sleep 30;ppp-onj128
然后在j128上斷線,等待vms68拔入。拔通后,在j128上要執行以下命令:
route add -net 192.168.89.0 gw 192.168.89.69 ppp0
route add default gw 192.168.89.69 ppp0
ipfwadm -F -a m -S 192.168.88.0/24 -D 0.0.0.0/0
現在可再telnet vms68,在vms68上拔號上網,這樣j003可通過j128,再通
過vms68上網,我也不用付任何費用。
二.Win98與Linux之間的互拔:
請看圖二:
我家里: 辦公室:
機器名:j128 機器名:vms68
OS: RedHat5.1 OS: RedHat5.1
IP: 192.168.88.128 IP: 192.168.89.68 <--->
Internet
[ttyS1] [ttyS0]
網線
機器名:j003
OS: Win98 ---------------------------
IP: 192.168.88.3 電話網
這里vms68要象第一步所說的,要配成答應拔入的ppp server。
這里主要是win98的配置,首先象上Internet那樣,在拔號網絡里新建一個連接,
要注重兩點,一要設置連通后彈出終端窗口,二是最主要的,在“控制面板”里
選“調制解調器”,選用來連線的modem,選“屬性”按鈕,選“連接”,再選
“高級”按鈕,再在“附加設置”里輸入&C0S0=001。
為什么要這樣做?因為win98自帶的ppp client會自動退出當遠端ppp server掛線
時,因此要騙一騙win98,要modem不要報告斷線,并自動應答拔入。&C0就是要
modem不要檢測carrier,s0=001要modem在響一下后就應答。
現在配vms68拔到j003,文件ppp-onj003如下:
# Script to initiate a ppp connection. This is the first part of the
# pair of scripts. This is not a secure pair of scripts as the codes
# are visible with the 'ps' command. However, it is simple.
#
# These are the parameters. Change as needed.
TELEPHONE=xxxx # The telephone number for the connection
#ACCOUNT=ppp # The account name for logon (as in 'George Burns')
#PASSWORD=xxxx # The password for this account (and 'Gracie Allen')
LOCAL_IP=192.168.89.68 # Local IP address if known. Dynamic = 0.0.0.0