How to enable port for public access? - tcp

I have enabled 1 port [8081] and it's accessible from the remote computer. but the same for other port [7500] not working?
I would like to know the meaning of the below line?
TCP [::]:8081 [::]:0 LISTENING
And how to enable the same for port [7500]?
Attached listening port status:

netstat -na outputs 4 columns of data:
Proto, Local Address, Foreign Address, and State.
When looking for port 8081, you find 2 entries - one for TCP on 0.0.0.0:8081 for IPv4, and one for TCP [::]:8081 for IPv6.
When looking for port 7500, you find 1 entry - one for TCP 0.0.0.0:7500 for IPv4 only.
In both cases, you have local sockets listening via wildcard IPs to all local network adapters, and there is no "Foriegn Address" assigned because a listening socket is not connected to any remote party. TCP sockets in the ESTABLISHED state have remote parties.
You have not shown any code, or explained your network setup, so nobody can really explain why you have 2 entries for port 8081 but only 1 entry for port 7500, or why remote computers can connect to port 8081 but not to port 7500. Maybe those clients are only using IPv6? Maybe your listening computer is behind a router that doesn't forward port 7500? We don't know.

Related

2 applications on the same port

I have an interesting scenario where 2 applications are listening to the same port. One on the loop-back address and one on the invalid address.
My understanding is that only one application can listen to a port at a time. So, how is this possible?
Proto Local Address Foreign Address State PID
TCP 0.0.0.0:10006 0.0.0.0:0 LISTENING 1772
TCP 127.0.0.1:10006 0.0.0.0:0 LISTENING 3876
Both were started under the system account and both are running fine, but if I switch one to a local user then the that application fails to start. If I switch both to local user then both starts fine. It seems if both are in the same user context then both are able to run fine.
0.0.0.0 means all IPv4 addresses on the local machine. So if the machine has multiple network addresses, it will serve all of those.
The loopback is distinct from that, so it's legal to be listening on the same port but different adapters.

Port and IP address - what does bind mean?

I read on Ports WIKI page that "Ports are logical constructs which identifies a service or process", what service or process means here? It means protocol like HTTP, FTP etc. or software applications which are configured to listen on that port?
When it is said that application is listening on so and so... then does it listen for request to an IP address or a port, or listens on a combination of port and IP address? Application listen for a specific IP address and one or more ports are bound to it OR it listens for a combination of IP and port?
For example, I can have application configured for 7001 for HTTP requests and 7002 for HTTPS requests. So, would be listening on 7001 or what?
Applications/services such as a HTTP web server or an FTP server are assigned a port to use/listen on, usually in the config of the application. and they often use a standard port. HTTP for example usually uses port 80.
If an app/service is listening it listens to a port and has no relation to a specific IP address. This is because the IP address it is listening on is the IP address of the computer that the app/service it is running on.

Sending Udp on port 8080?

Is it possible to send/receive udp over port 8080? Everything I see says 8080 is strictly a TCP port. I don't quite get why that would be?
Port 8080 is used by TCP or UDP. There is no restriction of Kernel for opening ports 8080 UDP. What happens is that there is a convention to use port 8080 as TCP, like squid proxy, but nothing prevents you from using UDP in it.

conncetion asterisk from outside network via sip

I have asterisk in a server having public ip. I am trying to asterisk from outside network from a sip phone(zoipar). I have opened the port 5060 on my router which is the default udp port for asterisk sip connection and i have also opened the 10000-20000 port for rtp defined in rtp.conf in asterisk.
When i m trying to connect my softphone to asterisk server from outside my network, it says Registration timeout and when i check if i got any hit on my port 5060, its doesnt show anything.
on my server 5060 is running
netstat -nlp | grep 5060
udp 0 0 0.0.0.0:5060 0.0.0.0:* 21768/asterisk
BTW I'm able to connect from local network without any problem .
You need to forward incoming traffic on your router from SIP and RTP to your asterisk server, it's not enough to open those ports, you need to explain your router where to send incoming traffic ton those ports
You need setup NAT.
This article will help you in your situation.
http://www.voip-info.org/wiki/view/Asterisk+sip+nat
You need to login to your router and forward the ports to your asterisk server internal IP.
You will also need to make sure your firewall on your server is setup correctly to allow the ports to go in and out of your server.
You can read more on iptables here: http://www.cyberciti.biz/tips/linux-iptables-examples.html

What happens when 2 computers listen to the same port and a router receives a packet through that port

What I am asking is if two computers listen to the same port and a packet of information enters the router through the WAN Ip and the same port. Would the packet go to both computers? Neither? One or the other?
IE
computer 1 -(internal IP)-> 192.168.1.3 -(listens to port)-> 4444
computer 2 -(internal IP)-> 192.168.1.2 -(listens to port)-> 4444
computer 3 -(connects and sends)-> 24.157.358.45:4444
packet -> computer 1 AND computer 2
The code in VB6 is:
LAN.LocalPort = 4444
LAN.Protocol = sckTCPProtocol
LAN.Listen
I am using a WinSock object in the Microsoft WinSock Control 6.0 in VB6 Professional
If there is something that needs to be clarified I would be more than happy to.
The router won't send an inbound packet to either machine unless communication has already been established.
If 192.168.1.3 calls out to some other machine (e.g. 4.5.6.7) from its port 4444, the router will assign an arbitrary port on its external address (say 24.157.358.45 [sic] :5555) and pass the packets on to 4.5.6.7. 4.5.6.7 will send reply packets to 24.157.358.45:5555 -- because that's the only address it knows about -- and the router will relay those to 192.168.1.3:4444.
That's the normal course of things, but there are a lot of additional details to this scheme that make it possible to establish communication with a machine behind a router via trickery.
The system of having machines with private IP addresses behind a router with a public address is called network address translation (NAT); it's a pretty deep topic.
From my knowledge of routers, unless port forwarding is setup, the router will discard any packets sent on that port.
If port forwarding is setup, only one of the computers could be setup to receive the packets.
If the packet is an inbound request to establish a new TCP connection with a server that is running behind the router, the router must have an explicit port-forwarding rule configured, either statically in the router's configuration or dynamically via uPNP or SNMP, that tells the router where to route inbound packets on 24.157.358.45:4444 to, either to 192.168.1.2:4444 or to 192.168.1.3:4444, otherwise the packet will be discarded. So no, both of your listening servers will not see the same packet.
Once a TCP connection is established, the router knows which specific LAN machines are associated with which connections and will route incoming packets belonging to those connections accordingly.
The previous answers are correct, you need to enable port forwarding. If it is not enabled port 4444 will be closed on the router.
It sounds like you have multiple servers and want to forward to whatever server is turned on at the moment. This is not possible (*), the router does not care whether or not PC1 or PC2 are listening on port 4444, it will simply forward everything to the address configured in the port forwarding.
(*): Ok it is possible but it takes some extra work.
Solution 1: Trick the router into thinking there is only one server. Give PC1 and PC2 a virtual network interface with the same IP address and forward to that address. Make sure only one of these interfaces is enabled, having duplicate IP addresses in your network can have unintentional behaviour.
Solution 2: Make the router care about which server is on. You will need to write a program to run on the router (or on another server) that can detect which server is on and forward the packets accordingly. If you are using Linux the program iptables can be worth looking at.

Resources