易陆发现互联网技术论坛

 找回密码
 开始注册
查看: 4781|回复: 6
收起左侧

openstack底层neutron security-group-create 创建安全组及创建安全组规则

[复制链接]
发表于 2019-4-11 22:28:15 | 显示全部楼层 |阅读模式
购买主题 本主题需向作者支付 2 金钱 才能浏览
 楼主| 发表于 2019-4-11 22:30:12 | 显示全部楼层
neutron security-group-show 5c5d9d5e-fe6b-4f04-ae91-650da50fe76c
; E4 M. l- b& }. `% Q; ^+ V# ~+----------------------+--------------------------------------------------------------------+9 x$ F1 n- e! j
| Field                | Value                                                              |0 s6 u4 @/ ^6 _1 S- C9 F" e  }
+----------------------+--------------------------------------------------------------------+5 m' n: h4 |& R# I  O3 s
| description          |                                                                    |. Z5 T5 p+ Z* X# c+ i3 @" }6 m: X6 s- R
| id                   | 5c5d9d5e-fe6b-4f04-ae91-650da50fe76c                               |
6 C; H% A- r0 B& l' q| name                 | SDN-lr-test                                                        |
7 Q6 t% w& h- W( s/ e, z+ Z| security_group_rules | {                                                                  |
0 ?( q3 i) [' y3 H* ~|                      |      "remote_group_id": null,                                      |
, {# r  z" g9 }|                      |      "direction": "egress",                                        |* e& \0 O& B( `9 V' J
|                      |      "remote_ip_prefix": null,                                     |
% p2 o& L7 G" H|                      |      "protocol": null,                                             |
/ l) G: K& {! T- ?+ F8 I1 L|                      |      "tenant_id": "acb5078daac840cc86de3c8dc5d0f4fc",              |& K+ X+ [+ V, q. p, W5 n4 Q
|                      |      "port_range_max": null,                                       |, {0 z. S4 ?1 b( g- T
|                      |      "security_group_id": "5c5d9d5e-fe6b-4f04-ae91-650da50fe76c",  |
; D1 l; w. L' A. P; r  N1 X|                      |      "port_range_min": null,                                       |
0 z( g% s( ?' V# A& C# q8 F|                      |      "ethertype": "IPv6",                                          |+ F6 o9 K; m! B( o" Z
|                      |      "id": "06ba5ec0-725d-4bd1-80ad-910048e2658b"                  |
' I; ]* Q2 D! G( R& Z8 a" x# a|                      | }                                                                  |  f* {7 m) l' z1 i: C7 Y
|                      | {                                                                  |
8 z% P$ I8 o) ]) k8 Y; v. b5 o|                      |      "remote_group_id": null,                                      |
9 p! p* s8 D( \0 H: M( y|                      |      "direction": "egress",                                        |
  U! {7 l0 T8 h) r( P4 K|                      |      "remote_ip_prefix": null,                                     |
5 {- \- ^0 `/ ]: t+ b|                      |      "protocol": null,                                             |
# C/ I9 ?! D1 R3 {3 t|                      |      "tenant_id": "acb5078daac840cc86de3c8dc5d0f4fc",              |
* z% h$ L- N. q! k7 v8 m3 D|                      |      "port_range_max": null,                                       |/ s0 z; j+ ?9 Y8 p' v
|                      |      "security_group_id": "5c5d9d5e-fe6b-4f04-ae91-650da50fe76c",  |
3 s$ g7 R# e4 x9 O( a" _|                      |      "port_range_min": null,                                       |0 b5 p7 d5 S7 E3 l2 d
|                      |      "ethertype": "IPv4",                                          |
+ b( ~5 N. b) N, x, c|                      |      "id": "e11c1d8c-9536-4ba1-aa54-3b6be5089c1c"                  |. {5 z* E4 ^5 `9 j
|                      | }                                                                  |
6 z! T) `' x- O1 a| tenant_id            | acb5078daac840cc86de3c8dc5d0f4fc                                   |- T. ^1 U2 C# F  V/ L# a/ w2 Z
+----------------------+--------------------------------------------------------------------+
 楼主| 发表于 2019-4-17 09:54:20 | 显示全部楼层
neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id | grep c98a2a3f-1b06-429d-b419-aa862662f116
6 y$ `+ H+ `. Z1 y' J例子:neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id  |grep 41c9fa3f-22ce-4116-ad31-f81992693d29
# P" A: g! y. M8 }& g6 X| [u'0c59149b-7ca5-437c-b834-1346e9f8ad6f']                                                                                                                                                                     | 41c9fa3f-22ce-4116-ad31-f81992693d29 | fa:16:3e:ed:69:ad | {"subnet_id": "a5c39d3a-7718-4aca-818b-fc5b6d72bcfe", "ip_address": "192.168.1.225"}    |                               8 F8 [3 q' O7 {) g9 F7 `

! b; f% w# X  wneutron port-list -c id -c mac_address -c fixed_ips -c device_id  -c security_groups |grep 41c9fa3f-22ce-4116-ad31-f81992693d298 H0 [4 N% [/ j; [* L) h9 G
| 41c9fa3f-22ce-4116-ad31-f81992693d29 | fa:16:3e:ed:69:ad | {"subnet_id": "a5c39d3a-7718-4aca-818b-fc5b6d72bcfe", "ip_address": "192.168.1.25"}    |                                      | [u'0c59149b-7ca5-437c-b834-1346e9f8ad6f']                                                                                                                                                                     |
. T+ O( G* u9 V8 Q/ J( ~
 楼主| 发表于 2019-4-17 09:55:43 | 显示全部楼层
列表 安全组:( e0 B/ |- _% z- i9 a* R( Q
* G5 L8 n% m0 g
s1@controller:~$ neutron security-group-list
: T1 f4 Y9 h3 d8 ?* E, p7 G4 B+--------------------------------------+------------+-------------+
  \& L1 X; F8 q! J2 B. T| id                                   | name       | description |% `* R0 H- ^6 `7 \* R
+--------------------------------------+------------+-------------+9 Z  p, |+ C3 K- t  u- W" d* s8 A6 n
| 0aff643b-7b34-4384-b482-f37eccef5b90 | sg-all-ssh | allow ssh   |
. B2 a+ V/ w8 N9 d| c98a2a3f-1b06-429d-b419-aa862662f116 | default    | default     |; c0 x( j$ O0 J* E1 S5 t
| f5377a66-803d-481b-b4c3-a6631e8ab456 | default    | default     |; d8 ^; \5 D' l5 z# O( k
+--------------------------------------+------------+-------------+
* D, R3 S; C2 B+ [9 _: u 1 L) |: J: \+ T- o6 h! I! X
列表配置了某安全组的所有 port:
, d# w& S( q0 u9 ~4 b& ~s1@controller:~$ neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id | grep c98a2a3f-1b06-429d-b419-aa862662f116
* w3 N3 i4 ?8 G* C  V: p4 s| [u'c98a2a3f-1b06-429d-b419-aa862662f116'] | 29eaea66-6614-47e3-b251-0104ff9f12e2 | fa:16:3e:bc:52:eb | {"subnet_id": "d803eaa3-63c9-4c2b-834a-9780db31df70", "ip_address": "100.1.250.1"}   | 1214b1b4-7c3a-41ad-ad8e-1e520b9c2830                                          |' r" ^. j! f0 J+ W% H
| [u'c98a2a3f-1b06-429d-b419-aa862662f116'] | a7e26c3e-c1ae-4c65-a0e4-2d81266a11b3 | fa:16:3e:b8:f9:ad | {"subnet_id": "4ac56c61-84f3-4d00-b87a-1ab2441e8437", "ip_address": "100.1.150.1"}   | 1214b1b4-7c3a-41ad-ad8e-1e520b9c28303 h. b: g% K3 |& j8 R' c# x- U$ i
& S* ~* D9 L8 r6 U* L+ o
s1@controller:~$ neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id | grep 29eaea66-6614-47e3-b251-0104ff9f12e2, K1 G3 [3 o1 B" |0 Q8 y) A: d, b
| [u'0aff643b-7b34-4384-b482-f37eccef5b90'] | 29eaea66-6614-47e3-b251-0104ff9f12e2 | fa:16:3e:bc:52:eb | {"subnet_id": "d803eaa3-63c9-4c2b-834a-9780db31df70", "ip_address": "100.1.250.1"}   | 1214b1b4-7c3a-41ad-ad8e-1e520b9c2830                                          |
6 A; G: w1 ]) o# d# @+ ?6 D9 P7 |, \, `* r/ {8 A7 `5 A' s5 U
删除指定 port 的安全组:* e' c! T/ ^& s  F0 w, K: X
s1@controller:~$ neutron port-update --no-security-groups 29eaea66-6614-47e3-b251-0104ff9f12e28 o) ]7 D& a% O* O1 c; [
Updated port: 29eaea66-6614-47e3-b251-0104ff9f12e2& H1 q, ]8 h# g
- Y* k+ h: Y) E) r& ^
删除后查看:, g; I# m) f+ _- [4 r" {/ \
s1@controller:~$ neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id | grep 29eaea66-6614-47e3-b251-0104ff9f12e2
1 a% d9 d6 u* z$ M  u$ {. c+ b| []                                        | 29eaea66-6614-47e3-b251-0104ff9f12e2 | fa:16:3e:bc:52:eb | {"subnet_id": "d803eaa3-63c9-4c2b-834a-9780db31df70", "ip_address": "100.1.250.1"}   | 1214b1b4-7c3a-41ad-ad8e-1e520b9c2830                                          |6 x- g) Q# ?) ^* [9 N: E9 A

( Q- Z  P/ ]4 i7 }7 e% v设置指定 port 的安全组:1 C; |4 x9 r' q3 D& ]7 t1 v
s1@controller:~$ neutron port-update --security-group 0aff643b-7b34-4384-b482-f37eccef5b90 29eaea66-6614-47e3-b251-0104ff9f12e2                 d" Y) g: x& i4 ]! B' b
Updated port: 29eaea66-6614-47e3-b251-0104ff9f12e2+ C7 i/ Z: q% F8 \1 d
  ~1 b7 k+ J- x8 b" s% M
设置后查看
9 a) \6 D+ d. {  P- m' F" Ns1@controller:~$ neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id | grep 29eaea66-6614-47e3-b251-0104ff9f12e2: X& L5 ^' k0 a% n9 X/ }
| [u'0aff643b-7b34-4384-b482-f37eccef5b90'] | 29eaea66-6614-47e3-b251-0104ff9f12e2 | fa:16:3e:bc:52:eb | {"subnet_id": "d803eaa3-63c9-4c2b-834a-9780db31df70", "ip_address": "100.1.250.1"}   | 1214b1b4-7c3a-41ad-ad8e-1e520b9c2830
 楼主| 发表于 2019-4-19 14:26:01 | 显示全部楼层
添加某个地址的安全组规则:- Y3 U! Y1 B* P0 w
neutron security-group-rule-create 6beccc48-a119-44f2-9eb1-2f6870a71dc1  --direction ingress --ethertype IPv4 --protocol tcp --port-range-min 22 --port-range-max 22  --remote-ip-prefix 21.176.33.95* v& G3 `, |, p- c& ^/ r
Created a new security_group_rule:
$ U4 T5 Z3 c/ |* F+-------------------+--------------------------------------+
- U4 w! _: k" d4 K| Field             | Value                                |
4 d+ g+ K1 z  C' z7 w" V+-------------------+--------------------------------------+3 Y% q0 F3 y; x
| direction         | ingress                              |; Y" }1 d# o1 Q
| ethertype         | IPv4                                 |
4 \! y8 M4 R8 Q( D5 || id                | 28613a19-85c5-4cac-b806-d25bf564ad39 |
) O- R6 o; X2 u; f7 g' L' Q| port_range_max    | 22                                   |
, b) A, J) K* B0 O! \$ ]; N) U| port_range_min    | 22                                   |
# ^4 B3 V  B$ C3 L: c| protocol          | tcp                                  |
0 O2 f) P: |" o" W( ]" k| remote_group_id   |                                      |! ~- }$ J, Z4 u" }) f3 n- n
| remote_ip_prefix  | 21.176.33.95/32                     |
& B% t2 O$ I9 s& D- h5 s: _  L| security_group_id | 6beccc48-a119-44f2-9eb1-2f6870a71dc1 |9 X& v# e; Z( t" f
| tenant_id         | acb5078daac840cc86de3c8dc5d0f4fc     |
% F3 i+ z% n7 y# A* M, h+-------------------+--------------------------------------+
 楼主| 发表于 2019-4-22 22:20:06 | 显示全部楼层
端口更新安全组:) D' P/ X$ ^" b, J  U9 D
neutron port-update --security-group 0aff643b-7b34-4384-b482-f37eccef5b90 29eaea66-6614-47e3-b251-0104ff9f12e2
 楼主| 发表于 2020-12-3 20:45:54 | 显示全部楼层
neutron security-group-rule-create 4c48b300-c668-4c25-b3ff-d03f652ea562  --direction ingress --ethertype IPv4 --protocol tcp --port-range-min 22 --port-range-max 22  --remote-ip-prefix 11.189.19.85) T& a9 W4 D- h5 u# c) g) I+ V# s
neutron security-group-rule-create security-group-id  --direction ingress --ethertype IPv4 --protocol tcp --port-range-min port --port-range-max port  --remote-ip-prefix 11.189.19.85
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

站长推荐上一条 /4 下一条

北京云银创陇科技有限公司以云计算运维,代码开发

QQ|返回首页|Archiver|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )点击这里给我发消息

GMT+8, 2026-4-9 00:04 , Processed in 0.061403 second(s), 26 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

快速回复 返回顶部 返回列表