To open a specific port, such as 9090, in Google Compute Engine, you must create a firewall rule allowing traffic on that port.
Here’s a step-by-step guide on how to create a firewall rule in the Google Cloud Console.
Go to the Google Cloud Console: https://console.cloud.google.com/
Sign in with your Google account, and then select the appropriate project.
In the left-side menu, click on the hamburger icon (three horizontal lines) and navigate to “VPC network” > “Firewall”.
- Click on the “Create Firewall Rule” button at the top of the page.
- Fill in the following details for your new firewall rule:
- Name: Give your firewall rule a unique and descriptive name.
- Description: (Optional) Add a description for the firewall rule.
- Network: Choose the VPC network where your Google Compute Engine instances run.
- Priority: Set the priority for the rule. Lower numbers indicate higher priority.
- The direction of traffic: Select “Ingress” to allow incoming traffic.
- Action on the match: Select “Allow” to permit traffic matching the rule.
- Targets: Choose “All instances in the network” or “Specified target tags” based on your requirements. If you choose “Specified target tags,” specify the target tags you assigned to the instances you want to apply the rule.
- Source Filter: Select “IP ranges” and provide the source IP ranges you want to allow traffic. You can use “0.0.0.0/0” to allow traffic from any source, but this is not recommended for security reasons.
- Protocols and ports: Choose “Specified protocols and ports” and enter the protocol and port number you want to open. For example, to open TCP port 9090, enter “tcp:9090” (without quotes).
Click “Create” to save your new firewall rule. The rule will be applied to the specified instances, and the specified port will be opened.
Please note that opening ports to the internet can expose your instances to potential security risks. Always follow best practices for securing your instances, such as VPNs, SSH keys, and strong authentication methods.
I hope this will help you!
Amit Doshi is a Cloud Engineer who has experienced more than 5 years in AWS, Azure, and Google Cloud. He is an IT professional responsible for designing, implementing, managing, and maintaining cloud computing infrastructure, applications, and services.