Wednesday, January 20, 2016

Modifying firewall rule of Google Cloud VM with command line tools.

Here's how to modify and add port 1522 to an already defined firewall rule named "allow-tns" of a Google Cloud VM.

root@sysdba:~$ gcloud compute firewall-rules list
NAME NETWORK SRC_RANGES RULES SRC_TAGS TARGET_TAGS
allow-agent default 0.0.0.0/0 tcp:3872
allow-bipub default 0.0.0.0/0 tcp:9803
allow-oms default 0.0.0.0/0 tcp:7803
allow-ons default 0.0.0.0/0 tcp:2016
allow-tns default 0.0.0.0/0 tcp:1521
default-allow-http default 0.0.0.0/0 tcp:80 http-server
default-allow-https default 0.0.0.0/0 tcp:443 https-server
default-allow-icmp default 0.0.0.0/0 icmp
default-allow-internal default 10.240.0.0/16 tcp:0-65535,udp:0-65535,icmp
default-allow-rdp default 0.0.0.0/0 tcp:3389
default-allow-ssh default 0.0.0.0/0 tcp:22
root@sysdba:~$ nmap -A em13c -p 1521-1522
Starting Nmap 6.47 ( http://nmap.org ) at 2016-01-20 10:25 EST
Nmap scan report for em13c (xxx.xxx.xx.xx)
Host is up (0.037s latency).
PORT STATE SERVICE VERSION
1521/tcp open oracle-tns Oracle TNS Listener
1522/tcp filtered rna-lm
Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 7.55 seconds
root@sysdba:~$ gcloud compute firewall-rules update allow-tns --allow tcp:1521-1522
Updated [https://www.googleapis.com/compute/v1/projects/sysdba/global/firewalls/allow-tns].
root@sysdba:~$ gcloud compute firewall-rules list
NAME NETWORK SRC_RANGES RULES SRC_TAGS TARGET_TAGS
allow-agent default 0.0.0.0/0 tcp:3872
allow-bipub default 0.0.0.0/0 tcp:9803
allow-oms default 0.0.0.0/0 tcp:7803
allow-ons default 0.0.0.0/0 tcp:2016
allow-tns default 0.0.0.0/0 tcp:1521-1522
default-allow-http default 0.0.0.0/0 tcp:80 http-server
default-allow-https default 0.0.0.0/0 tcp:443 https-server
default-allow-icmp default 0.0.0.0/0 icmp
default-allow-internal default 10.240.0.0/16 tcp:0-65535,udp:0-65535,icmp
default-allow-rdp default 0.0.0.0/0 tcp:3389
default-allow-ssh default 0.0.0.0/0 tcp:22
root@sysdba:~$ nmap -A em13c -p 1521-1522
Starting Nmap 6.47 ( http://nmap.org ) at 2016-01-20 10:24 EST
Nmap scan report for em13c (xxx.xxx.xx.xx)
Host is up (0.037s latency).
PORT STATE SERVICE VERSION
1521/tcp open oracle-tns Oracle TNS Listener
1522/tcp open oracle-tns Oracle TNS Listener
Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 6.35 seconds
view raw gistfile1.txt hosted with ❤ by GitHub
And the links to gcloud commands ...

gcloud compute firewall-rules list
gcloud compute firewall-rules update

No comments:

Post a Comment