码迷,mamicode.com
首页 > 系统相关 > 详细

2017-9-3 关于Linux网卡一系列问题的解决案例

时间:2017-09-03 23:37:15      阅读:269      评论:0      收藏:0      [点我收藏+]

标签:view   members   mod   sharp   ref   systemctl   dock   .net   外包   

   

   这几个月发生的事情还是蛮多的,换了个新公司,OpenStack的收获还是有的,当然这都是得靠自己来学,但是完全进入一个外包项目的感觉,我有点不舒服。如果做什么,都要文档的话,那么我的创造性思维不是被抹杀了吗?我相信自己的学习能力,所以自己一定要有意识,日积月累就能厚积薄发。唉,但我感觉自己还是有点失败,人生时不时都会迷茫,我对生活和技术都是永远不满足的,我知道我现在的最大优势就是年轻,我还不到22岁。不说废话了,下面都是我一个月内的工作笔记,方便以后用到。

 

一、如何判断多个网口是否在同一个网卡上?

查看每个网口的物理适配器即可,如果PHYAD相同,则在同一个网卡上,否则不在。
[root@fuel ~]# ethtool eth0|grep -i phyad
PHYAD: 0
[root@fuel ~]# ethtool eth1|grep -i phyad
PHYAD: 1

二、换硬盘不重启的解决案例

参考文档:http://blog.csdn.net/zhengwei125/article/details/53928061
[root@node /]# echo "- - -" > /sys/class/scsi_host/host2/scan    //主要命令

1. 添加了磁盘后查看,没有刷新出来

[root@node /]# fdisk -l
Disk /dev/sda: 17.2 GB, 17179869184 bytes

2. 查看主机总线号

root@node /]# ls /sys/class/scsi_host/
host0 host1 host2
3.重新扫描SCSI总线来添加设备
[root@node /]# echo "- - -" > /sys/class/scsi_host/host0/scan
[root@node /]# echo "- - -" > /sys/class/scsi_host/host1/scan
[root@node /]# echo "- - -" > /sys/class/scsi_host/host2/scan
4. 查看磁盘,可以看到 /dev/sdb  这个就是新加的盘

[root@node /]# fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

三、配置辅助IP用于访问外网,用于解决单网卡无法上网问题,也就是说一个网卡多个IP地址。

注:如果是虚拟机最好选择桥接模式

[root@roller ~]# ifconfig eth0:0 172.16.17.138
[root@roller ~]# ip r ##查看路由
[root@roller ~]# ip r delete default via 10.20.0.1 dev eth0 ##删除旧的默认网关
[root@roller ~]# ip r add default via 172.16.17.254 dev eth0 ##修改新网关
[root@roller ~]# cat /etc/resolv.conf ##检查DNS

四、解决Linux网卡乱序问题

只有eth0、eth2,没有eth1,或者网卡是eno16777736的情况
参考文档:http://jingyan.baidu.com/article/6b97984db5f0971ca2b0bf25.html
1、删除70-persistent-net.rules文件
[root@roller udev]# cd rules.d/
[root@roller rules.d]# ls
60-raw.rules 70-persistent-cd.rules 70-persistent-net.rules 80-docker.rules 90-hal.rules
[root@roller rules.d]# rm -f 70-persistent-net.rules
卸载网卡驱动:rmmod e1000 ##此步骤会导致远程中断,只能登陆控制台
重新加载网卡驱动:modprobe e1000
重启网卡服务:service network restart
更改配置文件:ifcfg-eth1

五、华为交换机简易配置vlan的access和trunk模式

PXE交换机的配置:
telnet 172.16.161.251
<PXE-Switch> system-view
[PXE-Switch] display current-configuration
[PXE-Switch] display vlan 5
[PXE-Switch] interface Ethernet 1/0/11
[PXE-Switch] port access vlan 5
[PXE-Switch] quit
[PXE-Switch] save

千兆交换机的配置:
telnet 172.16.161.254
[Layer1-switch] interface GigabitEthernet0/0/4
[Layer1-switch-GigabitEthernet0/0/4]port link-type trunk
[Layer1-switch-GigabitEthernet0/0/4]port trunk allow-pass vlan 167 200 201 2000 to 2010

