SecureCRT 链接本地linux虚拟机(二)

SecureCRT 链接本地linux虚拟机(二)linux

上篇讲述了经过SecureCRT SSH链接本地虚拟机中关于虚拟机安装openssh-client和启用相关服务。本篇介绍关于如何配置虚拟机网络链接方式。
bash

1、在VirtualBox中将网络链接配置为桥接网卡方式。SecureCRT能远端到虚拟服务器,同时虚拟服务器可以访问外网。服务器

wKiom1W0ofexp4W5AAHDFp6d8Ug544.jpg

本机经过无线网卡链接外网。因此界面名称选择的桥接网卡为无线网卡。网络

在虚拟终端查看网络信息,经过ifconfig命令ssh

huanr@huanr-VBox:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:86:d2:30  
          inet addr:192.168.1.111  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe86:d230/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:23954 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9961 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:29500490 (29.5 MB)  TX bytes:784452 (784.4 KB)
...
huanr@huanr-VBox:~$

能够看到虚拟机地址为192.168.1.111,在客户机ping该地址,能够ping通,说明能客户机到虚拟机可通信。ide


在虚拟机ping客户机地址,ping外网,如baiduspa

huanr@huanr-VBox:~$ ping 192.168.1.106
PING 192.168.1.106 (192.168.1.106) 56(84) bytes of data.
64 bytes from 192.168.1.106: icmp_seq=1 ttl=64 time=0.668 ms
64 bytes from 192.168.1.106: icmp_seq=2 ttl=64 time=0.426 ms
64 bytes from 192.168.1.106: icmp_seq=3 ttl=64 time=0.579 ms


huanr@huanr-VBox:~$ ping www.baidu.com
PING www.a.shifen.com (119.75.217.109) 56(84) bytes of data.
64 bytes from 119.75.217.109: icmp_seq=1 ttl=56 time=56.9 ms
64 bytes from 119.75.217.109: icmp_seq=2 ttl=56 time=10.4 ms
64 bytes from 119.75.217.109: icmp_seq=3 ttl=56 time=11.8 ms
64 bytes from 119.75.217.109: icmp_seq=4 ttl=56 time=14.6 ms

都能通信,说明虚拟机能访问外网。orm


2、NAT网络地址转换。(虚机能访问Internet,而SecureCRT没法链接到虚拟机)blog


wKiom1W0pYnSj5KvAAGflydc5Ms450.jpg

虚拟机ping主机和外网:get

huanr@huanr-VBox:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:86:d2:30  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe86:d230/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:23954 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9961 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:29500490 (29.5 MB)  TX bytes:784452 (784.4 KB)
huanr@huanr-VBox:~$ ping 192.168.1.106
PING 192.168.1.106 (192.168.1.106) 56(84) bytes of data.
64 bytes from 192.168.1.106: icmp_seq=1 ttl=63 time=2.35 ms
64 bytes from 192.168.1.106: icmp_seq=2 ttl=63 time=1.38 ms
64 bytes from 192.168.1.106: icmp_seq=3 ttl=63 time=2.04 ms


huanr@huanr-VBox:~$ ping www.baidu.com
PING www.a.shifen.com (119.75.217.109) 56(84) bytes of data.
64 bytes from 119.75.217.109: icmp_seq=1 ttl=55 time=12.9 ms
64 bytes from 119.75.217.109: icmp_seq=2 ttl=55 time=10.9 ms
64 bytes from 119.75.217.109: icmp_seq=3 ttl=55 time=10.3 ms

说明虚拟机到主机能通信,可访问外网。



主机ping虚拟机地址

C:\>ping 10.0.2.15

正在 Ping 10.0.2.15 具备 32 字节的数据:
请求超时。
请求超时。
请求超时。
请求超时。

10.0.2.15 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 0,丢失 = 4 (100% 丢失),

通信超时,没法经过SecureCRT链接到虚拟机。



3、仅主机(Host-Only)适配器链接方式。可经过SecureCRT链接到虚拟机,但虚机没法与外界通信

wKioL1W0q1jAXDuYAAG6W6ZKXXs837.jpg


自动获取virtualBox网卡地址

wKiom1W0qpCDCU9uAAGrBnTBD4M148.jpg

huanr@huanr-VBox:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:86:d2:30  
          inet addr:192.168.56.101  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe86:d230/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:24495 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10842 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:29561758 (29.5 MB)  TX bytes:890494 (890.4 KB)

ping客户机,没法到达

huanr@huanr-VBox:~$ ping 192.168.1.106
connect: Network is unreachable



客户机ping虚机能够通信

C:\>ping 192.168.56.101

正在 Ping 192.168.56.101 具备 32 字节的数据:
来自 192.168.56.101 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.56.101 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.56.101 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.56.101 的回复: 字节=32 时间<1ms TTL=64

192.168.56.101 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
    最短 = 0ms,最长 = 0ms,平均 = 0ms
相关文章
相关标签/搜索