一、router相关命令
1)Router的创建
neutron router-create {name} --ha true --distributed true --ext ext --disable-snat
|
–ext ext 后面的ext对应的是network list的ext 外部网络
neutron router-create {name} --ha false --distributed true --legacy true --ext ext-toc -- enable -snat
|
–ext ext 后面的ext-toc对应的是network list的ext-toc 外部网络
2)Router绑定(解绑)子网
neutron router-interface-add {router_id} {subnet_id}
neutron router-interface-delete {router_id} {subnet_id}
|
3)Router增删route规则
neutron router-add-route {router_id} --route source =CIDR,destination=CIDR,nexthop=IP_ADDR, type =TYPE,peer_route_id=PEER_ROUTE_ID
neutron router-remove-route {router_id} --route source =CIDR,destination=CIDR,nexthop=IP_ADDR, type =TYPE,peer_route_id=PEER_ROUTE_ID
|
上述命令中destination=CIDR,nexthop=IP_ADDR是必须的参数,其他是可选的。
4)Router增加ipv6子网限速
neutron router-add-qos {router_id} --router-qos subnet=SUBNET_ID,qos=QOS_POLICY_ID
neutron router-remove-qos {router_id} --router-qos subnet=SUBNET_ID,qos=QOS_POLICY_ID
|
5)通知l3 agent增加/删除router
neutron router-add-to-host {router_id} --host {host_name}
|
该命令通知指定物理节点上的l3 agent创建router。创建时l3 agent会从neutron server同步router信息,如果router不在物理机上,跳过创建router的步骤。
可用于修复某个计算节点上的指定DVR缺失,或指定DVR的接口缺失。
neutron router-add-to-host {router_id}
|
针对所有应该有该qrouter的host进行修复,会影响多个节点。
neutron router-remove-from-host {router_id} --host {host_name}
|
该命令通知指定物理节点上的l3 agent删除router。
注意一下,上述命令不会对数据库做改动,只是通知相应的l3 agent
二、NAT相关命令
1)创建NAT
neutron nat-create {name} --ext ext --subnet {subnet_id} --flavor {flavor}
|
其中--flavor {flavor}时可选的,–ext ext 后面的ext对应的是network list的ext 外部网络
2)更新NAT
neutron nat-update {nat_id} --name {name} --flavor {flavor} -subnet {subnet_id}
|
上述参数都是可选的
3)查询NAT
neutron nat-list
neutron nat-show {nat_id}
|
三、snat相关命令
1)创建snat
neutron snat-create {floating_ip_id} --subnet {subnet_id}
|
2)删除snat
neutron snat-delete {snat_id} {floating_ip_id}
|
3)查询snat
neutron snat-list {floating_ip_id}
neutron snat-show {snat_id} {floating_ip_id}
|
四、dnat相关命令
1)创建dnat
neutron dnat-create {floating_ip_id} --ext-port {ext_port_num} --int-port {inter_port_num} --ip-address {inter_port_address} --port {inter_port_id} --protocol PROTOCOL
|
PROTOCOL从{tcp, udp, icmp,any}四种中选
2)删除dnat
neutron dnat-delete {dnat_id} {floating_ip_id}
|
3)查询dnat
neutron dnat-list {floating_ip_id}
neutron dnat-show {dnat_id} {floating_ip_id}
|
五、floating pool相关命令
1)创建floating pool
neutron floatingpool-create {name} -network {network_id}
|
2)删除floating pool
neutron floatingpool-delete {floating_pool_id}
|
3)查询floating pool
neutron floatingpool-list
neutron floatingpool-show {floating_pool_id}
|
4)Floating pool增加(移除)子网
neutron floatingpool-add-subnet {floating_pool_id } --subnet {subnet_id}
neutron floatingpool-remove-subnet {floating_pool_id } --subnet {subnet_id}
|
六、floating ip相关命令
1)指定floating pool id创建floatingip
neutron floatingip-create ext --floating-pool {floating_pool_id} --subnet {subnet_id} --qos-policy {qos_policy_id}
|
其中 --floating-pool {floating_pool_id} --subnet {subnet_id} --qos-policy {qos_policy_id} 三个参数都是可选的
七、port相关命令
1)指定多子网创建port
neutron port-create {network_id} --validate-subnets {subnet_id}
|
其中 --validate-subnets 可以重复,由此可指定多个子网,port的ip会从指定的子网中选出。
八、agent相关命令
1)触发指定agent的更新
neutron agent-update {l3_agent_id} --update
|
可修复某个计算节点上的DVR缺失,或DVR接口缺失,影响该节点所有路由器。
九、network相关命令
1)创建network
openstack network create {network_name}
|
2)创建subnet
openstack subnet create --network {network_name} --subnet-range {subnet_range} {subnet_name}
|
十、networkID和routerID互查
1)通过networkID查routerID
qr_port_id=$(openstack port list --network {network_id} --device-owner network:router_interface_distributed -c id -f value)
openstack port show ${qr_port_id} -c device_id
|
查出router在该网络里的qr口,qr口的device_id即为router_id
2)通过routerID查networkID
qr_port_id=$(openstack port list --device- id {router_id} --device-owner network:router_interface_distributed -c id -f value)
openstack port show ${qr_port_id} -c network_id
|
查出该router在网络里的qr口,qr口有记录network_id
十一、DHCPS agent调度
1)查询network的dhcp落在哪些节点
neutron dhcp-agent-list-hosting-net {network_id}
或
openstack network agent list --network {network_id}
|
2)调度到指定节点
neutron dhcp-agent-network-add {dhcp_agent_id} {network_id}
或
openstack network agent add network --dhcp {dhcp_agent_id} {network_id}
|
3)从指定节点删除
neutron dhcp-agent-network-remove {dhcp_agent_id} {network_id}
或
openstack network agent remove network --dhcp {dhcp_agent_id} {network_id}
|
4)查看dhcp agent及其id(dhcp_agent_id)
openstack network agent list --agent- type dhcp
|
十二、NAT网关调度
1)查询NAT网关落在哪些节点,及主备情况
neutron l3-agent-list-hosting-router {router_id}
或
openstack network agent list --router {router_id} --long
|
2)调度到指定节点
neutron l3-agent-router-add {l3_agent_id} {router_id}
或
openstack network agent add router --l3 {l3_agent_id} {router_id}
|
3)从指定节点删除
neutron l3-agent-router-remove {l3_agent_id} {router_id}
或
openstack network agent remove router --l3 {l3_agent_id} {router_id}
|
4)查看l3 agent及其id(l3_agent_id)
openstack network agent list --agent- type l3
|