易陆发现互联网技术论坛

 找回密码
 开始注册
查看: 4786|回复: 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- J7 }5 o4 d" Y6 I7 i
+----------------------+--------------------------------------------------------------------+
3 J# {# ^( r3 W" H| Field                | Value                                                              |& v- E& y1 j- N0 [; j
+----------------------+--------------------------------------------------------------------+
3 b9 D) b( k0 K9 E| description          |                                                                    |
9 t* E% z4 Y+ V4 I| id                   | 5c5d9d5e-fe6b-4f04-ae91-650da50fe76c                               |
. t1 t8 u4 o4 q7 i+ [8 h1 _| name                 | SDN-lr-test                                                        |0 d5 f' T5 l1 ]8 T  W( V) _
| security_group_rules | {                                                                  |/ F$ J/ q  F0 M6 x8 p" v. R
|                      |      "remote_group_id": null,                                      |' j' Y9 R' K' s- W( J/ b3 y# p
|                      |      "direction": "egress",                                        |
6 u2 n; X, m2 Q) M8 l|                      |      "remote_ip_prefix": null,                                     |
$ `: @) w0 T% Q: v  e4 ^# k|                      |      "protocol": null,                                             |
' Q& R* T+ G/ L* }9 ]|                      |      "tenant_id": "acb5078daac840cc86de3c8dc5d0f4fc",              |
" G+ X8 Y& ]" ^9 q) i/ p+ k|                      |      "port_range_max": null,                                       |8 B1 y0 I5 N) A# i" J9 q& {" w
|                      |      "security_group_id": "5c5d9d5e-fe6b-4f04-ae91-650da50fe76c",  |
4 ]' \1 x7 v5 e# o- s: ^4 N|                      |      "port_range_min": null,                                       |
( {- J1 H/ f9 r9 @" \|                      |      "ethertype": "IPv6",                                          |
( ~) }6 |) T8 x3 @' f|                      |      "id": "06ba5ec0-725d-4bd1-80ad-910048e2658b"                  |: s4 a; u" G5 N0 r$ Y( [- q
|                      | }                                                                  |
) D+ N0 x" l8 K: @  e( N|                      | {                                                                  |
, w$ s  p: a" M; g2 U|                      |      "remote_group_id": null,                                      |+ B* j: `6 @4 \
|                      |      "direction": "egress",                                        |2 |* c8 I/ V2 f
|                      |      "remote_ip_prefix": null,                                     |
  C1 j* o5 `# {, F- Q) r! o|                      |      "protocol": null,                                             |
; f, Y" ?: e4 Z$ T: J9 Z& S|                      |      "tenant_id": "acb5078daac840cc86de3c8dc5d0f4fc",              |  }$ J$ @# N9 _5 o! z, K
|                      |      "port_range_max": null,                                       |
7 X+ J! L4 P. b|                      |      "security_group_id": "5c5d9d5e-fe6b-4f04-ae91-650da50fe76c",  |
1 u. s# h* n) q  G6 r- F|                      |      "port_range_min": null,                                       |
  c5 ?1 D$ M  u|                      |      "ethertype": "IPv4",                                          |8 ~: Y8 m2 ~! c' j8 T$ v0 U0 V
|                      |      "id": "e11c1d8c-9536-4ba1-aa54-3b6be5089c1c"                  |
7 q8 [  V5 X5 i7 {+ ||                      | }                                                                  |& `9 D2 [) ~, |9 O1 K
| tenant_id            | acb5078daac840cc86de3c8dc5d0f4fc                                   |
, E+ N% E9 d0 S" x+----------------------+--------------------------------------------------------------------+
 楼主| 发表于 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' H/ |/ T2 @2 `, K/ Q9 c
例子:neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id  |grep 41c9fa3f-22ce-4116-ad31-f81992693d29
: O- Y6 V7 O* R) P/ P| [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"}    |                              
0 G, t/ [; ^7 E- }
; i% U2 y1 q* k8 J" M* sneutron port-list -c id -c mac_address -c fixed_ips -c device_id  -c security_groups |grep 41c9fa3f-22ce-4116-ad31-f81992693d29
0 g4 {' a& L" I| 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']                                                                                                                                                                     |
+ w0 x) ]2 X: K" ~6 O$ _
 楼主| 发表于 2019-4-17 09:55:43 | 显示全部楼层
列表 安全组:/ A2 y1 p! Z3 y1 ]
0 x, W; [" o. O9 h) G  d' Q+ D) R" v0 M
s1@controller:~$ neutron security-group-list
0 D- E5 L! a0 F/ h- l+--------------------------------------+------------+-------------+  _# L& J4 u5 ?7 a5 m
| id                                   | name       | description |
% o7 w+ c% f: I) q+--------------------------------------+------------+-------------+2 N* e' H4 U) A. o9 V0 L3 x+ r" ]
| 0aff643b-7b34-4384-b482-f37eccef5b90 | sg-all-ssh | allow ssh   |
# L  F1 |, E) `; s, Z| c98a2a3f-1b06-429d-b419-aa862662f116 | default    | default     |, B6 Z9 A2 J9 F' f# b
| f5377a66-803d-481b-b4c3-a6631e8ab456 | default    | default     |; j) p4 u, W* U& [# S0 r
+--------------------------------------+------------+-------------+$ W- n9 T3 R7 J9 _

4 M! l4 ^& L/ z4 s- E, ^5 O列表配置了某安全组的所有 port:
6 ^: A+ K0 F+ W8 X: W. T/ zs1@controller:~$ neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id | grep c98a2a3f-1b06-429d-b419-aa862662f1166 M2 Q3 s5 H! H3 J9 h1 H) V- X
| [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                                          |
' Z, w! x& T, s" G* O| [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
) b  i; n9 j2 S  Y% T  D5 F& ~
4 I  a2 F6 s) r) M" h0 w3 [+ `9 | 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
6 S( A4 W/ w7 j1 j( s5 a+ P4 M| [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                                          |
* E3 ?( P" V' `9 K. s# n$ k$ L, o: m( F, N5 Y" ^; j, _3 L1 z; p
删除指定 port 的安全组:7 b: ]$ s3 X8 ^& ^" a% g3 q
s1@controller:~$ neutron port-update --no-security-groups 29eaea66-6614-47e3-b251-0104ff9f12e2- n& ], a: {& c! O3 i  q
Updated port: 29eaea66-6614-47e3-b251-0104ff9f12e2
( u6 w" a5 n7 ^" I  o3 N4 ]1 z# G 9 i1 F5 p5 C+ x/ f4 Q5 z
删除后查看:
1 j4 ^1 ~' 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
, E# d, m' n/ s+ k| []                                        | 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 H" l9 h6 S1 `* _
2 r% ?4 k! g. \* |) R设置指定 port 的安全组:
5 l5 l1 S+ D8 t( @$ ^2 }s1@controller:~$ neutron port-update --security-group 0aff643b-7b34-4384-b482-f37eccef5b90 29eaea66-6614-47e3-b251-0104ff9f12e2               * ^3 }+ Z$ m  s9 e+ J$ ?
Updated port: 29eaea66-6614-47e3-b251-0104ff9f12e2
( ?7 x. K( ~6 C3 k. v: f/ m
  c* b( n: N' `& L设置后查看
4 n5 r2 Q: A+ Y  X2 Z+ qs1@controller:~$ neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id | grep 29eaea66-6614-47e3-b251-0104ff9f12e2
2 ^* p, ?5 B# v! H% h8 \| [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 | 显示全部楼层
添加某个地址的安全组规则:
; ^3 ]7 a! c+ u; D  sneutron 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
' o- U4 ~0 \9 Y) g  l6 }# \Created a new security_group_rule:
& N- s6 b% C- J  V" i  J+-------------------+--------------------------------------+
. N' o; d# C/ \* g2 {| Field             | Value                                |5 h4 Z( O4 @5 [+ b* F" X
+-------------------+--------------------------------------+7 c9 f) v. q* @2 K" v3 F
| direction         | ingress                              |
, z$ `4 I+ z% q( |: g* D/ N7 E4 S| ethertype         | IPv4                                 |
7 m( Y7 ?- `! r& P& k. e| id                | 28613a19-85c5-4cac-b806-d25bf564ad39 |2 T- Z" S/ b% z+ K! A+ O2 K7 R
| port_range_max    | 22                                   |# h3 C3 J# X8 G! n. |
| port_range_min    | 22                                   |
. O1 ]+ m3 F; d) t+ Z0 {$ i/ || protocol          | tcp                                  |
6 }. X1 R, e& K0 N( g| remote_group_id   |                                      |
+ L5 C" s  I& x| remote_ip_prefix  | 21.176.33.95/32                     |
. D: m2 k1 n8 D$ ~3 r3 T9 v4 [| security_group_id | 6beccc48-a119-44f2-9eb1-2f6870a71dc1 |
& o% k1 t) H( s+ S* h) P$ {- q| tenant_id         | acb5078daac840cc86de3c8dc5d0f4fc     |
" W8 Y" U1 M; U) s+-------------------+--------------------------------------+
 楼主| 发表于 2019-4-22 22:20:06 | 显示全部楼层
端口更新安全组:
2 m% h2 q, v$ L% Kneutron 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+ [  [2 }: I5 O& o) v8 K5 A- V: m% ~% }
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
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

站长推荐上一条 /4 下一条

北京云银创陇科技有限公司以云计算运维,代码开发

QQ|返回首页|Archiver|小黑屋|易陆发现技术论坛 点击这里给我发消息

GMT+8, 2026-4-8 10:39 , Processed in 0.057515 second(s), 25 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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