openstack安全组规则

本文档介绍了如何在OpenStack中管理安全组规则,包括创建自定义安全组、添加和删除规则,以及允许SSH、ping和DNS流量。通过修改默认或自定义的安全组规则,你可以控制实例对外的网络访问。详细步骤和命令行操作示例展示如何实现这些功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://www.aboutyun.com/thread-8964-1-1.html

 

 

 

参考官方资料
You must modify the rules for the default security group because users cannot access instances that use the default group from   
any IP address outside the cloud.  

You can modify the rules in a security group to allow access to instances through different ports and protocols. For example,   
you can modify rules to allow access to instances through SSH, to ping them, or to allow UDP traffic – for example, for a DNS   
server running on an instance. You specify the following parameters for rules:  

Source of traffic. Enable traffic to instances from either IP addresses inside the cloud from other group members or from all IP addresses.  

Protocol. Choose TCP for SSH, ICMP for pings, or UDP.  

Destination port on virtual machine. Defines a port range. To open a single port only, enter the same value twice. ICMP does not support ports: Enter values to define the codes and types of ICMP traffic to be allowed.  

Rules are automatically enforced as soon as you create or modify them.  

注: 已通过测试, 修改默认 secgroup 或自定义 secgroup 都可以完成数据访问测试
帮助

  1. [root@station140 ~(keystone_admin)]# nova help | grep secgroup  
  2.     add-secgroup        Add a Security Group to a server.  
  3.     list-secgroup       List Security Group(s) of a server.  
  4.     remove-secgroup     Remove a Security Group from a server.  
  5.     secgroup-add-group-rule  
  6.     secgroup-add-rule   Add a rule to a security group.  
  7.     secgroup-create     Create a security group.  
  8.     secgroup-delete     Delete a security group.  
  9.     secgroup-delete-group-rule  
  10.     secgroup-delete-rule  
  11.     secgroup-list       List security groups for the current tenant.  
  12.     secgroup-list-rules  
  13.     secgroup-update     Update a security group.  
复制代码



创建自定义安全组

  1. [root@station140 ~(keystone_admin)]# nova secgroup-create terry "allow ping and ssh"  
  2. +--------------------------------------+-------+--------------------+  
  3. | Id                                   | Name  | Description        |  
  4. +--------------------------------------+-------+--------------------+  
  5. | 6966a8e4-0980-40ad-a409-baac65b60287 | terry | allow ping and ssh |  
  6. +--------------------------------------+-------+--------------------+  
复制代码



列出当前所有安全组

  1. [root@station140 ~(keystone_admin)]# nova  secgroup-list  
  2. +--------------------------------------+---------+--------------------+  
  3. | Id                                   | Name    | Description        |  
  4. +--------------------------------------+---------+--------------------+  
  5. | 91a191a6-b89e-4f87-99c0-0fb985985978 | default | default            |  
  6. | 6966a8e4-0980-40ad-a409-baac65b60287 | terry   | allow ping and ssh |  
  7. +--------------------------------------+---------+--------------------+  
复制代码



列出某个组中的安全规则

  1. [root@station140 ~(keystone_admin)]# nova  secgroup-list-rules default  
  2. +-------------+-----------+---------+----------+--------------+  
  3. | IP Protocol | From Port | To Port | IP Range | Source Group |  
  4. +-------------+-----------+---------+----------+--------------+  
  5. |             |           |         |          | default      |  
  6. |             |           |         |          | default      |  
  7. +-------------+-----------+---------+----------+--------------+  
复制代码



增加规则方法 (允许 ping)

  1. [root@station140 ~(keystone_admin)]# nova secgroup-add-rule terry icmp -1 -1 0.0.0.0/0  
  2. +-------------+-----------+---------+-----------+--------------+  
  3. | IP Protocol | From Port | To Port | IP Range  | Source Group |  
  4. +-------------+-----------+---------+-----------+--------------+  
  5. | icmp        | -1        | -1      | 0.0.0.0/0 |              |  
  6. +-------------+-----------+---------+-----------+--------------+  
复制代码



增加规则方法 (允许 ssh)

  1. [root@station140 ~(keystone_admin)]# nova secgroup-add-rule terry tcp  22 22 0.0.0.0/0  
  2. +-------------+-----------+---------+-----------+--------------+  
  3. | IP Protocol | From Port | To Port | IP Range  | Source Group |  
  4. +-------------+-----------+---------+-----------+--------------+  
  5. | tcp         | 22        | 22      | 0.0.0.0/0 |              |  
  6. +-------------+-----------+---------+-----------+--------------+  
复制代码



增加规则方法 (允许 dns 外部访问)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值