Remote Desktop Connection between PCs -- Must they both be in the same Subnet?

AI Thread Summary
Remote Desktop Protocol (RDP) connections typically require both devices to be on the same local area network (LAN), although there are workarounds for remote access, such as using VPNs or port forwarding. Users have noted that TeamViewer and AnyDesk are often preferred for remote connections due to their ease of setup compared to RDP. When attempting to connect to SQL Server, issues often arise from misconfigurations, such as not enabling TCP/IP or named pipes in the server properties. For remote SQL Server access, proper configuration and understanding of network protocols are essential, as errors can indicate deeper connectivity issues. Overall, while RDP can be used for remote connections, alternative methods may be more user-friendly and secure.
WWGD
Science Advisor
Homework Helper
Messages
7,700
Reaction score
12,724
TL;DR Summary
Trying to connect desktop-desktop or device-device remotely.
Hi, just looking at RDP connections
https://support.microsoft.com/en-us/help/4028379/windows-10-how-to-use-remote-desktop

It would seem the two devices would have to be within the same LAN, right? Otherwise, how is just the computer name enough information to set up a connection? It seems for a connection string we would need to know more details than just the name (I doubt all the needed information is encoded under the computer name)
 
Computer science news on Phys.org
  • Like
Likes WWGD
Wrichik Basu said:
You are right, both computers need to be on the same network. But there are some workarounds too; see this site, for example:
https://www.howtogeek.com/131961/how-to-access-windows-remote-desktop-over-the-internet/

I personally prefer Teamviewer for remote connections compared to Windows remote desktop. The former is easier to set up compared to the latter, especially when the machines are not on the same network.
Thank you, I agree and have tried it but I am following up on a list for a data job interview. Same for using Python Jupyter/Anaconda.

Would a connection string allow you to connect outside of the LAN/Subnet (EDIT: if permissions were granted)?
 
I am having some strange issues trying to access my SQL Server from within the command line; cannot use ODBC because my SQL Server is connecting through named pipes. Maybe I can go to configuration manager or Control Panel and change the protocols used.
 
Remote desktop is not the way forward here.

WWGD said:
... my SQL Server is connecting through named pipes.
This does not make sense - your SQL Server instance doesn't have to connect to anything. Do you mean you are using named pipes to connect a SQL Studio instance to your SQL Server instance?

Named pipes are only used for connecting locally i.e. on the same machine. Do you already know how to connect from another machine over the LAN? Connecting from a remote network is the same, except you need to let your router know what to let through and where to connect it to - this is called port forwarding. This is a home setup with a direct connection to the internet right? You aren't behind some corporate or other firewall?

What are you actually trying to do?
 
pbuk said:
Remote desktop is not the way forward here.This does not make sense - your SQL Server instance doesn't have to connect to anything. Do you mean you are using named pipes to connect a SQL Studio instance to your SQL Server instance?

Named pipes are only used for connecting locally i.e. on the same machine. Do you already know how to connect from another machine over the LAN? Connecting from a remote network is the same, except you need to let your router know what to let through and where to connect it to - this is called port forwarding. This is a home setup with a direct connection to the internet right? You aren't behind some corporate or other firewall?

What are you actually trying to do?
I was trying to access SQL Server from the command line within the same machine.

Error message was:
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Named Pipes Provider: Could not open a connection to SQL Server
 
How do you know the SQL Server instance is running?
 
WWGD said:
I was trying to access SQL Server from the command line within the same machine.
If you can't do that then the last thing you want to do is introduce other variables by trying to connect from outside the LAN.
 
  • #10
pbuk said:
How do you know the SQL Server instance is running?
I started it through MSSM.
 
  • #11
pbuk said:
If you can't do that then the last thing you want to do is introduce other variables by trying to connect from outside the LAN.
I understand, thanks, I was also trying to connect locally; all part of interview skills list. I don't have access to another computer to try remote access. Sorry for my sloppy way of doing things; seems confusing to all but me :).
 
  • #12
WWGD said:
I started it through MSSM.
What is shown in the Named Pipes Properties dialog box in MSSM SSMS?

Edit: and what connection string are you using:
Code:
\\.\pipe\sql\query
?
 
  • Like
Likes WWGD
  • #13
