How to setup CentOS port forwarding on a VPS? - centos

I bought a VPS for my game since I was developing and hosting it on my own network. I would simple do port forwarding between my router and my machine, making the config on the router's page. Now, I don't know how to do the same thing on the VPS (SSH). I read something about iptables but Idk if it is what I'm searching for. I just want to open an UDP port. There was Apache running fine and I stopped it. What commands should I use?

I was able to fix this problem. I just shouldn't do any port forwarding, and bind the socket on the public address.

Related

How can I make my Socket server to work on WAN?

I am creating a multiplayer game using Unity Game Engine. I created my server using Socket in C#.
My server works fine on the LAN, however it doesn't work on the WAN. I learned that I need to configure port forwarding in order to make it work on the WAN. I am using a Tp-Link router, and I found a great video that helped me to setup port forwarding:
https://www.youtube.com/watch?v=2tIUts0fyFk
Things I adjusted on my own:
In the video, the person used HTTP, but I chose DNS for my Socket server. I don't really know what I should choose here.
On the client side, I changed the server IP from the IP reported by ipconfig to my router's static IP, and the server port to the port I chose while setting up port forwarding.
On the server side, I put the IP reported by ipconfig as the server IP. This is the same IP I chose as my DHCP OPTION.
I am using the UDP protocol for my game, and as I said it is working fine in my LAN network.
My problem is, even after all this, my game is not working on the WAN. I also made sure that my WAN client has his Windows Defender firewall turned off. It didn't work.

How to set up a client/server connection using port forwarding

I created a multi-threaded client/server application that can send messages to each other at real time. Everything works perfectly, but I want to be able to send messages over the Internet. From what I understand, I need to do port forwarding to be able to make my server reachable for the clients. I then set up my port forwarding options by providing a port (9991) and then my Macbook Air's IP Address (192.168.0.1).
I then tried to connect to my server using my public server IP (let's say 197.132.20.222) and it didn't work. I then tried to see if the port forwarding worked by using this website: https://www.yougetsignal.com/tools/open-ports/ and I realized that the connection was closed. I also tried the command nc -vz 197.132.20.222 9991 while running my application and the connection is refused.
I'm using a JavaFX application, and for my server side I use a ServerSocket with port 9991. For the client side, I use a Socket and set the IP Address to my public router IP Address, and I tried to connect with another PC using mobile data to use a different network.
My firewall settings are turn off, so I really don't know what is blocking my application to connect to that port. Could it be my ISP is blocking connections? I just don't understand why my ports are blocked even with no firewalls enabled.

Issue getting my web server to work from external devices

I am attempting to set up an apache2 web server on my raspberry pi. I am able to connect to it by doing http://localhost:8080 (8080 because my router blocks port 80). Although when I do http://my.pub.lic.ip:8080 the connection times out. I set up port forwarding so that requests going to my router on port 8080 go to my raspberry pi on port 8080. This does not seem to work but I'm also not sure if the port forwarding is the cause or if it is something else. Any suggestions?
Is your web server configured to listen on the network interface besides localhost?
https://httpd.apache.org/docs/2.4/bind.html
For example, to make the server accept connections on both port 80 and port 8000, on all interfaces, use:
Listen 80
Listen 8000
To make the server accept connections on port 80 for one interface, and port 8000 on another, use
Listen 192.0.2.1:80
Listen 192.0.2.5:8000
You can try using nmap by finding your router's public IP and on the raspberry pi type nmap my.pub.lic.ip This will show you what services are actually being published to the world. This gives more insight to the problem.
I got the web server up and running although for some reason it appears that my isp would only allow it to be hosted securely (as an https page)(I'm not sure if that's the right way to phrase it). To achieve this for free, I used cloudflare's ssl service. A tutorial to set it up for apache2 can be found here

Simple TCP server and client communication via public ip

Am using Netgear dgn1000 router and just planning to execute a server-client program over internet.
I switched off windows firewall. Allowed DMZ in router. Also Disabled antivirus in both the system. I don't know what else i got to do.?Please do help
Have you enabled port forwarding to the PC that the server is running on?

Connecting to Local Web Server when I am Outside my LAN

I have a web server running out of my home. I have assigned it an address such as 192.168.1.123 on port 80.
I understand that this is running on my local network. If I go to another computer on my network and type in the server's ip address, I can see the server.
Is there a way to access this server from outside my LAN?
Yes, you need to set your router to forward connections to port 80 to your internal IP address (192.168.1.123). Look for Port Forwarding on your router admin screen which I would imagine you access by going to http://192.168.1.1
Keep in mind that your ISP may block port 80 completely in which case you can run your web server on a different port (for example por 8180) and have your router forward connections to port 8180 to your internal IP.
To access your server from outside, you just need to point your browser to your external IP address which you can find out by going to http://www.ipchicken.com
Assuming you have a connection to the internet:
https://github.com/progrium/localtunnel
is a quick way to access your local server from the internet. There might be similar implementations in other languages/platforms. This is just the one I know about.
Remember that security issues need to be carefully considered when opening your local network to the world.
If you use a PHP Webserver you can set it this way:
php -S <YourIPAdresse>:<SomePortNumber> <StartPHPpage>
Example: „php -S 192.168.1.123:9000 index.php"