找回密码
 注册
查看: 4791|回复: 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
) B. P8 z* w9 a& Y4 h  ?: Y+----------------------+--------------------------------------------------------------------+
+ Y8 J- L, ~2 X# A7 E| Field                | Value                                                              |
5 w& J+ X4 H( R* ~4 a6 e; C% G4 A+----------------------+--------------------------------------------------------------------+
& h" ^" B' N. y0 ?| description          |                                                                    |- P# o( B' W0 v5 ^8 v, z
| id                   | 5c5d9d5e-fe6b-4f04-ae91-650da50fe76c                               |- Y8 l6 G, @5 }  x$ O+ ^& X
| name                 | SDN-lr-test                                                        |6 v! W3 O! t( G7 M5 w0 E! A& D+ M& u
| security_group_rules | {                                                                  |
8 U: f- N/ r1 F$ Z|                      |      "remote_group_id": null,                                      |' C" y4 T8 T  ^! D8 i! _; K
|                      |      "direction": "egress",                                        |
- l: [1 p' m9 E* Z" c  H" I|                      |      "remote_ip_prefix": null,                                     |
% f% e) U1 ]  Y  g|                      |      "protocol": null,                                             |3 g- b! `) M# a4 g9 r" q
|                      |      "tenant_id": "acb5078daac840cc86de3c8dc5d0f4fc",              |
3 V" p9 `  L% N7 d) C+ R|                      |      "port_range_max": null,                                       |9 F8 L& ]$ X9 f7 M  h; d
|                      |      "security_group_id": "5c5d9d5e-fe6b-4f04-ae91-650da50fe76c",  |  K* X0 C1 @+ K2 D5 O
|                      |      "port_range_min": null,                                       |
5 W# ]( r! h" o; o9 ?) k|                      |      "ethertype": "IPv6",                                          |$ h& \6 d( }' j. R- {
|                      |      "id": "06ba5ec0-725d-4bd1-80ad-910048e2658b"                  |
- [+ S* p' O/ H' w|                      | }                                                                  |
. F' R( k, ]2 B|                      | {                                                                  |
% E; A* p6 H1 W2 t: }|                      |      "remote_group_id": null,                                      |! W; Y; h: J% W4 q; j3 ?  x
|                      |      "direction": "egress",                                        |- `( }( m6 s7 q! M. U' Z) X; f) _
|                      |      "remote_ip_prefix": null,                                     |
. E" `& q6 }  X" w3 J+ a|                      |      "protocol": null,                                             |
! v# r8 d0 J( h) {. b|                      |      "tenant_id": "acb5078daac840cc86de3c8dc5d0f4fc",              |5 d/ Z5 _/ x, s6 S; c; w% I- U
|                      |      "port_range_max": null,                                       |
. S$ E7 ?* ?- T2 l|                      |      "security_group_id": "5c5d9d5e-fe6b-4f04-ae91-650da50fe76c",  |: Y* b% r& w0 I8 I5 Y6 t3 ]& P
|                      |      "port_range_min": null,                                       |
! @; C: g3 ^' D5 a|                      |      "ethertype": "IPv4",                                          |1 ]6 A1 a1 r9 Z2 B: |
|                      |      "id": "e11c1d8c-9536-4ba1-aa54-3b6be5089c1c"                  |; t1 y: Z+ s: U+ _8 T3 ~' D
|                      | }                                                                  |
& W  f- _% T# T# O3 o# U" p# ]9 g| tenant_id            | acb5078daac840cc86de3c8dc5d0f4fc                                   |
7 Q: l8 O* h) B$ Q% J+----------------------+--------------------------------------------------------------------+

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' N" ^- i! D1 J% F
例子:neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id  |grep 41c9fa3f-22ce-4116-ad31-f81992693d29
0 Q. V4 B0 y8 b1 y6 H| [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"}    |                               ) S: N6 t( T- H

' t( O) }# w- Zneutron port-list -c id -c mac_address -c fixed_ips -c device_id  -c security_groups |grep 41c9fa3f-22ce-4116-ad31-f81992693d29
- K# c* z3 H: |9 @| 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']                                                                                                                                                                     |; q6 g7 B4 P0 |& j

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2019-4-17 09:55:43 | 显示全部楼层
列表 安全组:  V' P; }; x4 _7 }. b5 s/ }2 F

# S5 \' {% k; m3 o7 W) n; ~- es1@controller:~$ neutron security-group-list
9 n1 h+ N3 L/ k1 k, R- {+--------------------------------------+------------+-------------+0 X% p- g& [2 U, r0 i
| id                                   | name       | description |9 M/ }/ ~3 ~3 T& p& m- i0 Y4 I3 i
+--------------------------------------+------------+-------------+) W2 t, S$ j* g; {$ d' b
| 0aff643b-7b34-4384-b482-f37eccef5b90 | sg-all-ssh | allow ssh   |
. G$ j* e7 B. h, ]0 ^: k| c98a2a3f-1b06-429d-b419-aa862662f116 | default    | default     |
: O' I$ M( i' w7 k) J4 q5 K| f5377a66-803d-481b-b4c3-a6631e8ab456 | default    | default     |, G" g& o  q3 s1 ~; W0 I" r
+--------------------------------------+------------+-------------+4 n6 T- j: F2 x; j9 }1 `4 n/ C
6 `. `2 X4 l  i+ E! u
列表配置了某安全组的所有 port:5 P. w) I9 U( E
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
) T/ z# o1 ]: U; x% Q/ L( O| [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                                          |- u- x9 o' H# 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-1e520b9c28306 Q7 z2 `3 I% L4 B) d6 ^/ W
: g/ q( e0 G# y" [& r9 i
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/ u8 x8 J; G( ?2 S3 R- Q( t8 e
| [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                                          |) [. h( Q6 q4 k2 L( t9 {/ V

' [( _8 M1 H" k. I删除指定 port 的安全组:; D4 ]0 K1 P( d  a1 ^, w
s1@controller:~$ neutron port-update --no-security-groups 29eaea66-6614-47e3-b251-0104ff9f12e2" a; x9 _2 F" T
Updated port: 29eaea66-6614-47e3-b251-0104ff9f12e28 A2 o: @2 G7 L. S' `$ k/ f
1 n+ p1 p) f$ e
删除后查看:5 c( u$ ?( N; _. h
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) L* r! l. @+ y& @; }$ j6 W/ ]
| []                                        | 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                                          |
/ A: K4 g8 _  ^# X; e8 w: c! t: ]" H  K! d. y8 V6 m8 \; X/ H
设置指定 port 的安全组:# [2 N/ T6 ]) k- _+ ~
s1@controller:~$ neutron port-update --security-group 0aff643b-7b34-4384-b482-f37eccef5b90 29eaea66-6614-47e3-b251-0104ff9f12e2               , L( I1 u# q" o7 c! }: |7 i5 O0 i
Updated port: 29eaea66-6614-47e3-b251-0104ff9f12e2$ H% k4 G" k% [! o+ |9 u! N

; Y' s  x5 t3 P设置后查看
! p5 k0 v, X9 T5 ws1@controller:~$ neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id | grep 29eaea66-6614-47e3-b251-0104ff9f12e2
+ `* P" W/ @! R$ i* A; R6 s  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

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2019-4-19 14:26:01 | 显示全部楼层
添加某个地址的安全组规则:* _9 J- ^- y2 {  J; J' p
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
# @- f  k0 y- d) ^Created a new security_group_rule:
3 b) l0 C8 ?6 ~, \) t9 K+-------------------+--------------------------------------+3 s, H1 `8 D% S4 r, {" O. P( `
| Field             | Value                                |$ S3 W2 }# B9 `$ C+ D7 E
+-------------------+--------------------------------------+  T# }' G) e% n. H6 d
| direction         | ingress                              |- b0 m9 x" d7 [: ~
| ethertype         | IPv4                                 |
$ v0 y- T+ Q: w2 }1 p1 q, y| id                | 28613a19-85c5-4cac-b806-d25bf564ad39 |
+ V  L; B3 P5 T$ Q0 U- V% O) }$ k6 |/ Q| port_range_max    | 22                                   |
2 t! {- k( j  a: x+ u; M| port_range_min    | 22                                   |
- A8 J$ p3 T! K* b. G7 l7 q| protocol          | tcp                                  |
' Z- L! W. E" M8 o| remote_group_id   |                                      |
$ P% W$ \9 i" P7 v7 x* z| remote_ip_prefix  | 21.176.33.95/32                     |4 ~, z* o. q1 h5 s- q1 X
| security_group_id | 6beccc48-a119-44f2-9eb1-2f6870a71dc1 |
/ |) k( w% D* z7 c/ j' w- k& N| tenant_id         | acb5078daac840cc86de3c8dc5d0f4fc     |: E  R3 ]& ?0 j- B, |2 X
+-------------------+--------------------------------------+

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2019-4-22 22:20:06 | 显示全部楼层
端口更新安全组:
* v7 J* b1 z" W+ T, Qneutron 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
( m( P& K! P& k* Oneutron 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:29 , Processed in 0.031212 second(s), 26 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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