Try   HackMD

虛擬機使用 Host 的 VPN 網路

本篇主要講述怎麼讓虛擬機也使用與 Host 一樣的 VPN 網路,若沒有 VPN 需求,可以左轉離開。

介面卡 1,連線至主機的 VPN 網路

虛擬機設定

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

在虛擬機設定中選擇 網路 -> 介面卡 1,設定成 附加到 NAT

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

在虛擬機設定中選擇 網路 -> 介面卡 1,設定成 附加到 NAT

收集 IP

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Windows 為例,開啟 cmd 輸入 ipconfig,找到 VirtualBox Host-Only Network IPv4

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

找到 10.0 開頭的 NAT 使用網路,如上圖中的 10.0.2.5

轉接埠設定

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

點擊 連接埠轉送 並添加對應的主機、客體設定

若上述操作正確,在主機輸入 192.168.56.1:8060 應能正確連線至虛擬機的 8080 了


介面卡 2,讓主機能夠連線至虛擬機(optional)

虛擬機設定

如果你有 ssh 至虛擬機的需求,才需要執行這個 section

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

在虛擬機設定中選擇 網路 -> 介面卡 2,設定成 附加到 僅限主機介面卡

收集 IP

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

找到 192.168 開頭的主機網路,如上圖中的 192.168.56.101

若上述操作正確,主機應能 ssh 至虛擬機 192.168.56.101 了