pbuk said:
If you can't do that then the last thing you want to do is introduce other variables by trying to connect from outside the LAN.
I understand, thanks, I was also trying to connect locally; all part of interview skills list. I don't have access to another computer to try remote access.
The network protocol is set to <default> and options are not enabled:

1579225147558.png
 
  • #14
Hmmm, dunno, sorry :frown:

If you just want to play with a SQL Server instance you could open an Azure account?
 
  • #15
pbuk said:
Hmmm, dunno, sorry :frown:

If you just want to play with a SQL Server instance you could open an Azure account?
Hey, nothing to be sorry about; I've learned more from you in a few weeks than in years. Seriously, thanks so much. Will check out Azure.
 
  • #17
rbelli1 said:
Use the VPN option in that link. If you use the port forwarding option you will very quickly be hacked.

BoB
True but , it takes $$$ for quality VPN last I checked.
 
Last edited:
  • #18
WWGD said:
True but , it takes $$$$ for quality VPN last I checked.
Lol. . . what went wrong with your post ?

It should look like this. . . . 🤔

1579246059993.png


.
 
  • #19
OCR said:
Lol. . . what went wrong with your post ?

It should look like this. . . . 🤔

View attachment 255701

.
No clue. Did you guess it or how else you figured?
 
  • #20
WWGD said:
Did you guess it or how else you figured?
Refresh the page and watch. . . 😉

.
 
  • Like
Likes WWGD
  • #21
OCR said:
Lol. . . what went wrong with your post ?

It should look like this. . . . 🤔

View attachment 255701

.
$$ is the delimiter for a ## \LaTeX ## block so $$$$ is parsed as an empty block of ## \LaTeX ##. Use $$$ which stays as $$$.
 
  • Like
Likes WWGD
  • #22
Thanks, got it, but fittingly not a single $ appeared ;).
 
  • Like
Likes pbuk
  • #23
pbuk said:
Use $$$ which stays as $$$.
Unless $$$ you use it twice $$$ of course! Unless $$$ you use it twice $$$ of course!
 
  • Like
Likes WWGD
  • #24
rbelli1 said:
Use the VPN option in that link. If you use the port forwarding option you will very quickly be hacked.

BoB
How about portforwarding to a VM?
 
  • #25
WWGD said:
True but , it takes $$$ for quality VPN last I checked.

I was thinking that you could set up a VPN on your firewall. Use client certificates for the best security.

BoB
 
  • #26
rbelli1 said:
I was thinking that you could set up a VPN on your firewall. Use client certificates for the best security.

BoB
Aren't quality VPNs expensive?
 
  • #27
WWGD said:
Aren't quality VPNs expensive?
pbuk said:
Unless you use it twice of course!
Only if you use it twice. . . . 😛 .
Lol. . . . 🤦‍♂️

.
 
  • #28
OCR said:
Only if you use it twice. . . . 😛 .
Lol. . . . 🤦‍♂️

.
Actually, any odd numbers will do. I will print dollars signs 1,2,3,4,5,6. Let's see which show up:
1)$
2)$$
3)$$$
4)$$$$
5)$$$$$
 
  • #29
WWGD said:
How about portforwarding to a VM?
If you can't even access it on the same machine/VM then how are you going to access it remotely? Just to check a couple of things, you are running this console in the same OS instance as the SQL Server, yes? Or are you running the console on a host and the SQL Server instance in a VM - in which case local named pipes won't work? Have you tried accessing via a port i.e. localhost:1433?

Also, I can't see the important setting in the screenshot below:
WWGD said:
... the crucial setting is in the 'Server Properties' dialog box hidden under the 'Connection Properties' box. If you select 'Connections' it should show a list including 'Named Pipes: Enabled', and 'TCP/IP: Enabled' if you want to access via a port (i.e. localhost:1433).
 
  • #30
In other words, try all of the following in a console on whatever OS instance is running SQL Server.
Code:
sqlcmd
sqlcmd –S tcp:127.0.0.1,1433
sqlcmd –S np:\\127.0.0.1\pipe\sql\query
 
  • #31
Thanks, I thought I had included the server properties; clearly not. Coffee shop closed for today, will post ASAP

v
 
  • #32
