Get ip address from stun server - stun

I have stun server on xirsys.
How can I know what is my public address + port that I can ping to it from outside the network to my pc through NAT?

Related

Port forwarding from public ip to local ip in other way

So... if i want my tcp server can be connected by other network(not just local network), i will need to setup port forwarding in my router setting page. But it's so annoying so i'm wondering is there other way to port forwarding from public IP to my local IP address.. maybe with code?

IP Address for a socket address

So I know that a socket address is the combination of an IP address and a port number, but which IP address is used for the socket address? Is it the private or the public IP address, or can it be both but you have to choose one?
A connected socket can have any IP which is local on the machine - but only one at a time. A socket which is not connected (i.e. listening socket in case of TCP) can instead also be bound the catch-all IP (0.0.0.0 for IPv4, :: for IPv6) and thus receive data on all local IP.
Running socket.gethostbyname(socket.gethostname()) will give you the IP address it is using.

Configure dnsmasq to listen on public IP instead of only LAN

I am trying to host a DNS server with dnsmasq using my Raspberry Pi. I can connect to the DNS server through LAN but I am not able to connect to it through my public IP. I already have port 53 forwarded on my router.
/etc/dnsmasq.conf:
server=1.1.1.1
server=1.0.0.1
interface=wlan0
address=/test.example.com/127.0.0.1

TCP/IP Socket Programming Static Web IP between Dynamic IP

I am confused about TCP/IP Socket Programming. I know the internet protocols but in theory...
I am explaining my problem (what i need )
I have a server working on X.X.X.X IP Adress. And it always listens to Y PORT.
When i want to connect that server on MY PC, i have no problem because i wrote the ip adress (X.X.X.X) and the port (Y) and my PC connects..
When i connect to server server keeps my ip adress and my local ip adress.. After that connection is end.
Here is my problem starting...
As i sad my server knows my local PC informations. How can i connect to my local PC on server my web server and sent TCP or UDP packets ? I did port forwarding on my modem but i dont want it. When i did port forwarding there is no problem but i dont want it ...
Thanks for replies and sorry for my engislih if i have mistakes .
If a router/NAT sits between your server and an outside client, you MUST use port forwarding on the router. The outside client will NOT be connecting to your server's private LAN IP/Port directly, it will be connecting to the router's public WAN IP/Port instead. So the router needs to know to forward inbound packets to that IP/Port to the server's private LAN IP/Port.
A client running on your local PC is able to connect to the server because they are both on the same LAN side of the router, so the connection is direct and does not go through the router's WAN. That is not the case for clients that are on the WAN side of the router.

Client and Server public IP

Settings
Router huawei HG532b configured to forward port = 50111 by enable NAT > DMZ and put
Host address IP = 192.168.1.5 , and that is static IP of my PC in the Network.
the router configured to forward port = 50111 by mapping the port by NAT > Port Mapping with following settings:
Protocol = TCP/UDP, External port = 50111, Internal port = 50111,
Internal host = 192.168.1.5, Remote host = 192.168.1.5, Mapping
name=Chat.
the router configured to forward port = 50111 by triggering the port by NAT > Port Triggering with following settings:
Trigger protocol = TCP/UDP, Trigger start port = 50111, Trigger end
port = 50111, Open start port = 50111, Open end port = 50111, Trigger
name=Chat
The router have public or external or WAN IP = 188.167.2.4.
The router configured to enable UPnP.
The router configured LAN > DHCP by make Start IP address = 192.168.1.6, End
IP address = 192.168.1.253
The router is my Gateway with IP = 192.168.1.1.
My PC have static IP = 192.168.1.5, and the firewall service is off, and there is no antivirus installed or any other firewall, and I have XP with service pack 3.
Problem:
I Created two programs, Client and Server, they are parts of the chat program.
Server's socket have LocalPort = 50111 and put to Listen mode.
Client's socket have RemotePort = 50111, and have text box to put the remote IP in it and Command button called Connect.
When I test the Client and Server in the same PC that have Static IP = 192.168.1.5 and put the remote IP in Client = 192.168.1.5, everything go fine.
When I test the Server in the PC that have Static IP = 192.168.1.5 and put Client in PC with IP = 192.168.1.9 and put the remote IP in Client = 192.168.1.5, everything go fine.
When I test the Client and Sever in the same PC that have Static IP = 192.168.1.5 and put the remote IP in Client = 188.167.2.4 (that is my router public or external or WAN IP), and press Connect, the winsock error "connection is forcefully rejected" is raised.
When I test the Server in the PC that have Static IP = 192.168.1.5 and put Client in PC with IP = 192.168.1.9 and put the remote IP in Client = 188.167.2.4 (that is my router public or external or WAN IP), and press Connect, the winsock error "connection is forcefully rejected" is raised.
When I test the Server in the PC that have Static IP = 192.168.1.5 and put Client in PC in another network with IP = 192.168.1.7 and put the remote IP in Client = 188.167.2.4 (that is my router public or external or WAN IP), and press Connect, the winsock error timout is raised.
I read that if the Client and Server in the same PC, setting the Client remote IP to public or external or WAN IP will not work.
I read that the XP with service pack 3 have issue with port forwarding.
I read that there is a technique called hole punching, that can round over router port forwarding or firewall.
I want an expert to explain to me, what is wrong and how to correct it.
From looking at your tests you are experiencing problems from with out side your own private network. There are two possibilties that could be giving you problems and its more likely to be your port forwarding thats causing the issue
1: Port forwarding && DMZDMZ is something you don't want in this case as thats another layer of security on top of the security thats all ready active on your router and will give you those rufused connections. Look at the following page on how to set up port forarding
http://portforward.com/english/routers/port_forwarding/Huawei/HG532b/Xbox_Live_360.htm
Setup the one rule with the following information
External port: 50111
Internal port: 50111
Internal host: 192.168.1.5
Protocol: This can be set to TCP/UDP, if you are using both in your application then thats fine but if you are using just the one then best to set this to the one your are using.
2: External IPFrom time to time your router will drop connection from the internet and re-connect and on occasions your external ip address can change, check with https://www.whatismyip.com/ to see if the ip address has changed. If you are looking for the bigger picture with your application then may be worth looking into getting dynamic address, have a look at this for more information http://www.noip.com/support/knowledgebase/what-is-a-dynamic-ip-address/
Hopefully this helps you