《第10章管理Linux网络》由会员分享,可在线阅读,更多相关《第10章管理Linux网络(20页珍藏版)》请在金锄头文库上搜索。
1、第十章管理Linux网络,本章目标,了解Linux中网络设备的命名规则掌握修改网络参数的方法使用netconfig命令修改网络参数通过修改配置文件改变网络参数利用各类监视工具检查网络状态,本章内容,10.4网络状况监视工具,10.3与网络相关的配置文件,10.2使用网络配置工具,10.1常见网络设备,10.1常见网络设备,lo回环设备eth0系统内第一块以太网卡ppp0系统内第一个串行设备多数出现在使用ADSL拨入Internet时,10.2使用网络配置工具,10.2.1在命令行中配置网络参数10.2.2带有交互功能的netconfig命令,10.2.1在命令行中配置网络参数,ifconfig
2、routehostname,# ifconfig eth0eth0 Link encap:Ethernet HWaddr 00:0C:29:D9:2E:B9 inet addr:192.168.149.2 Bcast:192.168.149.255 Mask:255.255.255.0 inet6 addr: fe80:20c:29ff:fed9:2eb9/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:494 errors:0 dropped:0 overruns:0 frame:0 TX p
3、ackets:479 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:48033 (46.9 KiB) TX bytes:86344 (84.3 KiB) Interrupt:169 Base address:0x2000,# ifconfig eth0 192.168.149.10 netmask 255.255.255.0# ifconfig eth0:1 10.0.0.1 netmask 255.255.255.0# ifconfig eth0 down # ifconfig et
4、h0 up,10.2.1在命令行中配置网络参数,ifconfigroutehostname,# route -n 查看路由信息Kernel IP routing tableDestinationGatewayGenmaskFlagsMetricRefUseIface192.168.149.0*255.255.255.0U000eth010.0.0.0 *255.0.0.0U000eth011.0.0.0 *255.0.0.0U000eth0,# route add default gw 192.168.149.1# route add -net 10.0.0.0/24(要到达的网络) gw 1
5、92.168.149.1(通过本机的哪个接口出去)# route del -net 10.0.0.0/24,10.2.1在命令行中配置网络参数,ifconfigRouteUname a 查看系统内核hostname,# ,# hostname -i# hostname linux-srv,# cat /etc/hosts127.0.0.1 linux-srv localhost localhost.localdomain,10.2.2带有交互功能的netconfig命令,配置信息被保存在下列文件中:/etc/sysconfig/network-scripts/ifcfg-ethN/etc/re
6、solv.conf重新启动网络服务# service network restartShutting down interface eth0: OK Shutting down loopback interface: OK Bringing up loopback interface: OK Bringing up interface eth0: OK ,10.3与网络相关的配置文件,/etc/sysconfig/network-scripts/ifcfg-ethN/etc/sysconfig/network/etc/hosts/etc/host.conf/etc/resolv.conf,DE
7、VICE=eth0ONBOOT=yesBOOTPROTO=staticIPADDR=192.168.149.2NETMASK=255.255.255.0GATEWAY=192.168.149.1,10.3与网络相关的配置文件,/etc/sysconfig/network-scripts/ifcfg-ethN/etc/sysconfig/network/etc/hosts/etc/host.conf/etc/resolv.conf,NETWORKING=yesHOSTNAME=localhost.localdomain,10.3与网络相关的配置文件,/etc/sysconfig/network-
8、scripts/ifcfg-ethN/etc/sysconfig/network/etc/hosts/etc/host.conf/etc/resolv.conf,127.0.0.1localhost.localdomain localhost:1localhost6.localdomain6 localhost6,10.3与网络相关的配置文件,/etc/sysconfig/network-scripts/ifcfg-ethN/etc/sysconfig/network/etc/hosts/etc/host.conf/etc/resolv.conf,order hosts,bind,10.3与网
9、络相关的配置文件,/etc/sysconfig/network-scripts/ifcfg-ethN/etc/sysconfig/network/etc/hosts/etc/host.conf/etc/resolv.conf,nameserver 192.168.1.1nameserver 192.168.1.2search ,10.4网络状况监视工具,Netstate -nlutp 查看网络状况arpethtool/mii-toolpingtraceroute,# netstat -r# netstat -i# netstat -s,10.4网络状况监视工具,netstatearpethto
10、ol/mii-toolpingtraceroute,# arpAddressHWtype HWaddressFlags MaskIface192.168.149.1ether00:50:56:C0:00:01Ceth0,# arp -s 192.168.149.3 00:50:56:C0:00:03# arp -d 192.168.149.3,10.4网络状况监视工具,netstatearpethtool/mii-toolpingtraceroute,# ethtool eth0Settings for eth0: Supported ports: TP MII Supported link
11、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: Yes Speed: 100Mb/s Duplex: Half Port: MII PHYAD: 32 Transceiver: internal Auto-negotiation: on Support
12、s Wake-on: pumbg Wake-on: d Current message level: 0x00000007 (7) Link detected: yes,# mii-tool -v eth0eth0: negotiated 100baseTx-HD, 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 10
13、0baseTx-HD 10baseT-FD 10baseT-HD advertising: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD link partner: 100baseTx-HD 10baseT-HD,10.4网络状况监视工具,netstatearpethtool/mii-toolpingtraceroute,# ping -i 5 192.168.149.2PING 192.168.149.2 (192.168.149.2) 56(84) bytes of data.64 bytes from 192.168.149.2: icm
14、p_seq=1 ttl=64 time=0.184 ms64 bytes from 192.168.149.2: icmp_seq=2 ttl=64 time=0.335 ms,10.4网络状况监视工具,netstatearpethtool/mii-toolpingtraceroute,# traceroute 219.146.0.130traceroute to 219.146.0.130 (219.146.0.130), 30 hops max, 40 byte packets 1 (166.111.219.129) 12.691 ms 12.988 ms 15.285 ms 2 211
15、.151.88.202 (211.151.88.202) 86.034 ms 91.394 ms 92.695 ms 3 211.151.88.250 (211.151.88.250) 95.192 ms 96.954 ms 99.326 ms 4 211.151.88.253 (211.151.88.253) 99.223 ms 99.122 ms 101.109 ms 5 211.151.224.157 (211.151.224.157) 100.945 ms 100.841 ms 105.726 ms 6 211.151.224.186 (211.151.224.186) 105.108
16、 ms 75.619 ms 68.737 ms 7 222.173.18.233 (222.173.18.233) 83.569 ms 86.249 ms 102.849 ms 8 222.173.1.25 (222.173.1.25) 93.860 ms 94.982 ms 103.594 ms 9 219.146.20.206 (219.146.20.206) 95.657 ms 96.638 ms 98.101 ms10 219.146.15.38 (219.146.15.38) 108.165 ms 108.579 ms 110.390 ms11 219.146.15.41 (219.146.15.41) 103.060 ms 104.056 ms 105.397 ms12 219.146.0.254 (219.146.0.254) 61.586 ms 29.409 ms 83.508 ms13 219.146.0.254 (219.146.0.254) 83.043 ms 86.075 ms 87.057 ms,