Difference between linux network connection errors - linux

I've been coding a port scanner in Rust, and for detecting open ports what I do is create a TcpStream and try to connect to different ports on a given host to see if it allows the connection.
The problem I'm having is that when the connection fails, the OS (Linux) returns one of three codes:
101 - It is displayed if network is unreachable.
111 - It is displayed if connection is refused.
113 - It is displayed if there is no route to host.
And I've been looking for in-depth explanations of each error and what causes them, but I just find the same text over and over again.

Network unreachable ā†’ most likely explanation is that your computer is not connected to any network (Wi-Fi down, ethernet unplugged, ā€¦)
Connection refused means that you were able to reach the target computer, but that it refused the connection ā†’ no application is listening on the requested port on the other computer, or the firewall blocked the connection.
No route to host means that you were unable to reach the target computer. Either it is off, or there is a problem somewhere in the network between your computer and the target.

Related

How do I connect two computers using the same router?

Iā€™m using the python socket module on a Mac.
How do I connect two computers using the same router? I need a TCP socket with fast data passing between.
When I tried just hooking two computers up by their private ip address, then I got a Connection Refused error. How do I do this?
You can check first whether connection is allowed between two devices by going to one device and running telnet.
telnet <Private-IP-of-Second-Device> <Port>
If this shows connected then connectivity is good and issue exists with the socket module you have written.
If this fails you can try checking the firewall by going to System Preferences > Security & Privacy > Firewall.

I can't do connection with 3270 port

I have just installed a mainframe emulator and I have problems for running it. I think the problem is my 3270 TCP port. Reading a guide I found somebody say that you can do this:
telnet 127.0.0.1 3270
but when I try the answer is:
The connection to the host it can't be opened with port 3270 more or less
(I have windows in spanish) . Error on the connection.
Do you know how can I get connection with this direction and this port?
If I understand you correctly, you are trying to eliminate issues with your 3270 emulator configuration by attempting to telnet to the mainframe from the PC. Again, if my understanding is correct, then you need to use
telnet <ip or hostname of the mainframe>
In your example, you are using the local loopback address.
It is unlikely that you should be using port 3270. 3270 connections are typically configured on port 23, which is the default telnet port.
If the connection to the mainframe is successful, you can input any character string in the terminal and then press Enter.
An error such as this:
IKJ56710I INVALID USERID,xxxx
Will validate the fact that the port is open and that your emulator issues are down to something other than network problems (probably local configuration).

increase ssh timeout

I'm trying to connect to a mobile host connected over a 3G cell router from linux with
ssh root#74.198.25.XXX -p 2200
and all I immediately get is (doesn't even seem to run into a timeout)
ssh: connect to host 74.198.25.220 port 2200: Network is unreachable
However, when I try the same IP on port 2200 with putty on Windows, it presents my with the password prompt just fine as I'd expect.
What's going on here, do I need to increment my ssh timeout period to get this going or what?
Thank you,
Ron
Network unreachable implies the following:
The host is not on your local network
The network the host is on is not reachable from your local network
The reason for this could be many, but things to check would be:
Ensure that the device you're connecting from has a proper network connection
Ensure that the device you're connecting from has a proper gateway setup
Ensure that the device you're connecting from has a route leading to the target (Normally sorted by the abvoe)
Ensure that there's nothing between you and the target device firewalling port 2200

Only port 80 works for websites

I hosting a dedicated Server(win2008 Standart). IIS is installed. There are several Websites bound to different ports(eg SharepointServicesCentralAdministration to 17012).
Every website work well if is bound to port 80 but if i change the port i get timeout (connection via internet) - local it works well.
(Hardware and software firewall are down.)
For some additional test a c# TcpClient Instance is listening on port 12345. If i try connect via internet i get exception:
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond xxx.xxx.xxx.xxx:12345 - seems the same issue...
Any idea what could be wrong?
You most likely have port 80 forwarded to your machine from your internet bordering router/firewall.
You would need to have the other ports forwarded as well in your router/firewall for these other ports to work.
This also assumes you already opened the local firewall ports as you mentioned above, which is also required!
Is it possible for other computers in the local subnet to connect? Probably only the local subnet is allowed. The setting needed for ip-restrictions has to be installed: http://www.hrzdata.com/node/46

Multiple VPN connections behind NAT

I have the following problem:
I have Windows 2003 RAS VPN server configured with a single Nic (let's call it LAN1) behind a firewall (lets call it's public address WAN1). PPTP & L2TP ports are forwarded to the Server.
When a client (Windows or LINUX) in a remote network behind a firewall (LAN2) tries to connect to a PPTP VPN on the WAN1 everything goes fine.
When a second client in the same LAN2 tries to connect to the same VPN on the same WAN1 I get an error 629.
It's independant of which machine gets the first connection.
Apparently the problem is also independant of the router/firewall hardware of LAN2 (We have tested it from at least five different types of remote small router/firewalls - linksys, huawey, d-link, etc.)
The firewall WAN1 listens to two internet connections. The problem is independant of which external address the clients are pointing to (even if two different workstations point to different IP addresses to attempt to stablish a vpn).
Inside LAN1, there is no such limitation and multiple workstations connect just fine.
Theres also no limitation from different remote LANs.
Is this a limitation of PPTP protocol?
Thanx in advance.
From your description it sounds like the issue is at the remote end. You mention that when a second user from LAN2 attempts to reach the same VPN server at WAN1 you receive an error.
Depending on the firewall mechanism in use there can be a "limitation" that exists with regard to PPTP connection tracking and multiple VPN connections to the same server address.
Google: pptp multiple connections to same ip
Due to the way in which NAT tracks PPTP connections, specific modules need to be loaded in order to handle multiple connections to a single server.
If it's netfilter based, make sure 'nf_conntrack_pptp' and 'nf_nat_pptp' are loaded.

Resources