For something very straightforward and with no technicalities, I use a program called anydesk. Very sweet if you ask me.
 
  • Like
Likes WWGD
  • #33
WWGD said:
True but , it takes $$$ for quality VPN last I checked.

Some VPNs provide a small amount of traffic at no charge. I've used the free tier of Windscribe and TunnelBear before, and they are okay for testing, at least.

But I agree with @rbelli1, using RDP without really understanding what you are doing is a quick way to be hacked...and you won't even know it!

There are numerous bad actors polling the internet looking for poorly protected machines to attack - I set up a Linux server on Azure for a project with an IP that was not advertised and within a day the root user account was being pinged at the rate of two password tries every second.
 
  • #34
Tghu Verd said:
I set up a Linux server on Azure for a project with an IP that was not advertised and within a day the root user account was being pinged at the rate of two password tries every second.
Never enable password login on a public machine, login should be by public key only.
 
  • #35
pbuk said:
Never enable password login on a public machine, login should be by public key only.

Correct, and this wasn't. But that does not stop attackers from trying root...and other common system user names.
 
  • #36
@pbuk : Sorry for the delay. Here are the server properties of my instance: Upper half of default connection settings re allowing named pipes to use ODBC:

1579557085498.png


1579557180635.png
 
  • #37
Remember the error came about when I was trying to access my instance through sqlcmd in the command line. I just need, for my interview, to know how to access SQL Server without using SSMS, so I may also give Pyodbc a shot, so don't worry of you're too busy; you have helped me plenty as it is.

EDIT: Error message when trying to use sqlcmd to connect:

Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Named Pipes Provider: Could not open a connection to SQL Server [2]. .
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
 
  • #38
WWGD said:
Remember the error came about when I was trying to access my instance through sqlcmd in the command line. I just need, for my interview, to know how to access SQL Server without using SSMS, so I may also give Pyodbc a shot, so don't worry of you're too busy; you have helped me plenty as it is.
pyodbc is not going to help, the problem the error messages are telling you is that that the ODBC driver cannot connect to SQL Server so pyodbc -> ODBC -> SQL Server will have exactly the same problem as sqlcmd -> ODBC -> SQL Server.

I think the fundamental problem is that you are exposing yourself to a lot of stuff you don't need to know how to do - set up and mangage connections to a MS SQL Server instance. And the deeper you go, the deeper you are getting into unrelated stuff like network protocols. It's like building an aeroplane yourself from a set of blueprints when what you really want to do is learn to fly!

A last stab in the dark, I'm not convinced that your server is exposing a named pipes connection, have you tried just connecting to the server DESKTOP-QH...\PYTHONRSQLSERVER, or possibly just DESKTOP-QH..., or possibly with the default SQL Server port number DESKTOP-QH...,1466
 
  • Like
Likes WWGD
  • #39
pbuk said:
pyodbc is not going to help, the problem the error messages are telling you is that that the ODBC driver cannot connect to SQL Server so pyodbc -> ODBC -> SQL Server will have exactly the same problem as sqlcmd -> ODBC -> SQL Server.

I think the fundamental problem is that you are exposing yourself to a lot of stuff you don't need to know how to do - set up and mangage connections to a MS SQL Server instance. And the deeper you go, the deeper you are getting into unrelated stuff like network protocols. It's like building an aeroplane yourself from a set of blueprints when what you really want to do is learn to fly!

A last stab in the dark, I'm not convinced that your server is exposing a named pipes connection, have you tried just connecting to the server DESKTOP-QH...\PYTHONRSQLSERVER, or possibly just DESKTOP-QH..., or possibly with the default SQL Server port number DESKTOP-QH...,1466
Thanks, I can connect through SSMS and have done queries, etc, but I am trying to connect from outside of SSMS and, of course, learn whatever possible. EDIT: As part of a list of reqs given for a Data job.
 
  • #40
WWGD said:
Thanks, I can connect through SSMS and have done queries, etc, but I am trying to connect from outside of SSMS and, of course, learn whatever possible.
Yes but SSMS does not use ODBC so to get ODBC working you need to tell the ODBC Driver to connect to the same connection as SSMS is using, which is the one at the bottom of the window and it doesn't seem to be a named pipe.
 
  • Like
Likes WWGD
Back
Top