


Linux與Linux之間的互拔
一.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如下:
# to initiate a ppp connection. This is the first part of the
# pair of s. This is not a secure pair of s 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 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 dont ask.)
#
DIALER_=/home/ppp/ppp-on-dialer
#
# Initiate the connection
#
# I put most of the common options on this command. Please, dont
# 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. Dont 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_ \
debug
現在配vms68拔到j128,文件ppp-onj128如下:
# to initiate a ppp connection. This is the first part of the
# pair of s. This is not a secure pair of s 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 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 dont ask.)
#
DIALER_=/home/ppp/ppp-on-dialer
#
# Initiate the connection
#
# I put most of the common options on this command. Please, dont
# 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. Dont 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_ \
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如下:
# to initiate a ppp connection. This is the first part of the
# pair of s. This is not a secure pair of s 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 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 dont ask.)
#
DIALER_=/home/ppp/ppp-on-dialer
#
# Initiate the connection
#
# I put most of the common options on this command. Please, dont
# 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. Dont 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_ \
debug
這里要注意LOCAL_IP和REMOTE_IP要給值,還有的是在pppd里沒有defaultroute。
因為vms68還要拔上Internet,所以不要defaultroute。還有這里沒有ACOUNT和
PASSWORD,因為WIN98的PPP CLIENT不要用戶名和密碼,因此在PPP-ON-DIALER里
要把送ACOUNT和PASSWORD的那兩行去掉。
J003通過拔號拔上VMS68后,要TELNET VMS68,在VMS68里執行以下腳本:
kill `cat /var/run/ppp0.pid` ###注意如果是用ppp1,就用ppp1.pid
nohup sleep 30;ppp-onj003
這里要特別注意的一點是一定要在linux里斷線,因為在WIN98里斷線,則WIN98
的PPP CLIENT就會退出,就不會應答呼叫。
現在WIN98和LINUX之間就可以實現回拔了,但要注意WIN98的路由問題。
在win98下要自配一下路由,在win98的目錄里有route程序,它的格式如下:
route print/add/delete/change (直接打route就有幫助看)
象我的j003,在沒有拔號時,用route print得到如下信息:(行號是我加上的)
Active Routes:
Network Address Netmask Gateway Address Interface Metric
1 0.0.0.0 0.0.0.0 192.168.88.128 192.168.88.3 1
2 127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
3 192.168.88.0 255.255.255.0 192.168.88.3 192.168.88.3 1
4 192.168.88.3 255.255.255.255 127.0.0.1 127.0.0.1 1
5 192.168.88.255 255.255.255.255 192.168.88.3 192.168.88.3 1
6 224.0.0.0 224.0.0.0 192.168.88.3 192.168.88.3 1
7 255.255.255.255 255.255.255.255 192.168.88.3 0.0.0.0 1
通過拔號網絡拔入vms68后,用route print得到如下信息:
Active Routes:
Network Address Netmask Gateway Address Interface Metric
1* 0.0.0.0 0.0.0.0 192.168.89.69 192.168.89.69 1
2* 0.0.0.0 0.0.0.0 192.168.88.128 192.168.88.3 2
3 127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
4 192.168.88.0 255.255.255.0 192.168.88.3 192.168.88.3 2
5 192.168.88.3 255.255.255.255 127.0.0.1 127.0.0.1 1
6 192.168.88.255 255.255.255.255 192.168.88.3 192.168.88.3 1
7 192.168.89.0 255.255.255.0 192.168.89.69 192.168.89.69 1
8 192.168.89.69 255.255.255.255 127.0.0.1 127.0.0.1 1
9 224.0.0.0 224.0.0.0 192.168.88.3 192.168.88.3 1
10 224.0.0.0 224.0.0.0 192.168.89.69 192.168.89.69 1
11 255.255.255.255 255.255.255.255 192.168.89.69 192.168.89.69 1
注意我打*號的地方,從WIN98拔號到LINUX,WIN98會自動配置路由,從LINUX拔號到WIN98?
?
WIN98就得手工配置路由,打*號的就是要在LINUX拔號到WIN98時要手工加上的。
現在TELNET上VMS68執行回拔腳本,連通后用route print得到如下信息:
Active Routes:
Network Address Netmask Gateway Address Interface Metric
1 0.0.0.0 0.0.0.0 192.168.88.128 192.168.88.3 1
2 127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
3 192.168.88.0 255.255.255.0 192.168.88.3 192.168.88.3 1
4 192.168.88.3 255.255.255.255 127.0.0.1 127.0.0.1 1
5 192.168.88.255 255.255.255.255 192.168.88.3 192.168.88.3 1
6 192.168.89.0 255.255.255.0 192.168.89.69 192.168.89.69 1
7 192.168.89.69 255.255.255.255 127.0.0.1 127.0.0.1 1
8 224.0.0.0 224.0.0.0 192.168.89.69 192.168.89.69 1
9 224.0.0.0 224.0.0.0 192.168.88.3 192.168.88.3 1
10 255.255.255.255 255.255.255.255 192.168.89.69 192.168.89.69 1
現在可看到跟上面的不同了,要在WIN98的DOS窗口下執行以下批處理:
route change 0.0.0.0 mask 0.0.0.0 192.168.88.128 metric 2
route add 0.0.0.0 mask 0.0.0.0 192.168.89.69
現在再用route print就會得到如下信息:
.
Active Routes:
Network Address Netmask Gateway Address Interface Metric
1 0.0.0.0 0.0.0.0 192.168.89.69 192.168.89.69 1
2 0.0.0.0 0.0.0.0 192.168.88.128 192.168.88.3 2
3 127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
4 192.168.88.0 255.255.255.0 192.168.88.3 192.168.88.3 1
5 192.168.88.3 255.255.255.255 127.0.0.1 127.0.0.1 1
6 192.168.88.255 255.255.255.255 192.168.88.3 192.168.88.3 1
7 192.168.89.0 255.255.255.0 192.168.89.69 192.168.89.69 1
8 192.168.89.69 255.255.255.255 127.0.0.1 127.0.0.1 1
9 224.0.0.0 224.0.0.0 192.168.88.3 192.168.88.3 1
10 224.0.0.0 224.0.0.0 192.168.89.69 192.168.89.69 1
11 255.255.255.255 255.255.255.255 192.168.89.69 192.168.89.69 1
現在可TELNET上VMS68,在VMS68上拔號到INTERNET,現在J003可通過VMS68上網了。
一些不足的地方:
一.要手工的地方太多,不大方便,請朋友們再改良一下。
二.只能用兩個串口,我沒有玩過多用戶卡,請有經驗的朋友指點一下在LINUX下用那種多用戶卡最好,在那有賣,多少錢
關鍵字:拔號、服務器、IP
新文章:
- CentOS7下圖形配置網絡的方法
- CentOS 7如何添加刪除用戶
- 如何解決centos7雙系統后丟失windows啟動項
- CentOS單網卡如何批量添加不同IP段
- CentOS下iconv命令的介紹
- Centos7 SSH密鑰登陸及密碼密鑰雙重驗證詳解
- CentOS 7.1添加刪除用戶的方法
- CentOS查找/掃描局域網打印機IP講解
- CentOS7使用hostapd實現無AP模式的詳解
- su命令不能切換root的解決方法
- 解決VMware下CentOS7網絡重啟出錯
- 解決Centos7雙系統后丟失windows啟動項
- CentOS下如何避免文件覆蓋
- CentOS7和CentOS6系統有什么不同呢
- Centos 6.6默認iptable規則詳解