iT邦幫忙

2

自己構建完全免費的VPN Server(冀Oracle Cloud + Google Outline 使用教學)

目錄

  1. 註冊與登入Oracle cloud
  2. 第二部分: 設置Oracle Cloud
  3. 第三部分:Oracle 防火牆設定(14,Oct,2019 updated)
  4. 第四部分:SSH
  5. 第五部分:Outline VPN
  6. 第六部分:使用VPN
  7. 結語
  8. 附錄:暴力開Port 大法

第一部分:註冊與登入Oracle cloud

  1. 去Oracle 官網:https://www.oracle.com/cloud/free/?source=:ow:o:p:nav:0916BCButton&intcmp=:ow:o:p:nav:0916BCButton

  2. Click Start for free

    https://ithelp.ithome.com.tw/upload/images/20191020/20120557YKnX1pfbDj.png

  3. 之後寫電郵地址(要記得)和位置,位置可以隨便寫,不是Server位置。

    https://ithelp.ithome.com.tw/upload/images/20191020/20120557TUDa4tMAx8.png

  4. 下一步最重要既就係填寫Account Name(要記得),Home Region 同 tel number,其他可以隨便寫

    https://ithelp.ithome.com.tw/upload/images/20191020/201205577A2itWCXVB.png

  5. 選擇home region要注意,得呢3個地方有免費Server 用

    https://ithelp.ithome.com.tw/upload/images/20191020/201205579UmE356LDP.png

  6. click Next既時候要等一陣,如果佢話你錯要寫翻岩個地址

    https://ithelp.ithome.com.tw/upload/images/20191020/201205572Wr5MD9ljP.png

  7. 寫Password要符合咁多個要求(都係要記得Password的)

    https://ithelp.ithome.com.tw/upload/images/20191020/201205575FNj6UloQj.png

  8. 之後就係填信用卡資料

  9. 入呢個Link:https://cloud.oracle.com/sign-in ,寫Account 名

    https://ithelp.ithome.com.tw/upload/images/20191020/20120557l0E9H6XdPu.png

  10. 跟著打Email Address 同埋 Password

    https://ithelp.ithome.com.tw/upload/images/20191020/20120557opP3rLJoVc.png

