Author’s note: in the current Developer Day image, port forwarding on 1521 is there out-of-the-box for easy connections to your Database.
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.
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.
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:192.168.0.18 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fe22:794f/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 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 192.168.0.18, probably.
Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\jdsmith>ping 192.168.0.18 Pinging 192.168.0.18 with 32 bytes of data: Reply from 192.168.0.18: bytes=32 time<1ms TTL=64 Reply from 192.168.0.18: bytes=32 time<1ms TTL=64 Reply from 192.168.0.18: bytes=32 time<1ms TTL=64 Ping statistics for 192.168.0.18: Packets: Sent = 3, Received = 3, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms Control-C
Let’s see what happens in SQL Developer.
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?
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.
You remembered to open up port 1521 in the Linux Firewall, yes? Good.
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.