找回密码
 注册
查看: 4790|回复: 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% P! O+ t# G2 [+ a7 t- X
+----------------------+--------------------------------------------------------------------+
/ E' |2 U& E4 F* x| Field                | Value                                                              |* l3 e/ _9 c: K+ W  w
+----------------------+--------------------------------------------------------------------+8 H# _7 W" q0 z
| description          |                                                                    |
  y; V& x1 u( z6 C| id                   | 5c5d9d5e-fe6b-4f04-ae91-650da50fe76c                               |
# p" w/ O* L6 k* {4 \7 X| name                 | SDN-lr-test                                                        |/ K6 }5 o9 v$ K% S  z1 ]) O1 p
| security_group_rules | {                                                                  |( y8 g- q5 |; R( D4 j! c& I
|                      |      "remote_group_id": null,                                      |
. {; \" g- m/ X) R, \' x  u" P% ^|                      |      "direction": "egress",                                        |
: p/ V, b9 F( K, T$ U0 ?: \& E% z|                      |      "remote_ip_prefix": null,                                     |
1 g  L. I9 n& V4 c, h, n|                      |      "protocol": null,                                             |
' J7 C, p- l# N|                      |      "tenant_id": "acb5078daac840cc86de3c8dc5d0f4fc",              |
: \' ?% H; F% Q7 ^. p5 X: g|                      |      "port_range_max": null,                                       |" B* [; Y0 \/ ]. {0 Q4 Q9 m
|                      |      "security_group_id": "5c5d9d5e-fe6b-4f04-ae91-650da50fe76c",  |  Y4 |6 G5 i. R* s7 z$ A7 I7 {
|                      |      "port_range_min": null,                                       |
) E7 _) m" K9 g6 k% Y  ]6 R|                      |      "ethertype": "IPv6",                                          |
. w! h# J7 e# V: Z+ e/ ?9 @|                      |      "id": "06ba5ec0-725d-4bd1-80ad-910048e2658b"                  |
4 `6 W7 _1 l! V- e: J|                      | }                                                                  |
- i1 W7 M. {: E# I* e|                      | {                                                                  |+ U( a5 k' P) Y* c, q8 `' q9 L
|                      |      "remote_group_id": null,                                      |" X6 J. Q, _1 y3 y' _
|                      |      "direction": "egress",                                        |
: ?4 S. V. p4 v5 E# r2 y  S& W9 i|                      |      "remote_ip_prefix": null,                                     |
8 J5 |! o* p+ {" Y$ p# L|                      |      "protocol": null,                                             |
6 y" w4 H  X0 }9 O! Y2 A; v|                      |      "tenant_id": "acb5078daac840cc86de3c8dc5d0f4fc",              |
1 P. \7 S& S% Z, v. ~: r|                      |      "port_range_max": null,                                       |
* u" x7 V& y, l1 K1 a5 X|                      |      "security_group_id": "5c5d9d5e-fe6b-4f04-ae91-650da50fe76c",  |. }/ _! G' w6 @  l% r# k8 O# A, t
|                      |      "port_range_min": null,                                       |
' ]% ~, Z* Q9 B1 |$ L  r|                      |      "ethertype": "IPv4",                                          |( u; W: y8 J; H2 T) `
|                      |      "id": "e11c1d8c-9536-4ba1-aa54-3b6be5089c1c"                  |2 p, p: N+ Y5 W6 G6 ~% I
|                      | }                                                                  |
" f% F: G5 l9 S1 I3 D& T| tenant_id            | acb5078daac840cc86de3c8dc5d0f4fc                                   |
3 V. m3 E( ?/ ~# t# a3 V% K- t+----------------------+--------------------------------------------------------------------+

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 ^" R. |5 Q( |5 ]例子:neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id  |grep 41c9fa3f-22ce-4116-ad31-f81992693d29
" H; B3 l1 J. L# o" C. b% }! m| [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"}    |                              
* t5 S2 C5 q, H( v3 ]4 v/ Z0 }+ @; i. I4 g
neutron port-list -c id -c mac_address -c fixed_ips -c device_id  -c security_groups |grep 41c9fa3f-22ce-4116-ad31-f81992693d29# m* N! M& J# ?0 g5 J- Y
| 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']                                                                                                                                                                     |
; a2 [8 z5 S) b/ ^' Q

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2019-4-17 09:55:43 | 显示全部楼层
列表 安全组:- r+ U) P5 y9 n) D# f! M

" k( M4 T) k$ K! J- P  \3 Ns1@controller:~$ neutron security-group-list
% e( z# l! q. F) K. x: Q- A+--------------------------------------+------------+-------------+
& Y/ `* \5 ?; ]$ }9 {1 `7 T| id                                   | name       | description |
) o+ ]. q. z7 X% F* {; {5 V/ q# D+--------------------------------------+------------+-------------+- m+ U9 O# Q0 p1 M9 A
| 0aff643b-7b34-4384-b482-f37eccef5b90 | sg-all-ssh | allow ssh   |% M1 N+ G6 ~% a- r; b6 H
| c98a2a3f-1b06-429d-b419-aa862662f116 | default    | default     |
: y; U1 {5 j2 \5 b| f5377a66-803d-481b-b4c3-a6631e8ab456 | default    | default     |
. t0 ]  I# e$ b1 z! m+--------------------------------------+------------+-------------+
" M! w6 W' u7 |5 ^3 j0 q( ~ - ^, g2 A- e" {/ Y, E
列表配置了某安全组的所有 port:: T5 m4 N$ C, j2 \* v- W  q6 o
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
) J: z3 u+ z! ~* k: x; S/ a| [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                                          |
* ?+ N! n5 t/ C+ x6 c| [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+ H6 a: q. ^; K% |1 m

! |0 K4 c; t" q. W# T, f 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
* w5 g0 w9 e2 i0 u1 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                                          |0 p8 Z9 ]+ A. L7 d7 }, W+ i
' p( M! I# s# i1 K# x* \. p8 Y0 ^
删除指定 port 的安全组:
( c- F7 M' s/ O/ X& T$ k# Gs1@controller:~$ neutron port-update --no-security-groups 29eaea66-6614-47e3-b251-0104ff9f12e2% d; P) r7 K9 T6 E
Updated port: 29eaea66-6614-47e3-b251-0104ff9f12e27 l9 _# L8 I. Z+ P) Y
: D- I2 R8 C' r
删除后查看:
& _9 W- ]+ m- v6 Ms1@controller:~$ neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id | grep 29eaea66-6614-47e3-b251-0104ff9f12e2
: N: f4 C  w# F# H" X% t$ N' z| []                                        | 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                                          |
+ g5 z, P4 e% u1 N) R
7 \" C' f" b$ b- g3 v! I设置指定 port 的安全组:  |2 p$ T) s6 C) X1 X! w7 l
s1@controller:~$ neutron port-update --security-group 0aff643b-7b34-4384-b482-f37eccef5b90 29eaea66-6614-47e3-b251-0104ff9f12e2               ) T" v8 h: n: u9 _
Updated port: 29eaea66-6614-47e3-b251-0104ff9f12e29 M2 p8 Z& T0 v3 V0 c

