找回密码
 注册
查看: 4788|回复: 6

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

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2019-4-11 22:28:15 | 显示全部楼层 |阅读模式
购买主题 本主题需向作者支付 2 金钱 才能浏览

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2019-4-11 22:30:12 | 显示全部楼层
neutron security-group-show 5c5d9d5e-fe6b-4f04-ae91-650da50fe76c
" r3 f9 p+ u' W1 a! f. z# Q  p+----------------------+--------------------------------------------------------------------+7 w2 t6 G" e. S# F. T; Q$ J( m
| Field                | Value                                                              |7 k3 p( D' V, i1 F5 k3 M# m4 s
+----------------------+--------------------------------------------------------------------+) g2 r$ P; G8 ?- y( W+ \
| description          |                                                                    |( z* R( X# d8 z* M1 ~4 O; R/ G
| id                   | 5c5d9d5e-fe6b-4f04-ae91-650da50fe76c                               |# F5 [" i5 A0 y5 @8 r
| name                 | SDN-lr-test                                                        |. I# }7 c5 J# C+ I: T* P% G
| security_group_rules | {                                                                  |
# t  X9 Z! M2 R|                      |      "remote_group_id": null,                                      |
- M( N7 @. D. `5 @|                      |      "direction": "egress",                                        |
- m+ R2 \" O) k  K% N2 z|                      |      "remote_ip_prefix": null,                                     |( u5 O$ s* J" P  m2 P3 e
|                      |      "protocol": null,                                             |
3 i2 H; ~4 |7 s! f/ G5 Y& r3 F' O6 g|                      |      "tenant_id": "acb5078daac840cc86de3c8dc5d0f4fc",              |
1 K- a; Y+ _% W# {|                      |      "port_range_max": null,                                       |& G2 q- c9 G" Q& B/ A
|                      |      "security_group_id": "5c5d9d5e-fe6b-4f04-ae91-650da50fe76c",  |5 |3 a; J7 e- i" N$ J- z- S5 M
|                      |      "port_range_min": null,                                       |$ N) G" S2 `: J; C
|                      |      "ethertype": "IPv6",                                          |" k' d$ [0 N7 a+ K* Q
|                      |      "id": "06ba5ec0-725d-4bd1-80ad-910048e2658b"                  |  K8 c4 i' \1 K/ P: H, A
|                      | }                                                                  |$ [0 J  a& I* P4 s+ t
|                      | {                                                                  |
" \& k, U5 A( L8 l- E+ s|                      |      "remote_group_id": null,                                      |
" {7 c. m5 h* a! ~' ]% ]3 P|                      |      "direction": "egress",                                        |/ ?/ C9 X. \/ `4 c, {. y
|                      |      "remote_ip_prefix": null,                                     |
! u' [( r3 V3 C6 \|                      |      "protocol": null,                                             |
/ W& T, s7 Y1 z" X" n8 ^0 i|                      |      "tenant_id": "acb5078daac840cc86de3c8dc5d0f4fc",              |
9 a( J+ G% a( v6 K- f|                      |      "port_range_max": null,                                       |% w6 o7 n4 ^9 M% s, T9 u( s9 T- b
|                      |      "security_group_id": "5c5d9d5e-fe6b-4f04-ae91-650da50fe76c",  |
0 O$ \# a& H* W6 i% J! F& A|                      |      "port_range_min": null,                                       |5 G. q0 o9 S4 r
|                      |      "ethertype": "IPv4",                                          |
) |0 C0 k) I- e% s|                      |      "id": "e11c1d8c-9536-4ba1-aa54-3b6be5089c1c"                  |
* B, Z6 C$ \; H& p3 n3 ^0 K|                      | }                                                                  |
  ~$ d; G+ x3 M5 W  N6 O; L! e| tenant_id            | acb5078daac840cc86de3c8dc5d0f4fc                                   |" {% a6 E, `0 o2 U4 ~; X  z" r9 K) \
+----------------------+--------------------------------------------------------------------+

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 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 N) J* r. u! z! f' Y) T例子:neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id  |grep 41c9fa3f-22ce-4116-ad31-f81992693d29& a2 O) S7 _" G* N) Y5 C
| [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"}    |                               5 \" w# n7 c) F  S9 \! h

5 G$ Q) Z! A+ x3 u, d# @/ m! L( Sneutron port-list -c id -c mac_address -c fixed_ips -c device_id  -c security_groups |grep 41c9fa3f-22ce-4116-ad31-f81992693d29
0 F6 u: s/ F  l" H* ?0 X' r8 {4 ~| 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']                                                                                                                                                                     |5 d  @0 H1 r" q4 ~. I+ B, n" r

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2019-4-17 09:55:43 | 显示全部楼层
列表 安全组:
9 P. ~  ^, _4 V# w+ W9 N
+ R4 Z8 o- P$ M  L" T# o/ e- @s1@controller:~$ neutron security-group-list7 f) l, H$ j# I5 K6 M' p7 ~+ @. }% k
+--------------------------------------+------------+-------------+
/ o7 }$ R1 s2 s* O+ I9 g8 B0 d7 f- S| id                                   | name       | description |0 d: E, r4 {: }3 n/ B* m" f) a  l
+--------------------------------------+------------+-------------+4 J$ t! d* x: ?, P
| 0aff643b-7b34-4384-b482-f37eccef5b90 | sg-all-ssh | allow ssh   |5 G( R( k7 [- @; D, ~1 f, h1 I% e
| c98a2a3f-1b06-429d-b419-aa862662f116 | default    | default     |
0 g( b4 g- _% R; m$ B| f5377a66-803d-481b-b4c3-a6631e8ab456 | default    | default     |0 W3 i1 p0 V" O, O0 L
+--------------------------------------+------------+-------------+1 x4 X* f3 u0 w* M- N

/ G$ I8 t, T1 o1 I列表配置了某安全组的所有 port:9 n  h7 n! J8 v
s1@controller:~$ neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id | grep c98a2a3f-1b06-429d-b419-aa862662f1166 B' z0 g' E8 [
| [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                                          |  v5 ?5 {& S' |8 l6 L, J
| [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-1e520b9c28305 g& N7 O6 n' ^5 ^; x- e
0 R& K9 I( s8 h, b( X
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
% k7 G6 P8 S! T3 F+ n2 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                                          |
, M) x6 U) }. |: ~$ v1 K! b* N9 G& w- v) C, j4 s
删除指定 port 的安全组:
! }# p: R1 X5 S8 h" ^6 y0 xs1@controller:~$ neutron port-update --no-security-groups 29eaea66-6614-47e3-b251-0104ff9f12e2
2 E) @2 Z( {) ?. u" J; V/ xUpdated port: 29eaea66-6614-47e3-b251-0104ff9f12e2
9 z$ _0 g( G$ C  O, P  m* s
  ~' }% ]- t" Z6 o删除后查看:
- I8 P& ?  h7 `) w0 m9 T8 c- as1@controller:~$ neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id | grep 29eaea66-6614-47e3-b251-0104ff9f12e2
. `/ U) E6 j2 f/ a; l' G| []                                        | 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                                          |( X# T! a& A+ C. I$ b% g

4 t% X8 U+ l! ~( x) ], b& f. P设置指定 port 的安全组:: ^0 `: S. `# c4 {$ R  R
s1@controller:~$ neutron port-update --security-group 0aff643b-7b34-4384-b482-f37eccef5b90 29eaea66-6614-47e3-b251-0104ff9f12e2               * j. \! p9 h1 A) L& y! p6 R
Updated port: 29eaea66-6614-47e3-b251-0104ff9f12e2
0 ~% K7 r: U" r3 o3 t) R- z6 m( Y) g, E. Z
设置后查看
6 \3 _; [3 r( z3 [- zs1@controller:~$ neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id | grep 29eaea66-6614-47e3-b251-0104ff9f12e2
& N0 S9 x' p7 Q+ ]  d: s5 p. N| [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

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2019-4-19 14:26:01 | 显示全部楼层
添加某个地址的安全组规则:
+ k2 d2 b. o# v8 c4 Aneutron 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.955 C4 A  I3 W' I( o
Created a new security_group_rule:2 i2 I. n% j. M& h
+-------------------+--------------------------------------+9 c8 p2 p- ?8 p8 ]4 N" i8 c- z5 [
| Field             | Value                                |) l% ^5 H$ |8 u+ U
+-------------------+--------------------------------------+
# |( i2 W# N3 N1 ?| direction         | ingress                              |& D2 ~% ]+ w5 ?: K% U
| ethertype         | IPv4                                 |
; B2 I' S  G* q7 z9 p| id                | 28613a19-85c5-4cac-b806-d25bf564ad39 |' n9 g, ~$ X; X/ I6 G$ Y: U
| port_range_max    | 22                                   |' Y4 V$ ~5 J4 |) W* f. s
| port_range_min    | 22                                   |
/ W! @" T: U2 @$ A7 m| protocol          | tcp                                  |. R# s) O1 x6 r9 J6 _  n3 w
| remote_group_id   |                                      |2 W& a+ M" @: y# U* n- L5 D
| remote_ip_prefix  | 21.176.33.95/32                     |1 V* b8 [3 v1 b( j8 d
| security_group_id | 6beccc48-a119-44f2-9eb1-2f6870a71dc1 |( y9 B5 Q* Q. X
| tenant_id         | acb5078daac840cc86de3c8dc5d0f4fc     |
6 y+ I5 d# `% u1 l3 d- G+-------------------+--------------------------------------+

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2019-4-22 22:20:06 | 显示全部楼层
端口更新安全组:$ I6 E! |* c9 x7 K. t& o! J- b% N
neutron port-update --security-group 0aff643b-7b34-4384-b482-f37eccef5b90 29eaea66-6614-47e3-b251-0104ff9f12e2

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 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$ Y8 c: ?1 `9 g8 _! M3 ?( F* {
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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 00:14 , Processed in 0.022967 second(s), 26 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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