易陆发现互联网技术论坛

 找回密码
 开始注册
查看: 4780|回复: 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
8 \7 L2 C! B/ T! z+----------------------+--------------------------------------------------------------------+% {( ~" ~( z  c. z. W0 a5 o; {
| Field                | Value                                                              |8 n7 u  N; G( [6 r. N' w  M
+----------------------+--------------------------------------------------------------------+2 T' J: y6 J3 Z6 r, J* I2 Y
| description          |                                                                    |
, z  e. V1 b1 ]! E0 c$ l| id                   | 5c5d9d5e-fe6b-4f04-ae91-650da50fe76c                               |& P# m; o% [) r/ I! ^* k; }9 Y
| name                 | SDN-lr-test                                                        |
6 ^! v2 c# d, p, g. E' Z* e9 Z| security_group_rules | {                                                                  |- [8 ~7 q6 f2 @$ {
|                      |      "remote_group_id": null,                                      |! w" `6 P8 T& E0 [( x0 k
|                      |      "direction": "egress",                                        |
* ?4 A# V! @/ H. _|                      |      "remote_ip_prefix": null,                                     |, O- T  R; V* @# X3 y3 W
|                      |      "protocol": null,                                             |. x4 P2 f+ v' J' j+ T+ [
|                      |      "tenant_id": "acb5078daac840cc86de3c8dc5d0f4fc",              |$ P8 z5 H& T7 @: h# t; b3 f! u2 k
|                      |      "port_range_max": null,                                       |
0 @9 m& a; f; ]1 J) U|                      |      "security_group_id": "5c5d9d5e-fe6b-4f04-ae91-650da50fe76c",  |
3 f# u. l7 u/ [2 B  ], r|                      |      "port_range_min": null,                                       |
; A+ Y% F0 `9 f- D|                      |      "ethertype": "IPv6",                                          |2 Z$ K& W' K1 ]5 a9 R: z
|                      |      "id": "06ba5ec0-725d-4bd1-80ad-910048e2658b"                  |' h* P! Y: v% q% I) E
|                      | }                                                                  |
& G# V3 C8 S2 G' a6 g) @|                      | {                                                                  |" [8 J) p+ v0 k, G5 S9 H1 p- `( n
|                      |      "remote_group_id": null,                                      |/ k6 n3 d2 H  `$ f- \6 a0 F) {
|                      |      "direction": "egress",                                        |
0 U/ {; X- E* n0 j, p1 K|                      |      "remote_ip_prefix": null,                                     |0 f9 B! K9 }- \
|                      |      "protocol": null,                                             |5 B! H# o/ R7 ~; U5 Y% }+ B
|                      |      "tenant_id": "acb5078daac840cc86de3c8dc5d0f4fc",              |
* c+ X! c( W, @|                      |      "port_range_max": null,                                       |- M: D* q' a* N
|                      |      "security_group_id": "5c5d9d5e-fe6b-4f04-ae91-650da50fe76c",  |( `1 @9 j/ @& G3 Q9 _
|                      |      "port_range_min": null,                                       |  C! F7 L$ g3 R) h/ U5 v# ~
|                      |      "ethertype": "IPv4",                                          |$ l% o" `9 x, f4 l( O
|                      |      "id": "e11c1d8c-9536-4ba1-aa54-3b6be5089c1c"                  |
; M- |8 t& s' f- E2 P& F|                      | }                                                                  |% h8 D1 b/ F7 E2 z
| tenant_id            | acb5078daac840cc86de3c8dc5d0f4fc                                   |3 ?; ?7 G( S# O# L9 v1 W& F
+----------------------+--------------------------------------------------------------------+
 楼主| 发表于 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: L- O. _( S0 x* ^0 ~( s8 R8 v' Z" \
例子:neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id  |grep 41c9fa3f-22ce-4116-ad31-f81992693d29
& y, X; u2 b+ s& H9 G. y" f) q- _$ z| [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"}    |                                 \  K) T2 t& I. L% ~4 l
: a6 ~8 `, a  @$ @' `# b2 j. t
neutron port-list -c id -c mac_address -c fixed_ips -c device_id  -c security_groups |grep 41c9fa3f-22ce-4116-ad31-f81992693d29* a; L' h0 b* Q3 T
| 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']                                                                                                                                                                     |
, k; d3 l' q2 _1 ]/ A! \
 楼主| 发表于 2019-4-17 09:55:43 | 显示全部楼层
列表 安全组:3 V1 i! g$ q' A4 I: Q4 n  X9 Z1 X
  m1 O% j0 p, L' x, {
s1@controller:~$ neutron security-group-list2 m2 x4 r7 _# p1 v/ J: ]
+--------------------------------------+------------+-------------+& b: m8 X$ ]# _. R- o
| id                                   | name       | description |& |$ ]9 T+ e) k; l: t
+--------------------------------------+------------+-------------+8 V: `4 l2 p1 }. o, r: n( |/ \$ ~
| 0aff643b-7b34-4384-b482-f37eccef5b90 | sg-all-ssh | allow ssh   |
7 U# `2 d7 R1 N, Z| c98a2a3f-1b06-429d-b419-aa862662f116 | default    | default     |
2 M& L. C7 P) f| f5377a66-803d-481b-b4c3-a6631e8ab456 | default    | default     |
8 Y* P* V+ @# z9 y* Z$ c+--------------------------------------+------------+-------------+( n- f5 p6 _+ O% o5 x+ Z7 w- Z
& a8 w+ U8 G( f9 P
列表配置了某安全组的所有 port:6 W  a5 e7 g8 o6 t
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
5 |" f5 X4 L6 Z1 R| [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                                          |2 B8 K; {: D, B! S
| [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-1e520b9c2830
( p" g: O2 W1 A5 b! b1 B 7 x7 |# B+ D! b$ @# }& \0 q& D5 e
s1@controller:~$ neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id | grep 29eaea66-6614-47e3-b251-0104ff9f12e29 Y( z6 H# z- r" Q
| [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                                          |
$ s* c( R) y/ o+ c' H# `" Q. m
4 t3 P, w1 r4 X5 C1 ~$ {删除指定 port 的安全组:
. H8 T! h  @( L: e$ ]# ks1@controller:~$ neutron port-update --no-security-groups 29eaea66-6614-47e3-b251-0104ff9f12e23 D! [5 ]% I( ?+ p! H2 {
Updated port: 29eaea66-6614-47e3-b251-0104ff9f12e2
1 @2 w, d8 _, r
2 P! O8 M% C: g' l删除后查看:
# w: J  N: _! A0 xs1@controller:~$ neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id | grep 29eaea66-6614-47e3-b251-0104ff9f12e2
0 j% B3 l$ _; }. T! ~1 u  u, o" r) [| []                                        | 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                                          |
, I4 ?+ I7 `% r1 Y; r4 w6 `# ]) M+ b# y
设置指定 port 的安全组:
; n4 B* ]# b/ n& ^# P7 ks1@controller:~$ neutron port-update --security-group 0aff643b-7b34-4384-b482-f37eccef5b90 29eaea66-6614-47e3-b251-0104ff9f12e2               9 P$ F# B2 _5 @# v
Updated port: 29eaea66-6614-47e3-b251-0104ff9f12e2
0 Q. u4 R$ R( g3 l# i# J, y9 A. {4 Z* L& ^$ q8 N
设置后查看
. N: O5 o) S9 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 {' _- T$ _' E, s: H| [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 | 显示全部楼层
添加某个地址的安全组规则:
# ?- L( @' J+ A3 ?/ @2 Dneutron 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! `2 a6 O7 O+ M
Created a new security_group_rule:
, H5 j! D# S- \- g5 x+-------------------+--------------------------------------+
# {6 x5 I! f* n& V0 T# Q7 W| Field             | Value                                |8 _6 w; Q7 G% h( ~) f' Q
+-------------------+--------------------------------------+* O" o2 G8 Z! l. w
| direction         | ingress                              |) d+ S; f% j6 d0 S1 B' o6 _
| ethertype         | IPv4                                 |  k+ L/ Y3 X4 X! c7 C
| id                | 28613a19-85c5-4cac-b806-d25bf564ad39 |' R6 ^1 [7 p/ d
| port_range_max    | 22                                   |
" e6 _8 L+ z$ ^. s| port_range_min    | 22                                   |
+ B; ~. \0 C0 G2 B| protocol          | tcp                                  |
1 H4 k2 s: Q& ]% X| remote_group_id   |                                      |. D6 O1 L5 i& L. Z3 `# }# P) e
| remote_ip_prefix  | 21.176.33.95/32                     |
( m1 @+ N/ G& [. E; n| security_group_id | 6beccc48-a119-44f2-9eb1-2f6870a71dc1 |
! F9 ?9 z( c3 w  q& c' l| tenant_id         | acb5078daac840cc86de3c8dc5d0f4fc     |% R3 L* P  z$ W6 H
+-------------------+--------------------------------------+
 楼主| 发表于 2019-4-22 22:20:06 | 显示全部楼层
端口更新安全组:& j: j4 {" i% k1 G; B
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
0 |5 w9 l- S, Q9 M& X# \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-8 21:36 , Processed in 0.070519 second(s), 26 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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