5 }( z; v4 S) e设置后查看+ G6 P3 i  L: e, i% R9 D$ U
s1@controller:~$ neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id | grep 29eaea66-6614-47e3-b251-0104ff9f12e23 j- I( C: p3 l1 @- N0 {8 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 | 显示全部楼层
添加某个地址的安全组规则:- H. g3 d1 B0 Y7 E$ c3 }- t
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
! y3 P1 N* j$ ^$ `8 }Created a new security_group_rule:$ b- g/ S2 _! ]
+-------------------+--------------------------------------+
! n. T; f7 m( Z. _| Field             | Value                                |1 d! @" T/ d& c
+-------------------+--------------------------------------+
: |9 Q, B$ h; y8 L( Y6 _6 F3 X| direction         | ingress                              |5 l; l  K' _" C: a6 \2 q( |
| ethertype         | IPv4                                 |
1 D# N, r9 g, G. u$ ^  W' k| id                | 28613a19-85c5-4cac-b806-d25bf564ad39 |
* t$ k- g9 S+ w| port_range_max    | 22                                   |# ~' [) Y8 ^) L
| port_range_min    | 22                                   |! u. j: X% B6 Z. T8 U- U/ |
| protocol          | tcp                                  |4 X1 f* q5 A$ |- u7 Y  C
| remote_group_id   |                                      |- J0 c7 D" L. \& n) ~$ @+ H+ A
| remote_ip_prefix  | 21.176.33.95/32                     |/ g- }+ i1 E0 [1 u9 d- P
| security_group_id | 6beccc48-a119-44f2-9eb1-2f6870a71dc1 |' o5 v- V9 P% l" r- s( Q( _0 o
| tenant_id         | acb5078daac840cc86de3c8dc5d0f4fc     |
9 Q& b; T9 i3 j+-------------------+--------------------------------------+

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2019-4-22 22:20:06 | 显示全部楼层
端口更新安全组:) M6 c% ~- f9 D7 _' l" \! {% E
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, L3 k2 w0 `! y1 N& p& }& E
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 01:24 , Processed in 0.025303 second(s), 26 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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