-3

I currently have a sql server database and I want to be able to expose this over the internet so that someone external to my network can access the tables/data.

How best can I achieve this and what options do I have?

7
  • In what sense do you want to expose the database? For reading, editing and writing by end users or forming the back end of an application installed in respective end user clients? Or you want the data therein to be readable and the associated tables written to via a RESTful application? Otherwise external access would command that you have a public IP configured on the station hosting the server database or explore paid or free VPNs like Hamachi and OpenVPN
    – Frank
    Jul 19 at 22:03
  • expoing rdms to the internet, where you get 24 h a day attacks, it is a very,very dangerous idea.Every one uses REST APis for that purpose to avoid it, have had alook at taht?
    – nbk
    Jul 19 at 22:15
  • Best practice is to expose it via an API. Though it is possible to do so without one, it is considered less secure to do so. You may want to try asking this question on StackOverflow.com instead, since APIs are more programmatic in nature, and this is part infrastructure related too, depending on how specific of information you're looking for.
    – J.D.
    Jul 19 at 22:16
  • How is the database hosted? Is it running on a cloud VM or hosted on a VM / physical computer on your network?
    – KevH
    Jul 19 at 22:22
  • You most certainly do not want to expose a SQL Server instance to the internet. What you do want is to accomplish some task, and you have decided that exposing your database server to the internet is the way, which is likely wrong. If you explain what your goal is, someone might be able to suggest ways to achieve it without compromising your server and data.
    – mustaccio
    Jul 19 at 23:03
1

Echoing other comments from replies and answers I'd advise against opening up a SQL Server directly to the internet. Setting up a VPN on your network that the other person can connect to is the preferred solution.

The steps to prepare SQL Server for a remote connection via VPN or directly are mostly the same so here's how to get your server ready:

  1. Before you open any ports or expose SQL Server make sure your server is fully up to date with all service packs and cumulative updates. At the time of writing, for SQL Server 2016, this will be:

Check here to list the most recent updates just in case the above have changed.

  1. Now do the same for the Operating System and make sure all security updates are installed and the OS fully patched.

  2. The easiest way to allow remote clients or applications to connect to SQL Server is via TCP/IP so you'll need to make sure that SQL Server is set up to accept connections over TCP/IP.

    • On the Server open the SQL Server Configuration Manager. Note that on Windows 10 it may not appear in the Start Menu so launch it by entering SQLServerManager13.msc in the Start > Run box.
  3. In the SQL Server Configuration Manager select the instance that you want to allow access to under the SQL Server Network Configuration drop down. In the right window change the TCP/IP option to Enabled if it isn't already. SQL Server Configuration Manager

  4. Now you should be able to connect to the server from within your own network. If you can't The Windows firewall may need to be configured to allow connections on Port 1433 to SQL. This blog post shows how to open the windows firewall.

  5. You should now be able to forward a port from your router to the SQL Server to expose it but I won't go into details on how to do this as I don't recommend it. Now is a great time to set up a VPN instead. Wireguard is very versatile and straightforward VPN to set up.

  6. When the remote client has connected to the VPN they will be able to connect to the IP of your SQL Server on the default port of 1433.

Not the answer you're looking for? Browse other questions tagged or ask your own question.