易陆发现互联网技术论坛

 找回密码
 开始注册
查看: 4779|回复: 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# Q) G: ]) b; K# n1 n6 `
+----------------------+--------------------------------------------------------------------+% z& e% t' ~2 E: ]6 A+ q/ J" ^
| Field                | Value                                                              |+ d2 E( r8 z6 ], o: P8 {8 @' \
+----------------------+--------------------------------------------------------------------+
- Z# o3 G  f9 F8 h& }, Q* v+ L) c| description          |                                                                    |0 k( u# r- t( c- |8 j5 ^1 G4 E
| id                   | 5c5d9d5e-fe6b-4f04-ae91-650da50fe76c                               |% E& C, w* [) e9 U( |
| name                 | SDN-lr-test                                                        |* ]) ]- c/ U) {. {5 F7 k$ X: X
| security_group_rules | {                                                                  |
6 N& O+ U: @! l9 @5 ]) x  J|                      |      "remote_group_id": null,                                      |
- j+ N! D* I, y& P1 @5 @) a; D3 E|                      |      "direction": "egress",                                        |9 S5 g; ~9 l8 `9 C* ]# ~5 _
|                      |      "remote_ip_prefix": null,                                     |
+ t$ [# |/ i2 l  L1 n|                      |      "protocol": null,                                             |
3 ^  {( [- k1 O4 K8 d; ~|                      |      "tenant_id": "acb5078daac840cc86de3c8dc5d0f4fc",              |
' p7 q( a" ?1 K' T2 c|                      |      "port_range_max": null,                                       |
( q5 [4 t  U5 U|                      |      "security_group_id": "5c5d9d5e-fe6b-4f04-ae91-650da50fe76c",  |# n. T9 G6 t# F1 p. Y: q/ {6 H
|                      |      "port_range_min": null,                                       |( t- v. f) ]) {3 n; f
|                      |      "ethertype": "IPv6",                                          |
0 O; V9 V. K' Z# @/ n|                      |      "id": "06ba5ec0-725d-4bd1-80ad-910048e2658b"                  |
3 w$ I$ X. s8 w8 `7 }8 i6 a|                      | }                                                                  |& q" h; L: E2 S2 V; z% R
|                      | {                                                                  |/ s; _8 N4 ]% e
|                      |      "remote_group_id": null,                                      |: o$ V! S5 p  z0 M
|                      |      "direction": "egress",                                        |
& g( z  D3 q6 g- c) K% X4 T|                      |      "remote_ip_prefix": null,                                     |) H5 w% w( G. m( S+ A  N' z
|                      |      "protocol": null,                                             |
+ x. n% X8 R! n" D0 i|                      |      "tenant_id": "acb5078daac840cc86de3c8dc5d0f4fc",              |
) n: m# v( F* D* a" q' Z' J|                      |      "port_range_max": null,                                       |
. [) _% F: {9 k+ D! U|                      |      "security_group_id": "5c5d9d5e-fe6b-4f04-ae91-650da50fe76c",  |; i# A( t. q7 w8 n+ n+ r! C
|                      |      "port_range_min": null,                                       |
5 Y' Y& m, ~' Y+ k4 r|                      |      "ethertype": "IPv4",                                          |# v- `: w% _' Z  g  c
|                      |      "id": "e11c1d8c-9536-4ba1-aa54-3b6be5089c1c"                  |
5 z+ y& g% q2 |' k5 M+ _|                      | }                                                                  |& F7 ~$ {5 _- }
| tenant_id            | acb5078daac840cc86de3c8dc5d0f4fc                                   |
. @; F( c0 Z/ o7 x0 J5 S* 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: K# u8 U' h" n! {, t6 U- P
例子:neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id  |grep 41c9fa3f-22ce-4116-ad31-f81992693d29
: K: ^+ A+ c7 P- I2 d& r| [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"}    |                               - m& U! C; y: [0 c3 e

& i, o# y- v$ ?  b# {9 _, Eneutron port-list -c id -c mac_address -c fixed_ips -c device_id  -c security_groups |grep 41c9fa3f-22ce-4116-ad31-f81992693d29
+ ?8 C' s" D2 _' d6 E| 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']                                                                                                                                                                     |
1 N( n& t7 M* S* s% B" U( x
 楼主| 发表于 2019-4-17 09:55:43 | 显示全部楼层
列表 安全组:
# P  H/ {- G7 _* G# v5 R! K0 G0 q
: y' p5 ?' Y0 v4 e/ Fs1@controller:~$ neutron security-group-list
% p0 e0 g7 }8 b+--------------------------------------+------------+-------------+
# _% G1 L8 {& r, }8 M5 Y% S| id                                   | name       | description |0 ?" a2 x# B, c6 ?5 R
+--------------------------------------+------------+-------------+
9 V% o; \! K# U- @+ q/ {6 R| 0aff643b-7b34-4384-b482-f37eccef5b90 | sg-all-ssh | allow ssh   |
% Z& F9 L. B& I0 \: O$ b) i3 {' }  ]| c98a2a3f-1b06-429d-b419-aa862662f116 | default    | default     |% ^# c1 `# r$ H% n$ g3 S( n& i
| f5377a66-803d-481b-b4c3-a6631e8ab456 | default    | default     |% g) h& a9 T. ~8 S& J. J0 B; }! c
+--------------------------------------+------------+-------------+
  \% b3 j+ k2 N( t) V1 ]  t0 o
' O( l& T3 j6 g  {1 d7 g' t; o列表配置了某安全组的所有 port:
* A4 `: f6 Q" zs1@controller:~$ neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id | grep c98a2a3f-1b06-429d-b419-aa862662f116
9 b. m9 g% W+ e9 e& I6 l5 l( E! M! F| [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                                          |
; X3 [2 c# u0 m| [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; _  i2 P5 z) u' J: b
2 z" a& f" l" W; {% T+ |
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
; O0 Q, b/ D, m# j, n) O. v| [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 A; `6 Y# L. o; D) J
$ g( `( u6 T, P- v$ ^! o4 V4 Y  Y
删除指定 port 的安全组:- O, W5 o, m0 N
s1@controller:~$ neutron port-update --no-security-groups 29eaea66-6614-47e3-b251-0104ff9f12e2* E9 b" z2 J7 i/ j5 l2 ~, Q
Updated port: 29eaea66-6614-47e3-b251-0104ff9f12e2
! n/ z7 I$ \9 @* H3 N 1 J7 u7 m# K' E9 W) _  g
删除后查看:7 T- A3 F- y( M9 j3 B2 B* m  ~
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) b/ k7 y# v3 m& S
| []                                        | 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                                          |
- c( A: ?) R& r) d# Q  |2 D8 I  C% \8 A: U; j) F( W: L2 _
设置指定 port 的安全组:
+ D  v  u* O( \% c- T, C, vs1@controller:~$ neutron port-update --security-group 0aff643b-7b34-4384-b482-f37eccef5b90 29eaea66-6614-47e3-b251-0104ff9f12e2               ! `8 Z0 n; H" K
Updated port: 29eaea66-6614-47e3-b251-0104ff9f12e2" A$ W4 \. [/ C

+ u5 z5 w. c/ U设置后查看
( o& r! M5 }: a: z( ps1@controller:~$ neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id | grep 29eaea66-6614-47e3-b251-0104ff9f12e28 S9 [- O5 j' {9 t$ V. g
| [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 | 显示全部楼层
添加某个地址的安全组规则:
2 \* e6 h! ~, u: J- y  Q; B+ Kneutron 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. F. s9 d! s% y1 N' v
Created a new security_group_rule:
' g2 T7 x4 a# `+-------------------+--------------------------------------+) a* S. n- M+ J) E. f7 f/ d( c
| Field             | Value                                |- f6 X# p1 v1 S3 o0 R, g" m) X! z
+-------------------+--------------------------------------+5 E% z  W# H+ Y3 G5 F' W' x
| direction         | ingress                              |6 Q) Q4 ^1 b0 O5 A8 J: G
| ethertype         | IPv4                                 |
4 {: T# R& t' m& N2 t! Z| id                | 28613a19-85c5-4cac-b806-d25bf564ad39 |& c' o! C# l; {- X+ }
| port_range_max    | 22                                   |
, {* S9 N8 q( u" Z| port_range_min    | 22                                   |. J5 K2 J, B4 H$ F* u: m
| protocol          | tcp                                  |
! R9 s/ A0 V7 V+ S5 o, z# c| remote_group_id   |                                      |
  [5 h+ e+ T8 E; W9 c" i& D2 B| remote_ip_prefix  | 21.176.33.95/32                     |+ B5 Y, ]$ X. w
| security_group_id | 6beccc48-a119-44f2-9eb1-2f6870a71dc1 |7 @& U7 c, [: j3 C$ h4 a% o8 _# C
| tenant_id         | acb5078daac840cc86de3c8dc5d0f4fc     |
. D3 d$ m; b- @+-------------------+--------------------------------------+
 楼主| 发表于 2019-4-22 22:20:06 | 显示全部楼层
端口更新安全组:
! _4 s) E5 j+ V1 O1 g, o1 o! Lneutron 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
. w. g8 z- z5 [' `& W' aneutron 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 20:21 , Processed in 0.069319 second(s), 25 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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