0

I am trying to connect to a remote SQL Server 2008 from a bash file in a Ubuntu 14.04. I am using FreeTDS and the tsql command to do so.

When I am in the same network as the SQL Server, I can access it using its local ip 192.168.0.2, using the following command:

tsql -S 192.168.0.2 -U <user> -P <password> 

The problem is when I try to connect using an IPv6. tsql doesn't seem to recognize the IPv6 I got. Here is what I get when trying to connect (the ip is anonymized):

tsql -S fe80::c74a:ada5:be2e:255f%11 

Here is the result:

Error 20012 (severity 2):
Server name not found in configuration files.
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Error 20013 (severity 2):
Unknown host machine name.
There was a problem connecting to the server

What am I doing wrong here? Any help is appreciated

Gabriel Ilharco
  • 1,649
  • 1
  • 21
  • 34
  • cant you use the actual server name (fully qualified) rather than the IP address? – Fuzzy Jan 19 '16 at 17:20
  • It will be . – Fuzzy Jan 19 '16 at 17:40
  • I'm getting the same error – Gabriel Ilharco Jan 19 '16 at 17:46
  • can you ping the server from where you are trying to access the server? – Fuzzy Jan 19 '16 at 17:46
  • I'm getting 'network is unreachable' when I try to ping it – Gabriel Ilharco Jan 19 '16 at 17:50
  • so you cannot even reach the server. do you have an external IP address you can use and has that server been set up for remote connection. You might want to talk to your DBA/System Admin to get the issue resolved. You might want to have a look at this as well. https://msdn.microsoft.com/en-CA/library/ms191464.aspx – Fuzzy Jan 19 '16 at 18:03
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/101113/discussion-between-gabriel-ilharco-and-kamran-farzami). – Gabriel Ilharco Jan 19 '16 at 18:06
  • Check SQL Server Configuration Manager. The instance may not be bound to the IPv6 address. Check Protocols under SQL Server Network Configuration. – Bacon Bits Jan 19 '16 at 22:05
  • 1
    Ping may be disabled on your network. If you can, see if you can cannot to SQL Server via telnet: `telnet yourserver.com 1433` If it connects, you're good, if it is just hanging trying to connect, you may need to get the proper IP address / server name, or configure a firewall to allow the remote machine to connect over port 1433 (the default SQL Server port). – FlipperPA Jan 20 '16 at 13:53
  • What do you mean "remotely"? 192.x.x.x isn't a local address, which means you can already connect remotely to the server. Are you trying to connect to another network entirely? Do you require a VPN for this? Have you established a connection with that other network at all? What does `traceroute` report for the remote IP ? – Panagiotis Kanavos Jan 20 '16 at 15:00
  • 1
    *Does* your own network support IPv6? The address you originally used is IPv4. – Panagiotis Kanavos Jan 20 '16 at 15:03
  • Yep, that was it, @PanagiotisKanavos. Upgraded it to the latest version on github and it worked. Thanks a lot (please post your answer so I can accept it). – Gabriel Ilharco Jan 20 '16 at 15:47

1 Answers1

0

The problem was that I was using freetds v0.91 (which was the latest version on apt-get), which does not have support for IPv6. I upgraded to the latest version, which can be found here. Any version above v0.95 should be fine.

Gabriel Ilharco
  • 1,649
  • 1
  • 21
  • 34
  • Debian? The other distributions actually have a newer version. An [ODBC driver by Microsoft](https://technet.microsoft.com/en-us/library/hh568451(v=sql.110).aspx) is also available for Redhat, SUSE and Ubuntu. You should have specified that you are using Linux *and* the distribution – Panagiotis Kanavos Jan 20 '16 at 15:39