1

I learn from Amazon AWS Console that, you can open port by using specific attached security group of an instance and by editing it you can directly alter the port available for communication as mentioned in https://stackoverflow.com/a/10454688/789745.

I'm wondering, if the above can be performed using command line?? I have tried using netstat, nmap, iptables. but not successful so far.

Community
  • 1
  • 1
L.fole
  • 417
  • 2
  • 8
  • 17
  • Maybe this doc can help: http://docs.aws.amazon.com/AWSEC2/2006-10-01/DeveloperGuide/CLTRG-authorize.html – TeTeT Apr 19 '14 at 11:37

1 Answers1

0

You can do the same with ec2 command line tool. Here's how you can do this :

To create a security group:

  $ ec2-add-group myfirstsg -d 'My First Security Group'

  // myfirstsqg = your new security group name
  // -d is for the description

To open a ports on the created security group

  $ ec2-authorize myfirstsg -P tcp -p 80 -s 59.23.10.3/16
    GROUP myfirstsg "" PERMISSION myfirstsg ALLOWS tcp 80 80 
    FROM CIDR 59.23.10.3/16

  // -P PROTOCOL
  // -p PORT_RANGE
  // -s SOURCE_SUBNET
Rohit Raina
  • 316
  • 2
  • 7