r/SQL • • 19d ago

Oracle How to connect Oracle Database 19c from host machine to VirtualBox guest machine ?

Hi everyone, i want to access the oracle database on my guest machine (on VirtualBox) using my host machine (both machines are on windows 11) , i have already set up oracle client on my host machine but i couldn’t figure out how to connect it to the database on my guest machine , i also wasn’t able to find any YouTube tutorials explaining it , i would appreciate it if someone could redirect me to sources about this topic or explain to me how it’s done , thank you!

(I have to do this for school)

5 Upvotes

7 comments sorted by

1

u/TheMagarity 19d ago

This is a question for r/virtualbox

1

u/Last-Bonus6548 19d ago

Okay thank you

2

u/BinaryRockStar 19d ago edited 19d ago

VM software has network settings that generally allow you to assign a VM to

  • No network access at all
  • NAT mode where it acts like it is in it's own subnet so can't be seen by anything on your real network. Outbound connections from the VM work fine, inbound connections to the VM hit a hard wall.
  • Bridge(d) mode where it acts like a separate machine on your local network just as if it was an extra laptop/desktop. Your WiFi access point thinks it's a separate machine, it gets its own local IP address, it's a full on real machine as far as everyone is concerned.

You probably want the last one. If Oracle is anything like SQL Server then there will be an extra configuration step after installing the DB where you need to enable network access to it. This is for security reasons, the DB should become accessible precisely when the admin deems it's ready, not the instant you install it.

These days VMs are a bit out of fashion. If the DB has a docker image use that instead. It's like a VM (on Windows and Mac it really is a VM, invisible though) but without the extra resources of running a whole other operating system.

2

u/FallElectronic3774 18d ago

Set the VM adapter to Bridged (or keep NAT and add a 1521 port-forward). In the guest, ipconfig gives the IPv4; confirm the listener is up with lsnrctl status and that Windows Firewall allows TCP 1521. From the host: Test-NetConnection <guest-ip> -Port 1521, then sqlplus user/pass@//<guest-ip>:1521/<service> — use the service name shown by lsnrctl status (often ORCLPDB1 or XEPDB1). If the listener is only bound to 127.0.0.1, set its HOST to the guest IP or 0.0.0.0 in listener.ora and restart it; with NAT port-forward, connect to 127.0.0.1:1521 instead.

1

u/Plus_Dragonfruit_204 17d ago

These, are my notes from doing it. Haven't set one up in a while, but these still seem to be valid.

In the VM, in the network settings, set

Attached to to Bridged Adapter

Promiscuous Mode to Allow All

Restart the VM, the IP address will change.

Assuming that you had your listener set up correctly, you should only need to go into the listener.ora file and change the IP address that it is listening on and restart the listener.