第二部分: 設置Oracle Cloud

  1. 進入到Oracle 帳號頁面,之後,選Create a VM instance

    https://ithelp.ithome.com.tw/upload/images/20191020/201205574h27itckAZ.png

  2. 為你的VM改一個名字,然後按change image source

    https://ithelp.ithome.com.tw/upload/images/20191020/20120557LYlGqWOcE2.png

  3. 選Ubuntu或者CentOS都可以,我選Ubuntu 18.04 Minimal

    https://ithelp.ithome.com.tw/upload/images/20191020/20120557G3XTAZ7DD0.png

  4. 記得在最底按 Select Image

  5. 下一步就係SSH Key,你們可以看以下Website

    1. https://confluence.atlassian.com/bitbucketserver/creating-ssh-keys-776639788.html
  6. 在File Browser打開 ~/.ssh文件夾 (Windows 是 %userprofile%/.ssh

  7. id_rsa.pub 拖到黃圈位置,然後按 create

    https://ithelp.ithome.com.tw/upload/images/20191020/20120557IKmKYvb4jI.png

  8. 之後你應該會見到以下頁面

    https://ithelp.ithome.com.tw/upload/images/20191020/201205574lJqG1NYVI.png

  9. 滾到下面,當看到下面的情況,選Attached VNIC

    https://ithelp.ithome.com.tw/upload/images/20191020/201205578nNUUN721F.png

  10. 選這個,不同人有不同名字

    https://ithelp.ithome.com.tw/upload/images/20191020/20120557GRen0BAYM6.png

  11. 選IP Address

    https://ithelp.ithome.com.tw/upload/images/20191020/20120557sCTIFTzy5N.png

  12. 選Edit!!

    https://ithelp.ithome.com.tw/upload/images/20191020/20120557BcSgXW1waj.png

  13. 選EPHEMERAL PUBLIC IP和Update

    https://ithelp.ithome.com.tw/upload/images/20191020/20120557eApr5LWIDa.png

  14. 然後你就可以在同一頁得到Public IP了。把Public IP 複製儲存

    https://ithelp.ithome.com.tw/upload/images/20191020/20120557c6hwad0M2K.png

第三部分:Oracle 防火牆設定(14,Oct,2019 updated)

https://ithelp.ithome.com.tw/upload/images/20191020/20120557pBwsVo4H5z.png

https://ithelp.ithome.com.tw/upload/images/20191020/20120557YdbeeTPK6J.png

https://ithelp.ithome.com.tw/upload/images/20191020/20120557B5hl2bFTSO.png

https://ithelp.ithome.com.tw/upload/images/20191020/20120557h4QWaE7M5Z.png

https://ithelp.ithome.com.tw/upload/images/20191020/20120557CycNuT5KdE.png

https://ithelp.ithome.com.tw/upload/images/20191020/20120557jLggffKfCc.png

第四部分:SSH

  1. 打開terminal

  2. 把以下代碼貼進去

     ssh ubuntu@"你的Public IP Address" -i ~/.ssh/id_rsa
     yes
    
  3. Windows 打開Powershell

     ssh ubuntu@"你的Public IP Address" -i %userprofile%/.ssh/id_rsa
     yes
    
  4. 你可以發現你應該登入了那個Oracle Server,如果你見到 ubuntu@"你的server名字" 那麼就成功了。

  5. 不要把Terminal關掉

第五部分:Outline VPN

  1. 去這個網頁https://getoutline.org/en/home下載與安裝Outline Manager 和Outline

  2. 打開Outline Manager,選anywhere

    https://ithelp.ithome.com.tw/upload/images/20191020/20120557GDaU35eVhI.png

  3. 複製這些代碼到terminal中,然後enter

    https://ithelp.ithome.com.tw/upload/images/20191020/20120557lQebAnliJN.png

  4. 然後打以下代碼

     Y
    
  5. 安裝完成你會見到這兩個message

    https://ithelp.ithome.com.tw/upload/images/20191020/20120557qHPy8hQpOH.png

    https://ithelp.ithome.com.tw/upload/images/20191020/20120557Y6qNxvUDB7.png

  6. 然後我們要打以下代碼,記得要將 29775 轉換成Management Port。25931 轉換成你的Access Key Port

     sudo iptables -I INPUT -p tcp -m tcp --dport 29775 -j ACCEPT
     sudo iptables -I INPUT -p tcp -m tcp --dport 25932 -j ACCEPT
     sudo iptables -I INPUT -p udp -m udp --dport 25932 -j ACCEPT
     sudo netfilter-persistent save
     sudo netfilter-persistent reload
    
  7. 把你的Terminal綠色Output部分(圖上被黃色覆蓋的部分)複製到Outline的第二部分

    https://ithelp.ithome.com.tw/upload/images/20191020/20120557gZhlw3gb0L.png

    https://ithelp.ithome.com.tw/upload/images/20191020/20120557tU1On0olx1.png

  8. 按Done,大功告成

第六部分:使用VPN

  1. Key 1 旁邊有個share icon,按他會得到 ss開頭的Link(在 "1. copy your access Key"下面 )

    https://ithelp.ithome.com.tw/upload/images/20191020/20120557XgCPZQ39th.png

  2. 在手機上點 +

    https://ithelp.ithome.com.tw/upload/images/20191020/20120557XN6lIS41P1.png

  3. 複製ss key到這裏

    https://ithelp.ithome.com.tw/upload/images/20191020/20120557jTaFMaCbax.png

結語

大功告成,現在你已經擁有了一個VPN Server了。非常感謝你看完這個很長的教學。

附錄:暴力開Port 大法

以下操作可以用來處理第五部分 iptables 的異常情況,例如Outline的無法連結你的Server.
Outline

解決辦法如下

iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -F

但此舉將大幅增加你的資安風險,務必嘗試過其他辦法後再試過。


圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 則留言

0
wei770702
iT邦新手 5 級 ‧ 2020-02-26 22:24:13

感謝教學
非常詳細!!!!

卡在第三部分:Oracle 防火牆設定 的人

那個access key 跟manage key
是等一下出現才要設定的

0
qazw3334
iT邦新手 5 級 ‧ 2022-03-19 01:00:34

謝謝教學!

我要留言

立即登入留言