Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SFTP connectivity DNS issue - System.Net.Sockets.SocketException: The requested name is valid, but no data of the requested type was found

I am trying to connect to ftp via SharpSSH as below:

Sftp Connection = new Sftp(ftpAddress, FTPLogin, FTPPasword);
Connection.Connect();

Which results in JSchException:

System.Net.Sockets.SocketException: The requested name is valid, but no data of the requested type was found
at System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6)
at System.Net.Dns.GetHostByName(String hostName)
at Tamir.SharpSsh.java.net.Socket..ctor(String host, Int32 port)
at Tamir.SharpSsh.jsch.Util.createSocket(String host, Int32 port, Int32 timeout)

After some search I tried this code:

IPHostEntry ip = Dns.GetHostEntry(ftpAddress);

And I got SocketException: {No such host is known}

Now some background - I am able to connect with Filezilla to ftpAdress with via hostname and IP address (both external and internal). When I >ping ftp.mydomain.com
I get >10.5.165.15
But on >ping -a 10.5.165.15
I get >ftpnew.mydomain.com

If I am right, I am being rejected because of DNS <> revDNS problem.

My question is - what can I do to actually have my sftp connection work.

like image 833
Piotroslav Avatar asked Dec 18 '12 15:12

Piotroslav


1 Answers

Solution was found by checking every possibility and this is how I menaged to establish connection: First my ftpAddress was set to extrernal/internal IP.

IPHostEntry ip = Dns.GetHostByName(ftpAddress);
Sftp Connection = new Sftp(ip.ToString(),FTPLogin,FTPPassword);
Connection.Connect()

It seems my error was not about DNS<>revDNS but rather due to extra '\' signs in host adress I was trying to call.

like image 127
Piotroslav Avatar answered Sep 30 '22 12:09

Piotroslav