Assume we have an instance ID and wanted to list out the rules added to the instance. The below command will list out the all ingress and egress rule with the ports and all the security group attached to that instance from the neutron DataBase.
# source <rc file>
#instance_id=411ddccxx-dcc8-4cc6-9c9a-xxxxxxxx
# sec_group_ids=`nova list-secgroup $instance_id | tail -n +4 | awk {'print $2'} | sed -e '$ d' | xargs | sed -e 's/ /","/' `
# sec_group_ids=`echo \(\"$sec_group_ids\"\)`
# mysql -B -e "select port_range_min,port_range_max,ethertype,direction,protocol from securitygrouprules where security_group_id IN $sec_group_ids order by port_range_min ASC" neutron
port_range_min port_range_max ethertype direction protocol
NULL NULL IPv6 ingress NULL
NULL NULL IPv4 ingress icmp
NULL NULL IPv4 ingress NULL
NULL NULL IPv6 egress NULL
22 22 IPv4 ingress tcp
80 80 IPv4 ingress tcp
9999 9999 IPv4 ingress tcp
# source <rc file>
#instance_id=411ddccxx-dcc8-4cc6-9c9a-xxxxxxxx
# sec_group_ids=`nova list-secgroup $instance_id | tail -n +4 | awk {'print $2'} | sed -e '$ d' | xargs | sed -e 's/ /","/' `
# sec_group_ids=`echo \(\"$sec_group_ids\"\)`
# mysql -B -e "select port_range_min,port_range_max,ethertype,direction,protocol from securitygrouprules where security_group_id IN $sec_group_ids order by port_range_min ASC" neutron
port_range_min port_range_max ethertype direction protocol
NULL NULL IPv6 ingress NULL
NULL NULL IPv4 ingress icmp
NULL NULL IPv4 ingress NULL
NULL NULL IPv6 egress NULL
22 22 IPv4 ingress tcp
80 80 IPv4 ingress tcp
9999 9999 IPv4 ingress tcp
No comments:
Post a Comment