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
相關文章
相關標籤/搜索