欢迎光临
我们一直在努力

Linux与Linux之间的互拔-网管专栏,防火墙和路由

建站超值云服务器,限时71元/月

一.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 dont ask.)
#
dialer_script=/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_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 dont ask.)
#
dialer_script=/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_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
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 dont ask.)
#
dialer_script=/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_script \
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下用那种多用户卡最好,在那有卖,多少钱

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » Linux与Linux之间的互拔-网管专栏,防火墙和路由
分享到: 更多 (0)