nicsure

Oracle VPN Transcript

Nov 25th, 2022 (edited)
544
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.67 KB | None | 0 0
  1. [Required Software]
  2. PuTTY: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
  3. OpenVPN GUI: https://openvpn.net/community-downloads/
  4. WinRAR: https://www.rarlab.com/download.htm
  5. or
  6. 7-Zip: https://www.7-zip.org/download.html
  7.  
  8.  
  9. [Create Oracle Cloud Account]
  10. https://signup.cloud.oracle.com/
  11.  
  12.  
  13. [Setup VCN]
  14. Top Left 3 Horizontal Bars
  15. Click Networking -> Virtual Cloud Networks
  16. Click: Create VCN
  17. Name: vcn1
  18. IPv4 CIDR Blocks: 10.0.0.0/16 [press return]
  19. IPv6 Prefixes: Select "Assign an Oracle allocated IPv6 /56 prefix."
  20. Click: Create VCN
  21.  
  22.  
  23. [Setup VCN > Subnet]
  24. Click: Create Subnet
  25. Name: subnet1
  26. Subnet Type: Regional
  27. IPv4 CIDR Block: 10.0.0.0/30
  28. IPv6 Prefixes: Select "Assign an Oracle allocated IPv6 /64 prefix."
  29. Oracle allocated IPv6 address: 00
  30. Route Table Compartment: Select default
  31. Subnet Access: Public
  32. Dhcp Options: Select default
  33. Security Lists: Select default
  34. Click: Create Subnet
  35.  
  36.  
  37. [Setup VCN > Gateway]
  38. Under Resources on the left, click: Internet Gateways
  39. Click: Create Internet Gateway
  40. Name: gateway1
  41. Click: Create Internet Gateway
  42.  
  43.  
  44. [Setup VCN > Routes]
  45. Under Resources on the left, click: Route Tables
  46. Click: Default Route Table for vcn1
  47. Click: Add Route Rules
  48. Protocol Version: IPv4
  49. Target Type: Internet Gateway
  50. Destination CIDR Block: 0.0.0.0/0
  51. Target Internet Gateway: gateway1
  52. Click: Add Route Rules
  53. Click: Add Route Rules
  54. Protocol Version: IPv6
  55. Target Type: Internet Gateway
  56. Destination CIDR Block: ::/0
  57. Target Internet Gateway: gateway1
  58. Click: Add Route Rules
  59.  
  60.  
  61. [Setup VCN > Firewall]
  62. On the Navigation Path at the top, Click: vcn1
  63. Under Resources on the left, click: Security Lists
  64. Click: Default Security List for vcn1
  65. Click: Add Ingress Rules
  66. -- Allow Webmin
  67. Source Type: CIDR
  68. Source CIDR: 0.0.0.0/0
  69. IP Protocol: TCP
  70. Destination Port Range: 10000
  71. Click: Add Ingress Rules
  72. Click: Add Ingress Rules
  73. -- Allow OpenVPN (IPv4)
  74. Source Type: CIDR
  75. Source CIDR: 0.0.0.0/0
  76. IP Protocol: UDP
  77. Destination Port Range: 1194
  78. Click: Add Ingress Rules
  79. Click: Add Ingress Rules
  80. -- Allow OpenVPN (IPv6)
  81. Source Type: CIDR
  82. Source CIDR: ::/0
  83. IP Protocol: UDP
  84. Destination Port Range: 1194
  85. Click: Add Ingress Rules
  86.  
  87.  
  88. [Create VM]
  89. Top Left 3 Horizontal Bars
  90. Click Compute -> Instances
  91. Click: Create Instance
  92. Name: Whatever you want
  93. Placement -> Click: Edit
  94. -- Placement Domain
  95. Select the domain you want (Note for AMD free instances you need domain 1)
  96. Image and shape -> Click: Edit
  97. Click: Change image
  98. Select: Canonical Ubuntu
  99. Click: Select image
  100. Click: Change shape
  101. Select: whatever you want, I select VM.Standard.A1.Flex [Always Free-eligible] Ampere 1xOCPU 6GB RAM
  102. Click: Select shape
  103. Add SSH keys
  104. Select: Generate a key pair for me
  105. Click: Save private key (save it in your VPS folder)
  106. Click: Save public key (save it in your VPS folder)
  107. Select: Specify a custom boot volume size
  108. Boot volume size (GB): 50
  109. Use in-transit encryption: Do not select
  110. Click: Create
  111. Note: You may get an error message in red at the bottom. If this happens, try again.
  112. If it keeps happening select another placement domain and try again.
  113.  
  114.  
  115.  
  116. [Instance > Add IPv6 addresses]
  117. Under Resources on the left, click: Attached VNICs
  118. Click the name of the VNIC (same as instance name) in the table at the bottom.
  119. Under Resources on the left, click: IPv6 Addresses
  120. Click: Assign IPv6 Address
  121. Prefix: Select the prefix from the drop down (should be only 1)
  122. Select: Manually assign IPv6 addresses from prefix
  123. IPv6 Address: Enter :1:1
  124. Click: Assign
  125. Click: Assign IPv6 Address
  126. Prefix: Select the prefix from the drop down (should be only 1)
  127. Select: Manually assign IPv6 addresses from prefix
  128. IPv6 Address: Enter :1:2
  129. Click: Assign
  130. Repeat this process up to :1:f
  131.  
  132.  
  133. [Create an Info File]
  134. In your VPS folder create a new Text Document called info.txt
  135. Edit info.txt
  136. Enter the IPv4 Public and Private address
  137. Enter the IPv6 Prefix
  138. Create a secure password and Enter this too.
  139.  
  140.  
  141. [Log into Instance]
  142. Open PuTTYgen
  143. Load an existing private key file -> Click: Load
  144. -- Convert Private Key
  145. Change from PuTTY Private Key Files to All Files
  146. Open the .key (NOT the .key.pub) file you saved during the instance setup
  147. Save the generated key -> Click: Save private key
  148. Select "Yes" when prompted to save without a passphrase
  149. Give the key a name with a .ppk extension (such as oracle.ppk)
  150. Click: Save
  151. -- Log into Instance
  152. Using File Explorer Navigate to C:\Program Files\PuTTY
  153. Locate the main PuTTY executable, right click it and select: Copy
  154. Navigate to your VPS folder and right click in empty space, select: Paste shortcut
  155. Rename the shortcut to whatever you want, I rename it to "SSH to Oracle VPS".
  156. Right click the shortcut and select: Properties
  157. In 'Target' you should see "C:\Program Files\PuTTY\putty.exe"
  158. Change this to "C:\Program Files\PuTTY\putty.exe" ubuntu@[publicIPv4] -i oracle.ppk
  159. In 'Start in' you should see "C:\Program Files\PuTTY"
  160. Change this to the same folder as your VPS folder, mine is on my desktop.
  161. Click: OK
  162. Double click the shortcut and accept the certificate warning.
  163. You should now be logged in.
  164.  
  165.  
  166.  
  167. [Set root/user passwords]
  168. In your info.txt file copy the secure password you created to the clipboard
  169. In the shell enter: sudo passwd
  170. When asked for new password, right click in the window and press return
  171. When asked to retype password, again right click in the window and press return
  172. In the shell enter: sudo passwd ubuntu
  173. When asked for new password, right click in the window and press return
  174. When asked to retype password, again right click in the window and press return
  175.  
  176.  
  177.  
  178. [Update/Upgrade]
  179. In the shell enter: sudo apt update
  180. In the shell enter: sudo apt upgrade
  181. Enter: y
  182. pink screen, press return
  183. press tab until <OK> is highlighted, press return
  184.  
  185.  
  186. [Enable Packet Forwarding]
  187. In the shell enter: sudo nano /etc/sysctl.conf
  188. remove the # from the lines:
  189.  
  190. #net.ipv4.ip_forward=1
  191. #net.ipv6.conf.all.forwarding=1
  192.  
  193. press: CNTL-X then Y then Return
  194.  
  195.  
  196. [Edit main openssl config]
  197. In the shell enter: sudo nano /etc/ssl/openssl.cnf
  198. scroll down until you see: default_days = 365
  199. Change lines to the following
  200.  
  201. default_days = 3650
  202. default_crl_days= 3650
  203. default_md = sha512
  204.  
  205. press: CNTL-X then Y then Return
  206.  
  207.  
  208. [Install openvpn]
  209. In the shell enter: sudo apt install openvpn
  210. Enter: y
  211.  
  212.  
  213. [Install Webmin]
  214. Go to: https://www.webmin.com/deb.html
  215. Copy the wget line from the webpage and paste (right click) into PuTTY
  216. Copy the dpkg line from the webpage
  217. In the shell enter: sudo (put a space after sudo)
  218. Paste (right click) the dkpg line into PuTTY
  219. You should eventually see some dependency problems, ignore this
  220.  
  221.  
  222.  
  223. [Edit Webmin openssl config]
  224. In the shell enter: sudo nano /usr/share/webmin/acl/openssl.cnf
  225. scroll down until you see: default_days = 365
  226. Change lines to the following
  227.  
  228. default_days = 3650
  229. default_crl_days= 3650
  230. default_md = sha512
  231.  
  232. press: CNTL-X then Y then Return
  233.  
  234.  
  235. [Install dependencies]
  236. In the shell enter: sudo apt install -f
  237. Enter: y
  238.  
  239.  
  240. [Edit iptables file]
  241. In the shell enter: sudo nano /etc/iptables/rules.v4
  242. Find the line:
  243. -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
  244. After this line add the following two lines
  245.  
  246. -A INPUT -p tcp -m state -m tcp --dport 10000 --state NEW -j ACCEPT
  247. -A INPUT -p udp -m udp --dport 1194 -j ACCEPT
  248.  
  249. press: CNTL-X then Y then Return
  250.  
  251.  
  252. [Reboot Instance]
  253. In the shell enter: sudo reboot
  254. Log back in after reboot.
  255.  
  256.  
  257. [Log into Webmin]
  258. In your VPS folder, right click on empty space and select: New -> Shortcut
  259. For Location of item enter: https://[publicIPv4]:10000
  260. Click: Next
  261. Give the shortcut a name, anything you like. I used 'Webmin on Oracle'
  262. Double Click the shortcut
  263. -- Logging In
  264. Accept the security risks (self-signed certificate)
  265. For Username & Password use root and the password you created previously in info.txt
  266.  
  267.  
  268. [Add OpenVPN Webmin Module]
  269. On the left panel, select: Webmin -> Webmin Configuration
  270. Click: Webmin Modules
  271. Select: From HTTP or FTP URL
  272. In the box enter: https://github.com/nicsure/webmin-openvpn-debian-jessie/raw/master/openvpn.wbm.gz
  273. Click: Install Module
  274.  
  275.  
  276. [Edit OpenVPN module openssl config]
  277. In the shell enter: sudo nano /usr/share/webmin/openvpn/openvpn-ssl.cnf
  278. scroll down until you see: default_md = sha256
  279. Change this to: default_md = sha512
  280. press: CNTL-X then Y then Return
  281.  
  282.  
  283. [OpenVPN Create CA]
  284. On the left panel, select: Server -> OpenVPN + CA
  285. Click: Certification Authority List
  286. Name of Certification Authority: choose whatever you like, I used 'myca'
  287. Click: Save (this can take a while so be patient)
  288. Click: Return to OpenVPN Administration
  289.  
  290.  
  291. [Server/Client keys]
  292. Click: Certification Authority List
  293. Click: Keys list
  294. Key name: server1
  295. Key Server -> Select: server
  296. Click: Save
  297. Click: Return to keys list...
  298. Key name: oracle_v4
  299. -- IPv4 Client Key
  300. Key Server -> Select: client
  301. Click: Save
  302. Click: Return to keys list...
  303. Key name: oracle_v6
  304. -- IPv6 Client Key
  305. Key Server -> Select: client
  306. Click: Save
  307.  
  308.  
  309. [Create VPN]
  310. On the left panel, select: Server -> OpenVPN + CA
  311. Click: VPN List
  312. Click: New VPN Server
  313. Name: Whatever you want, I used 'oraclevpn'
  314. proto (Protocol) -> Select: udp6
  315. Net IP assigns (option server):10.50.0.0 Netmask:255.255.255.0
  316. Persist/unpersist...: yes
  317. Allow multiple clients...: yes
  318. Encrypt packets with cipher...: AES-256-GCM...
  319. Use fast LZO...: no
  320. User & Group set to: root
  321. float...: yes
  322. Additional Configurations -> Enter the following
  323.  
  324. ifconfig-ipv6 [your_ipv6_prefix]::1:1/124 ::
  325. ifconfig-ipv6-pool [your_ipv6_prefix]::1:2/124
  326. auth SHA512
  327. push "dhcp-option DNS 8.8.8.8"
  328. push "dhcp-option DNS 8.8.4.4"
  329. push "redirect-gateway def1 bypass-dhcp"
  330. push "route-ipv6 2000::/3"
  331.  
  332. Click: Save
  333.  
  334.  
  335. [Add Client Keys]
  336. Click: Client List
  337. Click: New VPN Client
  338. Name -> Select: oracle_v4
  339. -- IPv4
  340. remote (Remote IP): [your_public_ipv4]
  341. Use fast LZO compression: no
  342. Additional Configurations: auth SHA512
  343. Click: Save
  344. Click: New VPN Client
  345. Name -> Select: oracle_v6
  346. -- IPv6
  347. remote (Remote IP): [your_ipv6_prefix]::1:1
  348. Use fast LZO compression: no
  349. Additional Configurations: auth SHA512
  350. Click: Save
  351. On both oracle_v4 & oracle_v6 Click on 'Archive' and save the files to your VPS folder
  352.  
  353.  
  354. [Install Client Key Bundle]
  355. In Windows, start OpenVPN GUI application
  356. Right click OpenVPN GUI's notification icon and select: Settings
  357. Under 'Configuration Files' you will see 'Folder' and a box containing a file path
  358. To the right of this there is a button, click it. A Folder browse dialog will open.
  359. Now open one of the the Archive files you downloaded with WinRAR or 7-Zip
  360. A window should open with a folder in it, drag this into the browse dialog
  361. (Note: With 7-Zip it will show a .tar file, double click this to get the folder)
  362. Repeat for the other Archive file.
  363. Click Cancel
  364.  
  365.  
  366. [Configure iptables]
  367. In Webmin on the left panel, select: Networking -> Linux Firewall
  368. Under 'Forwarded packets (FORWARD)' there is one Reject rule listed
  369. Check the box to the left of this rule and click 'Delete Selected' underneath.
  370. Showing IPtable: Network address translation (nat)
  371. Packets after routing (POSTROUTING): Click 'Add Rule'
  372. Action to Take: Source NAT
  373. IPs and ports for SNAT
  374. Select -> IP range: [privateIPv4] to [blank] Port range: [blank] to [blank]
  375. Source address or network -> Equals: 10.50.0.0/24
  376. Outgoing interface -> Equals: enp0s3
  377. Click: Create
  378. Click: Apply Configuration
  379.  
  380.  
  381. [Adjust IPv4 Client Config]
  382. Right click OpenVPN GUI's notification icon. Select: Settings
  383. Click Advanced Tab
  384. Click Browse Button next to Configuration Files > Folder
  385. Right click Oracle_v4. Select 'Open in new Window'
  386. Right click oracle_v4.ovpn. Select: Open with > Notepad
  387.  
  388. Change: proto udp6
  389. to: proto udp
  390.  
  391. File Menu > Save
  392. Close Notepad
  393.  
  394.  
  395. [Reboot & Test]
  396. In the shell enter: sudo reboot
  397. Give it a minute or so to fully restart.
  398. In Windows, right click the OpenVPN GUI notification icon.
  399. Move to "oracle_v4" and select "Connect" from the sub-menu that opens.
  400. If you have IPv6 connectivity you may also use "oracle_v6" to connect via IPv6
  401.  
  402.  
  403. EXTRA INFORMATION
  404. While testing I was relying on the OS auto-removing the assigned IPv6 addresses from the VNIC interface enp0s3. This behaviour seems to have changed (possibly some update) and these addresses are no longer being auto removed and thus causing IP conflicts prevent IPv6 VPN functionality working. The reason I have to assign them at all is because Oracle's system will not route any traffic to an instance unless the destination IP is actually assigned to that instance. While testing, these IPs were being auto-removed from enp0s3 because they conflicted with the static IPs assigned to the VPN, now this does not seem to be happening anymore. I had to implement a script to purge the V6 addresses from the interface as they are added. I couldn't find any other way of doing it, disabling DHCPv6 didn't work.
  405.  
  406. Here's the procedure to follow after following the installation video.
  407.  
  408. Log into SSH
  409. Create a script : sudo nano /usr/sbin/v6purger
  410.  
  411. #!/bin/bash
  412. ip -6 monitor address dev enp0s3 | while read word1 word2 word3 word4 word5; do
  413. if [[ "$word4" == *"/"* ]]; then
  414. ip -6 addr del $word4 dev enp0s3 >/dev/null 2>/dev/null
  415. fi
  416. done
  417.  
  418. Press: CNTL-X then Y then Return to save the script
  419. Make the script executable : sudo chmod +x /usr/sbin/v6purger
  420. Create a system service unit : sudo nano /lib/systemd/system/v6purger.service
  421.  
  422. [Unit]
  423. Description=Auto IPv6 Address Purger
  424.  
  425. [Service]
  426. Type=simple
  427. ExecStart=/bin/bash /usr/sbin/v6purger
  428.  
  429. [Install]
  430. WantedBy=multi-user.target
  431.  
  432. Press: CNTL-X then Y then Return to save the file
  433. Enable the service : sudo systemctl enable v6purger.service
  434. Start the service : sudo systemctl start v6purger.service
  435. Reboot instance: sudo reboot
  436.  
  437.  
Advertisement
Add Comment
Please, Sign In to add comment