linux网络配置、测试及故障诊断方法和工具三
生活随笔
收集整理的這篇文章主要介紹了
linux网络配置、测试及故障诊断方法和工具三
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
DNS客戶端配置文件/etc/resolv.conf<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> /etc/resolv.conf 里面存放的是各大通信公司DNS服務(wù)器列表;下面的三個(gè)地址可以用一用;當(dāng)然您可以打電話問你的服務(wù)商; nameserver 202.96.134.133
nameserver 202.96.128.143
nameserver 202.96.68.38
#ethtool -s eth0 duplex full 在/etc/modules.conf添加內(nèi)容
alias eth0 bcm5700 line_speed=100 full_duplex=1
options??bcm5700 line_speed=100 full_duplex=1
重起! mii-tool 更改網(wǎng)絡(luò)接口協(xié)商的方法; [root@localhost]# mii-tool --help
usage: mii-tool [-VvRrwl] [-A media,... | -F media] [interface ...]
???????-V, --version display version information
???????-v, --verbose more verbose output 注:顯示網(wǎng)絡(luò)接口的信息;
???????-R, --reset reset MII to poweron state 注:重設(shè)MII到開啟狀態(tài);
???????-r, --restart restart autonegotiation 注:重啟自動(dòng)協(xié)商模式;
???????-w, --watch monitor for link status changes 注:查看網(wǎng)絡(luò)接口連接的狀態(tài)變化;
???????-l, --log with -w, write events to syslog 注:寫入事件到系統(tǒng)日志;
???????-A, --advertise=media,... advertise only specified media 注:指令特定的網(wǎng)絡(luò)接口;
???????-F, --force=media force specified media technology 注:更改網(wǎng)絡(luò)接口協(xié)商方式;
media: 100baseT4, 100baseTx-FD, 100baseTx-HD, 10baseT-FD, 10baseT-HD,
???????(to advertise both HD and FD) 100baseTx, 10baseT
Settings for eth0:
????????Supported ports: [ TP MII ]
????????Supported link modes: 10baseT/Half 10baseT/Full
????????????????????????????????100baseT/Half 100baseT/Full
????????Supports auto-negotiation: Yes
????????Advertised link modes: 10baseT/Half 10baseT/Full
????????????????????????????????100baseT/Half 100baseT/Full
????????Advertised auto-negotiation: No 注:自動(dòng)協(xié)商關(guān)閉
????????Speed: 100Mb/s 注:速度 100Mb
????????Duplex: Full 注:全雙工
????????Port: MII
????????PHYAD: 32
????????Transceiver: internal
????????Auto-negotiation: off
????????Supports Wake-on: pumbg
????????Wake-on: d
????????Current message level: 0x00000007 (7)
????????Link detected: yes 注:eth0已經(jīng)激活; ethtool 設(shè)置網(wǎng)卡的協(xié)商模式; ethtool -s DEVNAME \
????????????????[ speed 10|100|1000 ] \
????????????????[ duplex half|full ] \
????????????????[ port tp|aui|bnc|mii|fibre ] \
????????????????[ autoneg on|off ] \ 把網(wǎng)卡eth0 速度改為10Mb/s,采用半雙工; [root@localhost]# ethtool -s eth1 speed 10 duplex half [root@localhost]# ethtool eth1 Settings for eth1: ??????? Supported ports: [ TP MII ] ??????? Supported link modes:?? 10baseT/Half 10baseT/Full ??????????????????????????????? 100baseT/Half 100baseT/Full ??????? Supports auto-negotiation: Yes ??????? Advertised link modes:? 10baseT/Half 10baseT/Full ??????????????????????????????? 100baseT/Half 100baseT/Full ??????? Advertised auto-negotiation: No ??????? Speed: 10Mb/s 注:速度 10M/s ??????? Duplex: Half? 注:半雙工 ??????? Port: MII ??????? PHYAD: 32 ??????? Transceiver: internal ??????? Auto-negotiation: off ??????? Supports Wake-on: pumbg ??????? Wake-on: d ??????? Current message level: 0x00000007 (7) ??????? Link detected: no 注:eth1沒有激活; 把網(wǎng)卡eth0 速度改為100Mb/s,采用全雙工; [root@localhost]# ethtool -s eth1 speed 100 duplex full [root@localhost]# ethtool eth1 Settings for eth1: ??????? Supported ports: [ TP MII ] ??????? Supported link modes:?? 10baseT/Half 10baseT/Full ??????????????????????????????? 100baseT/Half 100baseT/Full ??????? Supports auto-negotiation: Yes ??????? Advertised link modes:? 10baseT/Half 10baseT/Full ??????????????????????????????? 100baseT/Half 100baseT/Full ??????? Advertised auto-negotiation: No ??????? Speed: 100Mb/s? 注:速度 100M/s ??????? Duplex: Full 注:全雙工 ??????? Port: MII ??????? PHYAD: 32 ??????? Transceiver: internal ??????? Auto-negotiation: off ??????? Supports Wake-on: pumbg ??????? Wake-on: d ??????? Current message level: 0x00000007 (7) ??????? Link detected: no 注:eth1網(wǎng)卡沒有激活;
nameserver 202.96.128.143
nameserver 202.96.68.38
?
改變網(wǎng)絡(luò)接口的速度和協(xié)商方式的工具miitool 和ethtool 通過mii-tool和ethtool工具來調(diào)整網(wǎng)卡的速度、雙工等,這樣能提高網(wǎng)卡的效率; mii-tool 配置網(wǎng)絡(luò)設(shè)備協(xié)商方式的工具 mii-tool 介紹 mii-tool - view, manipulate media-independent interface status (mii-tool 是查看,管理介質(zhì)的網(wǎng)絡(luò)接口的狀態(tài)) 有時(shí)網(wǎng)卡需要配置協(xié)商方式 ,比如10/100/1000M的網(wǎng)卡半雙工、全雙工、自動(dòng)協(xié)商的配置 。但大多數(shù)的網(wǎng)絡(luò)設(shè)備是不用我們來修改協(xié)商,因?yàn)榇蠖鄶?shù)網(wǎng)絡(luò)設(shè)置接入的時(shí)候,都采用自動(dòng)協(xié)商來解決相互通信的問題。但在有的情況下,需要我們手動(dòng)來設(shè)置網(wǎng)卡的協(xié)商方式; mii-tool 就是能指定網(wǎng)卡的協(xié)商方式。 注明:我在使用mii-tool工具修改協(xié)商模式時(shí),提示是錯(cuò)誤的,因?yàn)槭窃谔摂M機(jī)中做的,不過虛擬機(jī)中的網(wǎng)卡我查看是支持全雙工模式的,可是提示錯(cuò)誤SIOCGMIIPHY on 'eth0' failed: Operation not supported,問題出在那里也不清楚,用google查了下,發(fā)現(xiàn)不少人都是這樣的錯(cuò)誤,也沒說明原因;不過多數(shù)人提示可以使用ethtool工具去修改,我測試了下,還行!還有一種方法是修改/etc/modules.conf配置文件; #ethtool -s eth0 autoneg off#ethtool -s eth0 duplex full 在/etc/modules.conf添加內(nèi)容
alias eth0 bcm5700 line_speed=100 full_duplex=1
options??bcm5700 line_speed=100 full_duplex=1
重起! mii-tool 更改網(wǎng)絡(luò)接口協(xié)商的方法; [root@localhost]# mii-tool --help
usage: mii-tool [-VvRrwl] [-A media,... | -F media] [interface ...]
???????-V, --version display version information
???????-v, --verbose more verbose output 注:顯示網(wǎng)絡(luò)接口的信息;
???????-R, --reset reset MII to poweron state 注:重設(shè)MII到開啟狀態(tài);
???????-r, --restart restart autonegotiation 注:重啟自動(dòng)協(xié)商模式;
???????-w, --watch monitor for link status changes 注:查看網(wǎng)絡(luò)接口連接的狀態(tài)變化;
???????-l, --log with -w, write events to syslog 注:寫入事件到系統(tǒng)日志;
???????-A, --advertise=media,... advertise only specified media 注:指令特定的網(wǎng)絡(luò)接口;
???????-F, --force=media force specified media technology 注:更改網(wǎng)絡(luò)接口協(xié)商方式;
media: 100baseT4, 100baseTx-FD, 100baseTx-HD, 10baseT-FD, 10baseT-HD,
???????(to advertise both HD and FD) 100baseTx, 10baseT
?
查看網(wǎng)絡(luò)接口的協(xié)商狀態(tài) [root@localhost]# mii-tool -v eth0 eth0: negotiated 100baseTx-FD, link ok ? product info: vendor 00:00:00, model 0 rev 0 ??basic mode:?? autonegotiation enabled ? basic status: autonegotiation complete, link ok ? capabilities: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD ? advertising:? 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD ? link partner: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control 注:上面的例子,我們可以看得到是自動(dòng)協(xié)商。注意紅字的部份; 更改網(wǎng)絡(luò)接口協(xié)商方式; 更改網(wǎng)絡(luò)接口的協(xié)商方式,我們要用到-F選項(xiàng),后面可以接 100baseT4, 100baseTx-FD, 100baseTx-HD, 10baseT-FD, 10baseT-HD等參數(shù); 把網(wǎng)絡(luò)接口eth0改為 1000Mb/s全雙工的模式 [root@localhost]# mii-tool -F? 100baseTx-FD?
[root@localhost]#mii-tool -v eth0 eth0: 100 Mbit, full duplex, link ok ? product info: vendor 00:00:00, model 0 rev 0 ? basic mode:?? 100 Mbit, full duplex ? basic status: link ok ? capabilities: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD ? advertising:? 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD 也可以使用ethtool工具修改: ?[root@localhost]# ethtool -s eth0 speed 100 duplex full ethtool 工具關(guān)于網(wǎng)絡(luò)協(xié)商功能介紹 ethtool - Display or change ethernet card settings(ethtool 是用來顯示和更改網(wǎng)卡設(shè)置的工具);這個(gè)工具比較復(fù)雜,功能也特別多; ethtool 顯示網(wǎng)絡(luò)端口設(shè)置功能 [root@localhost]# ethtool eth0Settings for eth0:
????????Supported ports: [ TP MII ]
????????Supported link modes: 10baseT/Half 10baseT/Full
????????????????????????????????100baseT/Half 100baseT/Full
????????Supports auto-negotiation: Yes
????????Advertised link modes: 10baseT/Half 10baseT/Full
????????????????????????????????100baseT/Half 100baseT/Full
????????Advertised auto-negotiation: No 注:自動(dòng)協(xié)商關(guān)閉
????????Speed: 100Mb/s 注:速度 100Mb
????????Duplex: Full 注:全雙工
????????Port: MII
????????PHYAD: 32
????????Transceiver: internal
????????Auto-negotiation: off
????????Supports Wake-on: pumbg
????????Wake-on: d
????????Current message level: 0x00000007 (7)
????????Link detected: yes 注:eth0已經(jīng)激活; ethtool 設(shè)置網(wǎng)卡的協(xié)商模式; ethtool -s DEVNAME \
????????????????[ speed 10|100|1000 ] \
????????????????[ duplex half|full ] \
????????????????[ port tp|aui|bnc|mii|fibre ] \
????????????????[ autoneg on|off ] \ 把網(wǎng)卡eth0 速度改為10Mb/s,采用半雙工; [root@localhost]# ethtool -s eth1 speed 10 duplex half [root@localhost]# ethtool eth1 Settings for eth1: ??????? Supported ports: [ TP MII ] ??????? Supported link modes:?? 10baseT/Half 10baseT/Full ??????????????????????????????? 100baseT/Half 100baseT/Full ??????? Supports auto-negotiation: Yes ??????? Advertised link modes:? 10baseT/Half 10baseT/Full ??????????????????????????????? 100baseT/Half 100baseT/Full ??????? Advertised auto-negotiation: No ??????? Speed: 10Mb/s 注:速度 10M/s ??????? Duplex: Half? 注:半雙工 ??????? Port: MII ??????? PHYAD: 32 ??????? Transceiver: internal ??????? Auto-negotiation: off ??????? Supports Wake-on: pumbg ??????? Wake-on: d ??????? Current message level: 0x00000007 (7) ??????? Link detected: no 注:eth1沒有激活; 把網(wǎng)卡eth0 速度改為100Mb/s,采用全雙工; [root@localhost]# ethtool -s eth1 speed 100 duplex full [root@localhost]# ethtool eth1 Settings for eth1: ??????? Supported ports: [ TP MII ] ??????? Supported link modes:?? 10baseT/Half 10baseT/Full ??????????????????????????????? 100baseT/Half 100baseT/Full ??????? Supports auto-negotiation: Yes ??????? Advertised link modes:? 10baseT/Half 10baseT/Full ??????????????????????????????? 100baseT/Half 100baseT/Full ??????? Advertised auto-negotiation: No ??????? Speed: 100Mb/s? 注:速度 100M/s ??????? Duplex: Full 注:全雙工 ??????? Port: MII ??????? PHYAD: 32 ??????? Transceiver: internal ??????? Auto-negotiation: off ??????? Supports Wake-on: pumbg ??????? Wake-on: d ??????? Current message level: 0x00000007 (7) ??????? Link detected: no 注:eth1網(wǎng)卡沒有激活;
轉(zhuǎn)載于:https://blog.51cto.com/13233/82559
總結(jié)
以上是生活随笔為你收集整理的linux网络配置、测试及故障诊断方法和工具三的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 请教于国富律师——怎样把灰鸽子病毒和灰鸽
- 下一篇: 项目管理第四讲