找回密码
 注册
查看: 4789|回复: 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
) _9 E! M9 \7 X- Z5 N+----------------------+--------------------------------------------------------------------+
7 J1 K1 }( _' I4 I8 Q| Field                | Value                                                              |
7 f5 ]; l+ X8 `6 x9 ], a& Y+----------------------+--------------------------------------------------------------------+
2 {6 J( R/ t9 S$ o9 b& p| description          |                                                                    |
) H( D& Q9 z/ {2 y6 Y| id                   | 5c5d9d5e-fe6b-4f04-ae91-650da50fe76c                               |
: w, o+ B4 B  a, Y; J| name                 | SDN-lr-test                                                        |
- ~% D$ M8 J' @/ P* b. T( \| security_group_rules | {                                                                  |+ e2 R$ v& j$ v! e! o
|                      |      "remote_group_id": null,                                      |4 [. K6 ^3 J- X- S9 Y* L! \! }
|                      |      "direction": "egress",                                        |
/ X/ @* v" }0 m: U7 W' h1 ||                      |      "remote_ip_prefix": null,                                     |
  x( }$ `  M8 s1 p  ~% ~. D+ {|                      |      "protocol": null,                                             |
: G7 T) D1 s% b% ^/ v|                      |      "tenant_id": "acb5078daac840cc86de3c8dc5d0f4fc",              |# G2 R3 E8 W6 j+ V8 I2 r, d# W2 q) H' g
|                      |      "port_range_max": null,                                       |
- r" ~0 D! F& u8 [6 C6 ^3 ^|                      |      "security_group_id": "5c5d9d5e-fe6b-4f04-ae91-650da50fe76c",  |
$ S1 o5 ^' ^  g! Y( t' F+ I|                      |      "port_range_min": null,                                       |
- @4 ?. W$ h. v6 w4 P|                      |      "ethertype": "IPv6",                                          |
# ~. W0 T7 L5 B# i2 W5 ~|                      |      "id": "06ba5ec0-725d-4bd1-80ad-910048e2658b"                  |
; M, F0 E" B1 R|                      | }                                                                  |
" g4 e, ~' [/ ?) D+ S* V' n|                      | {                                                                  |
7 x* {# ^/ E0 K. T/ C% T; n0 j' i|                      |      "remote_group_id": null,                                      |- c7 F1 L& [  W
|                      |      "direction": "egress",                                        |
8 }7 e( t7 z& `* R% Q2 C( i|                      |      "remote_ip_prefix": null,                                     |
* k) L! d0 U* `: A9 O$ @9 Z  t! @" {|                      |      "protocol": null,                                             |
- }8 X. h2 v1 d|                      |      "tenant_id": "acb5078daac840cc86de3c8dc5d0f4fc",              |
& Y0 t% C8 J& [, i) L/ ^|                      |      "port_range_max": null,                                       |! k; g, W& t$ V
|                      |      "security_group_id": "5c5d9d5e-fe6b-4f04-ae91-650da50fe76c",  |5 E% m- E/ j/ {
|                      |      "port_range_min": null,                                       |! A, j/ f! k! `6 D2 ^
|                      |      "ethertype": "IPv4",                                          |2 k, L  \; t+ _
|                      |      "id": "e11c1d8c-9536-4ba1-aa54-3b6be5089c1c"                  |! [$ `( i  s  v0 A8 x' ?  g0 c
|                      | }                                                                  |1 G' w0 c  E4 s1 T
| tenant_id            | acb5078daac840cc86de3c8dc5d0f4fc                                   |; k: L- a' Y  ^9 ?9 Q
+----------------------+--------------------------------------------------------------------+

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 M# _3 r# b- a& c' b8 a0 V例子:neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id  |grep 41c9fa3f-22ce-4116-ad31-f81992693d29' x: ?6 r9 e& ?4 x
| [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"}    |                              
! J! S" P- _& {. B+ r5 q5 C- H5 k! V. F, G0 u# n4 K7 r
neutron port-list -c id -c mac_address -c fixed_ips -c device_id  -c security_groups |grep 41c9fa3f-22ce-4116-ad31-f81992693d29" `$ M- k6 t/ X/ i+ w
| 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']                                                                                                                                                                     |
. x+ b: w! ~9 Y% ]' n

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2019-4-17 09:55:43 | 显示全部楼层
列表 安全组:
+ R5 w: ]. @. }* |8 u& J6 X. x* v) w6 s6 S" ]' J7 D  X, r
s1@controller:~$ neutron security-group-list" G0 a0 }6 p2 X; |. [  |3 f/ q9 X: w. \
+--------------------------------------+------------+-------------+
9 c0 v6 X3 t6 l4 }7 C, f, O. d| id                                   | name       | description |
: ^- K% \( y! W9 s+--------------------------------------+------------+-------------+
4 x$ B6 y3 o+ y| 0aff643b-7b34-4384-b482-f37eccef5b90 | sg-all-ssh | allow ssh   |
4 C; I$ k! R# K! o+ S4 d* ^| c98a2a3f-1b06-429d-b419-aa862662f116 | default    | default     |, v/ f2 Q  E0 {1 ~. Q/ U! A/ C. J
| f5377a66-803d-481b-b4c3-a6631e8ab456 | default    | default     |
2 _* j- G& v0 V+--------------------------------------+------------+-------------+
2 k% ?7 ], Y) @$ T) F$ d, S
( n. u& G6 t$ i1 {. b# Q( x8 V% |+ k列表配置了某安全组的所有 port:. |$ M( }0 E. n/ Y3 g6 g
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
! a' L6 z& O' u. _; t| [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                                          |
& o( t8 d" D3 f5 N2 z" A/ L| [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
% _: e9 Q6 b3 d) S& e
; w$ ]2 i5 A$ W$ b. q9 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
( a% C+ S) {9 K2 g! c' O+ 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                                          |2 F1 J: T* M% ?
6 D, a" `6 d# ~3 x" O  c# ^5 W# p
删除指定 port 的安全组:: ]& G# y7 O% @, ~6 I# d
s1@controller:~$ neutron port-update --no-security-groups 29eaea66-6614-47e3-b251-0104ff9f12e2
- ~- [# U  o' I4 B+ P% P( ~& {Updated port: 29eaea66-6614-47e3-b251-0104ff9f12e2
" x- j3 o+ z' o/ e' W8 `   j( w" |1 o3 _$ h( p: l
删除后查看:$ q* i; |% n  a0 L
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
$ x2 A2 N! H. R- [. 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                                          |5 r. Y& u: [% c3 F: [4 }
# Q( X' l0 G: a/ S/ ^* T
设置指定 port 的安全组:
6 M% r7 A5 h% ?1 us1@controller:~$ neutron port-update --security-group 0aff643b-7b34-4384-b482-f37eccef5b90 29eaea66-6614-47e3-b251-0104ff9f12e2               
3 T' c/ |4 S8 oUpdated port: 29eaea66-6614-47e3-b251-0104ff9f12e2
/ k3 V8 G- m* l4 [1 U9 V4 \1 {4 ?. B
设置后查看
& u0 y( Y. S& `6 zs1@controller:~$ neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id | grep 29eaea66-6614-47e3-b251-0104ff9f12e22 W( ?3 b# C2 c; ^
| [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 | 显示全部楼层
添加某个地址的安全组规则:
- ?7 N  p7 o9 f. S& P# k* N/ Bneutron 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( X$ T# O2 f: ]+ |% U9 C/ K
Created a new security_group_rule:' ]" `( \$ l+ G) }& O
+-------------------+--------------------------------------+
) ?+ E3 o; b7 H* r- E, E) l| Field             | Value                                |
" k! a: C/ d4 f* M. Q+-------------------+--------------------------------------+9 L$ ]/ x; x- l% E2 v' N  C
| direction         | ingress                              |
( ^/ D! n# N) u, J! K| ethertype         | IPv4                                 |  F% O/ H+ H8 }8 i* }
| id                | 28613a19-85c5-4cac-b806-d25bf564ad39 |$ p+ M4 S! p& r8 W* [+ [- Q& H
| port_range_max    | 22                                   |
, R: w3 ^" S" B( X  W% G. p| port_range_min    | 22                                   |
0 w$ y: ~: z! j+ b. _, M| protocol          | tcp                                  |1 t" e% X! A0 b% P
| remote_group_id   |                                      |2 `7 S) Y7 k7 Z. U3 z' ?- P
| remote_ip_prefix  | 21.176.33.95/32                     |2 E7 [' A0 S$ D1 ]6 B9 c  i
| security_group_id | 6beccc48-a119-44f2-9eb1-2f6870a71dc1 |9 S& `  _+ P6 R' k- @
| tenant_id         | acb5078daac840cc86de3c8dc5d0f4fc     |
. R) V; v/ C) c6 Z. v# b+-------------------+--------------------------------------+

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2019-4-22 22:20:06 | 显示全部楼层
端口更新安全组:7 b6 L) Q7 R2 ]1 ]' X/ }
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( X" U3 U$ u# [- ?2 W
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:21 , Processed in 0.020069 second(s), 26 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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