易陆发现互联网技术论坛

 找回密码
 开始注册
查看: 4787|回复: 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
1 U- e' _; W& Q2 g3 \' M+----------------------+--------------------------------------------------------------------+! {! u9 ]. p1 m0 D& U3 y8 r( e
| Field                | Value                                                              |
, f! `7 Z! Q8 w/ x; S8 f- n: k+----------------------+--------------------------------------------------------------------+
, ^5 ^  N' |: P- f1 ^+ `, k- F| description          |                                                                    |
- O% F+ ^& N4 V  x0 T| id                   | 5c5d9d5e-fe6b-4f04-ae91-650da50fe76c                               |
3 H  a7 J3 D% `/ j, w9 O| name                 | SDN-lr-test                                                        |$ D6 F1 w3 o$ h. k4 }( b
| security_group_rules | {                                                                  |
1 N0 W+ A9 ?$ Q2 e3 }* N|                      |      "remote_group_id": null,                                      |
. o6 E( `& \1 Q: R" _|                      |      "direction": "egress",                                        |
2 l6 u- i4 T" I  g! D|                      |      "remote_ip_prefix": null,                                     |
1 z# q( C. b" t1 j|                      |      "protocol": null,                                             |
: I0 N7 G4 Y; D/ K& x& z2 p- f: U|                      |      "tenant_id": "acb5078daac840cc86de3c8dc5d0f4fc",              |1 g0 Q. H  w0 R" V+ L
|                      |      "port_range_max": null,                                       |/ U( P- I- Q  l* S. P) u4 E
|                      |      "security_group_id": "5c5d9d5e-fe6b-4f04-ae91-650da50fe76c",  |
# r& j- ?( ~" e1 }0 R|                      |      "port_range_min": null,                                       |
- h" D* y: L0 f" O! I|                      |      "ethertype": "IPv6",                                          |
2 J0 f0 [( C6 Y& O|                      |      "id": "06ba5ec0-725d-4bd1-80ad-910048e2658b"                  |
4 d% L' v/ j: B; k5 o8 s4 @5 Z|                      | }                                                                  |
0 L1 o- y2 M8 s' R- @! @|                      | {                                                                  |! F3 k) i$ R1 T- \% g
|                      |      "remote_group_id": null,                                      |% i' J* a" Q3 f6 R1 y4 e
|                      |      "direction": "egress",                                        |7 @! @8 ~. H9 ~2 O
|                      |      "remote_ip_prefix": null,                                     |
) F0 d& `+ W/ G8 U  ~|                      |      "protocol": null,                                             |+ \  d7 q+ z- x9 j  A2 A- K- `# H) R% N
|                      |      "tenant_id": "acb5078daac840cc86de3c8dc5d0f4fc",              |
% c9 n1 p% a7 P2 X1 G2 E3 s|                      |      "port_range_max": null,                                       |! A; T  B  t1 t! e) p/ [  Y6 T3 }
|                      |      "security_group_id": "5c5d9d5e-fe6b-4f04-ae91-650da50fe76c",  |
( W. O7 I; q8 H; p7 a$ z$ g|                      |      "port_range_min": null,                                       |' Q( h0 ]6 ~3 Q8 `
|                      |      "ethertype": "IPv4",                                          |: t9 ]8 w+ S. `3 y  u
|                      |      "id": "e11c1d8c-9536-4ba1-aa54-3b6be5089c1c"                  |
- _7 X. `/ ?: e|                      | }                                                                  |
! @$ o" {4 o; |) M2 ]5 O2 }0 v2 @| tenant_id            | acb5078daac840cc86de3c8dc5d0f4fc                                   |
& r  e5 K6 F* \8 ~3 s+----------------------+--------------------------------------------------------------------+
 楼主| 发表于 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, z* G2 \/ S% H( n" t
例子:neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id  |grep 41c9fa3f-22ce-4116-ad31-f81992693d29
* p( Q9 Y/ N& h1 u: M5 I" C| [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"}    |                              
$ T$ [2 U, L5 C- {  _3 w
' u+ n& q, m; O1 S) ~1 x8 w; e' k2 @neutron port-list -c id -c mac_address -c fixed_ips -c device_id  -c security_groups |grep 41c9fa3f-22ce-4116-ad31-f81992693d29% k, L2 C6 _1 ?( 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']                                                                                                                                                                     |
. T* x3 \' c9 a  |, q) Z& `
 楼主| 发表于 2019-4-17 09:55:43 | 显示全部楼层
列表 安全组:2 h7 w3 t1 p3 J1 y7 Z+ u! [3 s

6 j3 d- V$ x1 {+ k0 K# V- N- ^( D4 Bs1@controller:~$ neutron security-group-list/ ^6 Y, Q8 E+ W7 j
+--------------------------------------+------------+-------------+
6 O& |* M. l' G# p| id                                   | name       | description |, J' y2 H. k! p- t: [8 b
+--------------------------------------+------------+-------------+
0 E6 n9 {' v  c  d5 x" m* G| 0aff643b-7b34-4384-b482-f37eccef5b90 | sg-all-ssh | allow ssh   |
: N# ~9 ~) a& h& _) n! ~% {| c98a2a3f-1b06-429d-b419-aa862662f116 | default    | default     |7 L$ X: w% X9 j/ P
| f5377a66-803d-481b-b4c3-a6631e8ab456 | default    | default     |6 l' M9 H* {+ Z; T# m3 B
+--------------------------------------+------------+-------------+  c! Q. v0 V& c% v

) X: O5 a& \/ u' ]列表配置了某安全组的所有 port:
6 p9 L5 `3 H' j8 T; `, N- \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; e6 x/ {4 `6 f7 ]9 E
| [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* D; M2 x! B| [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  }, P6 ?/ j( ]' E3 w

* m$ f" T$ m) n9 w. }6 j 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
4 N* ]. N) Q8 N8 _- `9 Z& M/ i| [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                                          |) z0 d- d  m3 S1 ]5 X# r

7 I. V5 w# @  A# s7 V& Z) u: a删除指定 port 的安全组:# V: \5 d4 G" L, U
s1@controller:~$ neutron port-update --no-security-groups 29eaea66-6614-47e3-b251-0104ff9f12e2
  g9 s, w& E: B; \  [Updated port: 29eaea66-6614-47e3-b251-0104ff9f12e26 o; k7 C, B) \1 B+ S  m

5 E9 ]) r; C; ^删除后查看:
3 b/ g( e( m7 S' `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
# o2 y2 s7 s! i$ c9 L5 {| []                                        | 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                                          |
( y$ m5 v  G& h+ C& B4 F2 c  X) M
  J" Z& |& b; ~4 ]1 U设置指定 port 的安全组:, o; X6 C' ^8 q$ N+ i, a
s1@controller:~$ neutron port-update --security-group 0aff643b-7b34-4384-b482-f37eccef5b90 29eaea66-6614-47e3-b251-0104ff9f12e2               " t6 m+ A. O- }. f3 V
Updated port: 29eaea66-6614-47e3-b251-0104ff9f12e2( G3 [! {2 |3 d7 N" C

) U% O; |& ]% ]& j设置后查看
8 `- A2 d& Q( d& R5 O8 Os1@controller:~$ neutron port-list -c security_groups -c id -c mac_address -c fixed_ips -c device_id | grep 29eaea66-6614-47e3-b251-0104ff9f12e2
+ H( x: K( i" t  ]| [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 | 显示全部楼层
添加某个地址的安全组规则:" |6 `# X% I; ~6 s
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- t( T; f% e4 D9 i" dCreated a new security_group_rule:
. l) g) L: f# A; Q' {; o; {+ e+-------------------+--------------------------------------+
* c- a# ^( A: q+ k3 j/ g: v| Field             | Value                                |' D7 n- h* {' X4 Q
+-------------------+--------------------------------------+- v, e8 w. N3 r- s& }, O3 G
| direction         | ingress                              |, j* |- q; O( t" c; _- n: I
| ethertype         | IPv4                                 |% C$ j* m! V5 }/ |
| id                | 28613a19-85c5-4cac-b806-d25bf564ad39 |
8 {6 B* G% g, n| port_range_max    | 22                                   |4 L; H' |- {4 _( q6 D+ ~
| port_range_min    | 22                                   |
# k8 I- d4 C1 Y0 w9 n3 f& x| protocol          | tcp                                  |$ L. E' H  m9 j8 k
| remote_group_id   |                                      |/ Q' Z* {3 m3 d- T! k4 {
| remote_ip_prefix  | 21.176.33.95/32                     |3 e; d* U* n) b* M: P
| security_group_id | 6beccc48-a119-44f2-9eb1-2f6870a71dc1 |
. Q" z% g0 S5 s% P$ X8 d3 h| tenant_id         | acb5078daac840cc86de3c8dc5d0f4fc     |
( \* x1 V  J& f* C1 T! n: ~) {! p+-------------------+--------------------------------------+
 楼主| 发表于 2019-4-22 22:20:06 | 显示全部楼层
端口更新安全组:. `! [+ r. U, o0 F9 t$ y9 p: k
neutron 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! ]: F! X2 Z( X& v& U" z0 S9 n
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.081878 second(s), 25 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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