请教下关于ssh组网的问题

Web、Mail、Ftp、DNS、Proxy、VPN、Samba、LDAP 等基础网络服务
回复
quhan
帖子: 3
注册时间: 2018-03-02 3:02

请教下关于ssh组网的问题

#1

帖子 quhan » 2018-03-02 3:10

相信大家都知道ssh可以组点对点网络,基本应用就是我有一台公网服务器a,一台内网服务器b。
这种情况下b可以访问a,但a不能访问b。
我在b上用ssh -w命令可以令ab建立一个点对点网络,于是a就可以访问b,包括用haproxy、nginx等代理b上开启的服务。

然后问题来了。
ssh -w命令似乎可以建立一个以太网络,但是相对于点对点网络,当只有2台服务器的时候,以太网络毫无意义,但如果是1+2、1+3……1+N就有意义了。
假设我有一台公网服务器a,两台内网服务器b与c。a可以分别和bc建立点对点网络或以太网络,但建完后a分别可以访问b和c,但是如何实现bc的直接互通呢?
理论上说,既然建立了以太网络,abc就组成了一个虚拟局域网,除了和主机a互通之外,局域网内的客户机理论也应该互通才对。但是我没能实现?
请教高手!!

另外,不要劝我使用vpn软件
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: 请教下关于ssh组网的问题

#2

帖子 poloshiao » 2018-03-02 8:40

相信大家都知道 ssh 可以组点对点网络
1. 如果你是指 套件 ssh
https://packages.ubuntu.com/xenial/ssh
套件 ssh
1-1. openssh-client (>= 1:7.2p2-4ubuntu2.4)
secure shell (SSH) client, for secure access to remote machines
1-2. openssh-server (>= 1:7.2p2-4ubuntu2.4)
secure shell (SSH) server, for secure access from remote machines
1-3. 安裝 套件 ssh 會同時安裝 套件
1-3-1. openssh-client # 客戶端套件 (預設設定檔 /etc/ssh/ssh_config)
1-3-2. openssh-server # 伺服器端套件 (預設設定檔 /etc/ssh/sshd_config)

2. 如果你是指 指令 ssh
http://manpages.ubuntu.com/manpages/xen ... ssh.1.html
ssh — OpenSSH SSH client (remote login program)
ssh 是 客戶端指令 (目的 是為了登入 伺服器端)
2-1. 意思是 ssh 是提供 客戶端 對 伺服器端 連線的指令
ssh -w
3. http://manpages.ubuntu.com/manpages/xen ... ssh.1.html
ssh — OpenSSH SSH client (remote login program)
-w local_tun[:remote_tun]
Requests tunnel device forwarding with the specified tun devices between the client (local_tun) and the server (remote_tun).
The devices may be specified by numerical ID or the keyword “any”, which uses the next available tunnel device. If remote_tun is not specified, it defaults to “any”. See also the Tunnel and TunnelDevice directives in ssh_config(5). If the Tunnel directive is unset, it is set to the default tunnel mode, which is “point-to-point”.
3-2. 意思是 ssh -w 指令 必須附帶指定一個既成的連接隧道 (而不是新建一個点对点网络) 否則就是 任意

3. 詳細參閱
3-1. 伺服器端
https://help.ubuntu.com/16.04/servergui ... erver.html
http://manpages.ubuntu.com/manpages/xen ... fig.5.html
http://manpages.ubuntu.com/manpages/xen ... shd.8.html
3-2. 客戶端
http://manpages.ubuntu.com/manpages/xen ... fig.5.html
http://manpages.ubuntu.com/manpages/xen ... ssh.1.html
3-3. 額外參閱
https://help.ubuntu.com/community/SSH
及其連結文章
quhan
帖子: 3
注册时间: 2018-03-02 3:02

Re: 请教下关于ssh组网的问题

#3

帖子 quhan » 2018-03-02 14:55

谢谢楼上。可能我的问题没表述清楚

ssh -w 1:1 user@host
可以建立一个隧道,然后用
ifconfig tap1 xxx.xxx.xxx.xxx pointopoint xxx.xxx.xxx.xxx netmask 255.255.255.252
令隧道两端形成一个点对点网络
ssh -w 1:1 -o Tunnel=ethernet user@host
可以建立一个用于建立以太网络的隧道,但是当我有多个内网服务器通过这种方式与外网服务器建立隧道后,如何将这一堆内网服务器连同外网服务器组建虚拟局域网呢?
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: 请教下关于ssh组网的问题

#4

帖子 poloshiao » 2018-03-02 16:13

ssh -w 1:1 -o Tunnel=ethernet user@host
如何将这一堆内网服务器连同外网服务器组建虚拟局域网呢?
看看 這三兩篇 有沒有幫助 :

1. http://manpages.ubuntu.com/manpages/xen ... ssh.1.html
SSH-BASED VIRTUAL PRIVATE NETWORKS

2. http://manpages.ubuntu.com/manpages/xen ... fig.5.html
使用 Tunnel 搜尋

3. http://manpages.ubuntu.com/manpages/xen ... fig.5.html
使用 PermitTunnel 搜尋

4. 進階參閱
https://help.ubuntu.com/community/SSH_VPN
how to set up an SSH VPN
quhan
帖子: 3
注册时间: 2018-03-02 3:02

Re: 请教下关于ssh组网的问题

#5

帖子 quhan » 2018-03-02 18:08

都看过,没讲到以太网应用
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: 请教下关于ssh组网的问题

#6

帖子 poloshiao » 2018-03-02 18:25

ifconfig tap1 xxx.xxx.xxx.xxx pointopoint xxx.xxx.xxx.xxx netmask 255.255.255.252
没讲到以太网应用
1. http://manpages.ubuntu.com/manpages/xen ... fig.5.html
Tunnel
Request tun(4) device forwarding between the client and the server. The argument must be “yes”, “point-to-point” (layer 3), “ethernet” (layer 2), or “no”. Specifying “yes” requests the default tunnel mode, which is “point-to-point”. The default is “no”.
1-1. 是不是 意味著 point-to-point 與 ethernet 不能同時被選擇 ?

2. http://manpages.ubuntu.com/manpages/xen ... fig.5.html
PermitTunnel
Specifies whether tun(4) device forwarding is allowed. The argument must be “yes”, “point-to-point” (layer 3), “ethernet” (layer 2), or “no”. Specifying “yes” permits both “point-to-point” and “ethernet”. The default is “no”.
Independent of this setting, the permissions of the selected tun(4) device must allow access to the user.
2-1. 特別注意
Specifying “yes” permits both “point-to-point” and “ethernet”.
头像
冲浪板
论坛版主
帖子: 7513
注册时间: 2007-05-06 8:19

Re: 请教下关于ssh组网的问题

#7

帖子 冲浪板 » 2018-03-03 11:09

b和c本来不就是通的,还是说bc不是在同一个内网
回复