linux系统中实现网络会话共享功能

实验一共需要三台主机完成:

PC1:192.168.10.10

PC2:192.168.10.20

PC2:192.168.10.30

 

1、测试三台主机网络连通性

[root@PC1 ~]# ifconfig | head -n 3
eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.10.10  netmask 255.255.255.0  broadcast 192.168.10.255
        inet6 fe80::20c:29ff:fe66:37f7  prefixlen 64  scopeid 0x20<link>
[root@PC1 ~]# ping -c 3 192.168.10.20
PING 192.168.10.20 (192.168.10.20) 56(84) bytes of data.
64 bytes from 192.168.10.20: icmp_seq=1 ttl=64 time=0.294 ms
64 bytes from 192.168.10.20: icmp_seq=2 ttl=64 time=0.195 ms
64 bytes from 192.168.10.20: icmp_seq=3 ttl=64 time=0.197 ms

--- 192.168.10.20 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.195/0.228/0.294/0.049 ms
[root@PC1 ~]# ping -c 3 192.168.10.30
PING 192.168.10.30 (192.168.10.30) 56(84) bytes of data.
64 bytes from 192.168.10.30: icmp_seq=1 ttl=64 time=0.220 ms
64 bytes from 192.168.10.30: icmp_seq=2 ttl=64 time=0.210 ms
64 bytes from 192.168.10.30: icmp_seq=3 ttl=64 time=0.203 ms

--- 192.168.10.30 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.203/0.211/0.220/0.007 ms

 

2、PC2主机ssh远程连接PC1主机,然后使用screen命令创建两个网络会话test01和test02

[root@PC2 ~]# ssh root@192.168.10.10
root@192.168.10.10's password: 
Last login: Sat Dec 19 23:40:45 2020 from 192.168.10.30
[root@PC1 ~]# screen -ls
No Sockets found in /var/run/screen/S-root.

[root@PC1 ~]# screen -S test01   ## ctrl + a + d 退出
[detached from 33223.test01]
[root@PC1 ~]# screen -S test02   ## ctrl+ a + d 退出
[detached from 33249.test02]
[root@PC1 ~]# screen -ls
There are screens on:
    33249.test02    (Detached)
    33223.test01    (Detached)
2 Sockets in /var/run/screen/S-root.
[root@PC1 ~]# screen -r test01 ## 进入会话 test01

 

3、PC3主机ssh远程登录PC1主机,执行screen -x test01,就可以实现会话共享

 

以上实验实现PC2主机和PC2主机远程登录PC1主机之后的会话共享。

 

posted @ 2020-12-20 00:00  小鲨鱼2018  阅读(163)  评论(0编辑  收藏  举报