六、网卡绑定的bond 0实验笔记,将不同网卡的网口通过双绞线连到到同一台交换机上

参考文档:http://www.cnblogs.com/hyp-19871112/p/5461615.html
注意:在做Bond的过程中,会断网,即使该网卡不参与绑定工作,bond 1、bond 5、bond 6不需要交换机配置。

[root@fuel network-scripts]# cat ifcfg-bond0
DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.11.100
NETMASK=255.255.255.0

[root@fuel network-scripts]# cat ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
MASTER=bond0
SLAVE=yes

[root@fuel network-scripts]# cat ifcfg-eth2
DEVICE=eth2
BOOTPROTO=none
MASTER=bond0
SLAVE=yes

[root@fuel ~]# cat /etc/modprobe.d/bonding.conf
alias bond0 bonding
options bonding mode=0 miimon=200 ##mode是核心部分
[root@fuel ~]# modprobe bonding
[root@fuel ~]# lsmod|grep bonding
bonding 141566 0
[root@fuel ~]# service network restart
[root@fuel ~]# ifconfig

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:a0:24:81 brd ff:ff:ff:ff:ff:ff
inet 192.168.11.136/24 brd 192.168.11.255 scope global dynamic eth0
valid_lft 1770sec preferred_lft 1770sec
3: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
link/ether 00:0c:29:a0:24:8b brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
link/ether 00:0c:29:a0:24:8b brd ff:ff:ff:ff:ff:ff
5: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
link/ether 00:0c:29:a0:24:8b brd ff:ff:ff:ff:ff:ff
inet 192.168.11.100/24 brd 192.168.11.255 scope global bond0

[root@fuel ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: load balancing (round-robin)

交换机链路聚合配置:一种是将交换机和交换机相组合,两台机器做相同配置,如果某个端口是100M,那么两台交换机就是4个端口,即400M发包速率。这里交换机和双网卡同样配置,应该是一样的效果。

 


# interface eth-trunk 1 # port link-type trunk # port trunk allow vlan 10 to 100 # quit # interface G0/0/0/1 # eth-trunk 1# display trunkmembership eth-trunk 1 验证是否创建成功,端口是否加入 # display eth-trunk 1 在另一台交换机同样配置eth-trunk,加入端口。

 

 七、可以Ping通但是ssh不上去,这个问题烦死我了,看起来简单,但就是排错不了

其实最关键的问题service iptables status变为inactive,但是还需要service iptables stop

问题:1、可以Ping 通linux节点192.168.11.133,但是ssh不上去?如何排错呢
解决:(1)【关掉windows的防火墙,可以互通】windows 笔记本可以ping 通192.168.11.133,但是fuel却ping不通windows。
(2)【关掉Linux的防火墙iptables,还是ssh不上去】# systemctl stop iptables

Could not connect to ‘192.168.11.133‘ (port 22): Connection failed.
(3)【检查ssh的配置文件,没有问题啊,允许密码登陆,重启ssh服务】 # systemctl restart sshd
(4)【关掉iptables的同时,立即重启sshd】# service iptables stop
# service sshd restart

问题:2、虚拟机NAT模式和windows笔记本不通?

未解决:(1)VMNET8已正常开启,ifconfig eth0可以正常看到IP地址和UP状态。
(2)# systemctl status firewalld已关闭,windows防火墙已关闭。
(3)# service network restart无济于事
(4)# iptables -F 清空防火墙没用
(5)检查/etc/sysconfig/network-scripts的配置文件无措。
(6)尝试添加eth1并改为桥接模式,添加与windows笔记本相同的网段--->发现windows能通虚拟机,但是虚拟机不通windows。
--->于是判断还有防火墙没关闭,猜测是iptables还存在,# service iptables stop
(7)又回到windows能通虚拟机,但是ssh不通的问题,翻看以往排错笔记,没用,临时给eth1添加的IP很可能就手机占用了,我ping的只是手机IP而已。那么问题归结NAT模式和桥接模式下,都无法ping 通虚拟机
(8)eth0改为静态IP试试。

 

2017-9-3 关于Linux网卡一系列问题的解决案例

标签:view   members   mod   sharp   ref   systemctl   dock   .net   外包   

原文地址:http://www.cnblogs.com/yue-hong/p/7471326.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!