Connecting to Oracle from Your Host to a VirtualBox OEL Guest

加入 Oracle技术学习QQ群:171092051




服务热线 : 400-690-3643 备用电话: 13764045638 邮箱


This isn’t a SQL Developer post per-se, however if you are using the Oracle Developer Day VirtualBox 12c image, you will find this useful.

A few of you have noticed that it’s difficult to connect to your Oracle Database from your computer if it’s running on this image. One Twitter friend asked just yesterday…

Need help with connecting @OracleSQLDev on host computer to @virtualbox guest OS (Oracle Developer Day). Any thoughts?

Now, I should note that you can indeed easily run your tools directly from inside the image, SQL Developer and APEX included. But if you want to run your browser and/or tools from OUTSIDE the image and talk to the database, then you might need to keep reading.

The simple answer is that port 1521 isn’t open in the Firewall

This is easy to fix.

You'll need the root password, same as oracle's on this image

You’ll need the root password, same as oracle’s on this image

Now once this port (1521 is the default for the Oracle Listener for TCP connections although 1522 is also popular) is open, you can connect from outside the image.

You can also just wipe all the firewall rules. This is a ‘play’ image running on your personal machine, so there’s probably nothing to worry about doing something like:

[root@localhost ~]# iptables --flush
[root@localhost ~]# /etc/init.d/iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]

Either way, once the firewall is no longer stopping you from talking over port 1521…

You have two options to connect into your VirtualBox guest:

  • Get an IP address for the image that your Host can ‘see’
  • Setup Port Forwarding

Get an IP Address

What I do, from trial-and-error, is setup a 2nd network adapter.

You'll need to reboot your image after any networking changes

You’ll need to reboot your image after any networking changes

And then once your image is up and running, see if you got an IP assigned.

In *NIX this is done via

[oracle@localhost ~]$ /sbin/ifconfig
eth1      Link encap:Ethernet  HWaddr 08:00:27:22:79:4F  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::a00:27ff:fe22:794f/64 Scope:Link
          RX packets:5931 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:393510 (384.2 KiB)  TX bytes:1242 (1.2 KiB)

So I can connect directly onto, probably.

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.


Pinging with 32 bytes of data:
Reply from bytes=32 time<1ms TTL=64
Reply from bytes=32 time<1ms TTL=64
Reply from bytes=32 time<1ms TTL=64

Ping statistics for
    Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

Let’s see what happens in SQL Developer.

I don't normally connect by IP, but when I do...

I don’t normally connect by IP, but when I do…

So why don’t I always just do this?

Well, when I enable my corporate VPN, this no longer works for me. Or, the IP address CAN change.

If only there were a better way?

Port Forwarding

Basically I can tell VirtualBox to take traffic from a local port and transfer it to a port on the guest port. So I want to talk on port 1521 and have it go to the listener port on our Developer Day image.

Pretty straightforward...

Pretty straightforward…

You remembered to open up port 1521 in the Linux Firewall, yes? Good.

Now connect!

Remember in 12c, you reference PDBs by their SERVICE, not the SID

Remember in 12c, you reference PDBs by their SERVICE, not the SID

Disclaimer: I’m not a VirtualBox OR Networking Guru

Trial and error, I figured this out. If you want REAL advice, try the VirtualBox forums, they’re very good.


扫码关注 微信公众号:



TEL/電話+86 13764045638
QQ 47079569