1 网络
1.1查看虚拟网络平面
neutron net-list
1.2查看物理网络平面
neutron physical-net-list
neutron net-show 网络名称 | grep physical_network
1.3查看物理网卡对应关系
cat /usr/bin/ports_info | python -m json.tool|cat /usr/bin/ports_info | python -mjson.tool | grep nic
1.4查看端口规则
iptable-save |grep 虚拟机端口ID
1.5查看VDC ID
openstack project list
1.6查看网络
ovs-ofctl dump-flows br-int
1.7查看Neutron服务
cps template-instance-list –service neutron neutron-server
1.8查看neutron-openvswitch-agent
cps template-instance-list --service neutron neutron-openvswitch-agent
1.9为虚拟机添加网卡
nova interface-attach --net-id NET_ID VM_ID
1.10创建外部网络
neutron net-create base(名称) --provider:network_type vlan(类型为VLAN) --provider:segmentation_id 1700(VLAN_ID) --provider:physical_network physnet2(物理网卡) --shared --router:external true
1.11创建子网
neutron subnet-create base(子网名称) 10.148.32.0/26(子网段) --allocation-pool start=10.148.32.6,end=10.148.32.40 --name sub-base(名称) --gateway_ip=10.148.32.1(网关)
1.12指定IP添加网卡
nova interface-attach CHG1(VM_name) --net-id caa92335-84aa-4061-8b70-dc8a98b8a870(net_id) --fixed-ip 192.168.6.122(ip)
1.13更新端口IP
neutron port-update --fixed-ip subnet_id=SUBNET,ip_address=IP_ADDRPORT_ID
1.14删除网卡
nova show VM_ID 查看虚拟机的port-id
nova interface-detach 5882da8b-fea1-4291-869d-0dc4fef4a82a(VM_ID) 0ec1f964-4d3f-4e08-9ff4-fb338c345ed1 (port-id)
1.15查看子网、端口、内大网IP、网段等信息
查看网络状态:neutron net-show id
查看子网信息:neutron subnet-show subnet_id
查看子网使用的所有ip地址:neutron port-list |grep subnet_id
查看某个ip地址的使用情况:neutron port-show ip_id
查看大网IP信息:neutron floatingip-list | grep VM_IP
查看大网IP信息:neutron floatingip-show 内大网IP地址
1.16删除子网、端口、内大网IP、网段等信息
删除端口:neutron port-delete 端口ID
册除子网:neutron subnet-delete 子网ID
删除网络:neutron net-delete 网络ID
删除网络类型为floatingip:neutron floatingip-delete floatingip_id
1.17查看做banding的trunk对应的物理网口的命令:
cat /sys/class/net/trunk0/bonding/slaves
1.18bonding后查看逻辑网口与物理网卡对应关系:
cat /usr/bin/ports_info | python -m json.tool
1.19查看网络规划
cps hostcfg-list
1.20查看网络规划详情
cps hostcfg-show --type network group0
1.21修改trunk的MTU值
cps hostcfg-item-update --item bond --bond-name trunk0 --bond-mode nobond --mtu 9000 --type network group*
cps commit
1.22查看虚拟机网卡信息
nova interface-list VM_ID
1.23查看某个port属于哪个虚拟机
neutron port-show port-id | grep device-id
1.24 查询dhcp port的IP
neutron port-list --network_id NET_ID --device_owner network:dhcp
1.25查询dhcp server的主机
neutron dhcp-agent-list-hosting-net NET_ID
1.26查询DHCP服务
cps template-instance-list --service neutron neutron-dhcp-agent
1.27查询路由
neutron router-port-list 路由ID
1.28查询external_api vlanID
cps network-list | grep external_api
1.29与AC对帐
neutron acctrl-neutron-sync --compare-data
1.30进命名空间
ip netns
1.31查看内大网配置
ip netns execfip-4fdb1752-6787-49db-ad5a-805b2a9ac791 ifconfig
1.32ping内大关
ip netns exec fip-4fdb1752-6787-49db-ad5a-805b2a9ac791 ping 内大网网关
1.33各种网络问题排查命令
33.1 ethtool ethX 主要关注link detected是否为yes,表示联通性ok。
33.2 ethtool -i ethX 某些网络不通情况下,需要查看网卡固件版本是和虚拟机否兼容,同样的也可以在虚拟机上执行这个命令查看固件版本。
33.3 OVS网络不通排查,虚拟机--主机--交换板网络排查:
vconfig add trunk0 4012 //4012假设为虚拟机所在网络VLAN
ifconfig trunk0.4012 192.168.100.100/24
vconfig rem trunk0.4021 //排查完毕删除该接口
33.4 EVS网络不通,初步排查命令
ovs-vsctl get port tapport-id tag:用来查看虚拟机的port所带的VLAN,tapport-id是虚拟机port-id的前11位;
ovs-vsctl list-br:查询所有的ovs网桥。
ovs-vsctl add-port br-evs hnic1 00 -- set interface :如果ifconfig hnic1没有这个设备,则添加这么个设备
如果已经配置了hnic1,则查看下类型是否为hnic:ovs-vsctl list interface hnic1,查看type是否为hnic(默认是local_service),如果不是如下
ovs-vsctl -- set interface hnic1 type=hnic
vconfig add hnic1 2016
ifconfig hnic1.2016 192.168.201.6/24 //不要冲突了
ifconfig hnic1 up
vconfig rem hnic1.2016 // 排查完毕删除该接口
33.5 硬直通网络不通,初步排查命令
ip link show eth3 //eth3为用作硬直通的网卡
ifconfig eth0 192.168.20.16/24 up,登陆虚拟机,配置IP
vconfig add eth3 2016 // 登陆虚拟机所在主机,2016 为虚拟机eth0网卡所使用的vlan
ifconfig eth3.2016 192.168.20.17/24 // 配置IP
vconfig rem eth3.2016 //排查完毕删除该接口
33.6 IP冲突排查,以下以FS external_api可能冲突为例,只关注命令
非Haproxy所在节点配置:ip addr show external_api
如果没有同网段的,需要配置一个IP:ip addr add 128.22.225/24 dev external_api
重复操作arping 检测 正向代理、反向代理 IP 以及网关IP 是否有冲突:arping 128.22.22.10 -I external_api
正常如下,只返回一个MAC地址,否则就是IP冲突了。
注:交换机上配置对应VLAN的vlanif并配置测试IP,测试完要删除。
1.34网络不通问题排查
关于tcpdump,有时候网络不通的问题,手段到了山穷水尽的时候,就试下这几个常用命令,附件有工具
监视指定方向和接口的包1:tcpdump -i eth0 src host 10.126.1.222
监视指定方向和接口的包2:tcpdump -i eth0 dst host 10.126.1.222
监视指定主机和另外主机之间得通信:tcpdump host 10.126.1.222 and (10.126.1.1 or 10.126.1.13 )
2 EIP
2.1查看EIP绑定关系
根据虚拟机的私网ip查询其绑定的内大网IP地址和EIP
neutron floatingip-list | grep <虚拟机ip>
2.2创建fip
neutron floatingip-create <floatingip_network>
2.3绑定fip给虚拟机的私有IP
neutron floatingip-associate <FLOATINGIP_ID> <PORT_ID>
2.4解绑定fip给虚拟机的私有IP
neutron floatingip-disassociate <FLOATINGIP_ID>
2.5删除fip
neutron floatingip-delete <FLOATINGIP_ID>
2.6查看网络节点in和out vlan
级联层执行:
cps template-params-show --service nat-server neutron-l3-nat-agent01
2.7确认内大网网关
在被级联层控制节点执行:
neutron subnet-list , neutron net-list,neutron subnet-show subnetid
neutron subnet-show subnet-id
2.8查看
在被级联层任一节点执行:
cps template-ext-params-show --service network-agent neutron-dvr-compute-agent
3 安全组
3.1全局关闭安全组
#配置nova-compute。 在云数据中心场景,以对接FC为例,在FusionCompute的系统--第三方对接,可以看到是否需要开启安全组,尽管web-ui上可能已经全局关闭了安全组,但如果这里还是开启的,虚拟机也会出现安全组的典型虚拟机网络不通现象,此时需要排查这里。
cps template-params-update --service nova nova-compute --parameter security_group_api=nova firewall_driver=nova.virt.firewall.NoopFirewallDriver libvirt_vif_driver=nova.virt.libvirt.vif.LibvirtGenericVIFDriver
#配置neutron-server。
cps template-params-update --service neutron neutron-server --parameter firewall_driver=neutron.agent.firewall.NoopFirewallDriver
cps template-params-update --service neutron neutron-server --parameter enable_security_group=False
#配置neutron-openvswitch-agent。
cps template-params-update --service neutron neutron-openvswitch-agent --parameter firewall_driver=neutron.agent.firewall.NoopFirewallDriver
cps template-params-update --service neutron neutron-openvswitch-agent --parameter enable_security_group=False
cps template-params-update --service neutron neutron-openvswitch-agent --parameter enable_ipset=False
3.2安全组相关
安全组开关打开后,创建的虚拟机会加入到一个默认安全组,此时从外面ping该虚拟机默认是不通的,需要作如下处理。
安全组开关打开后,neutron 安全组相关的命令能够执行,如果没有开启,会报404
创建安全组
neutron security-group-create 安全组名称
B)为安全组增加规则
安全组内的虚拟机配置EIP后,能够从外部ping ,需要配置ICMP规则,方向为ingress:
neutron security-group-rule-create 名称或ID –direction ingress –protocol ICMP –remote-ip-prefix 0.0.0.0/0
安全组内的虚拟机配置EIP后,能够从外部SSH,需要配置TCP规则和端口号,方向为ingress:
neutron security-group-rule-create 名称或ID –direction ingress –protocol TCP –remote-ip-prefix 0.0.0.0/0 –port-range-min 0 –port-range-max 65535
安全组内的虚拟机配置EIP后,能够从外部SSH,需要配置UDP规则和端口号,方向为ingress:
neutron security-group-rule-create 名称或ID –direction ingress –protocol UDP –remote-ip-prefix 0.0.0.0/0 –port-range-min 0 –port-range-max 65535
3.3修改安全组的规则
根据安全组的ID,修改安全组的规则,例如修改为全部允许通过
neutron security-group-rule-create --direction ingress --remote-ip-prefix 0.0.0.0/0 de6d2cef-6be2-4d9e-bb15-64fb44884ed4 (安全组ID)
3.4更多安全组命令
neutron security-group-create Create a security group.
neutron security-group-delete Delete a given security group.
neutron security-group-list List security groups that belong to a given tenant.
neutron security-group-rule-create Create a security group rule.
neutron security-group-rule-delete Delete a given security group rule.
neutron security-group-rule-list List security group rules that belong to a given tenant.
neutron security-group-rule-show Show information of a given security group rule.
neutron security-group-show Show information of a given security group.
neutron security-group-update Update a given security group.
4 日志
4.1Neutron-api日志路径
三个控制节点上:
/var/log/fusionsphere/operate/neutron-api/
4.2Neutron-server日志路径
三个控制节点上路径:
/var/log/fusionsphere/component/neutron-server/
4.3Neutron日志路径
三个控制节点上路径:
/var/log/fusionsphere/component/neutron/
4.4Neutron- dhcp-agent日志路径
三个dhcp-agent服务节点上
查看服务命令:
cps template-instance-list –service neutron neutron-dhcp-agent
日志路径:
/var/log/fusionsphere/component/neutron-dhcp-agent/
4.5Neutron-openvswitch-agent日志路径
type1场景下查看被级联层的虚拟机所在计算节点,type2/3,NFV在虚拟机所在计算节点搜索
日志路径:/var/log/fusionsphere/component/neutron-openvswitch-agent/