1 / 21

Linux 网络操作系统

Linux 网络操作系统. 第 7 章 Linux 网络基础配置. 广州工程技术职业学院. 本章内容. TCP/IP 网络配置文件 使用命令配置网络 网络诊断工具. TCP/IP 网络配置文件. /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network /etc/host.conf /etc/hosts /etc/resolv.conf /etc/services. /etc/sysconfig/network-scripts/ifcfg-eth0. 网络接口的启动脚本 内容实例:

john-chaney
Download Presentation

Linux 网络操作系统

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Linux网络操作系统 第7章 Linux网络基础配置 广州工程技术职业学院

  2. 本章内容 • TCP/IP网络配置文件 • 使用命令配置网络 • 网络诊断工具

  3. TCP/IP网络配置文件 • /etc/sysconfig/network-scripts/ifcfg-eth0 • /etc/sysconfig/network • /etc/host.conf • /etc/hosts • /etc/resolv.conf • /etc/services

  4. /etc/sysconfig/network-scripts/ifcfg-eth0 • 网络接口的启动脚本 • 内容实例: • DEVICE=eth0 • ONBOOT=yes • BOOTPROTO=static • IPADDR=192.168.0.110 • NETMASK=255.255.255.0 • GATEWAY=192.168.0.254 • NETWORK=192.168.0.0 • BROADCAST=192.168.0.255

  5. /etc/sysconfig/network • 网络基本信息配置 • 内容实例: • NETWORKING=yes • HOSTNAME=linux.jnrp.cn • GATEWAY=192.168.0.254

  6. /etc/hosts • /etc/hosts文件是系统本地的主机名解析数据库 • 内容实例: # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost 192.168.1.2 linux-server1

  7. /etc/host.conf • /etc/host.conf文件用来指定如何解析主机名,可用选项包括: • order:设置主机名解析的可用方法以及顺序,可用方法包括hosts(使用/etc/hosts文件进行解析)、bind(使用DNS服务器解析)、nis(使用网络信息服务NIS解析) • multi:设置是否从/etc/hosts文件中返回主机的多个IP地址,取值为on/off

  8. /etc/resolv.conf • /etc/resolv.conf文件是DNS域名服务的客户端配置文件 • 内容实例: • nameserver 202.194.14.2 • nameserver 202.194.14.3 • search jnrp.cn • domain jnrp.cn

  9. /etc/services • 设置网络服务默认使用的TCP或UDP端口 • 文件内容实例: • # Each line describes one service, and is of the form: • # • # service-name port/protocol [aliases ...] [# comment] • tcpmux 1/tcp # TCP port service multiplexer • tcpmux 1/udp # TCP port service multiplexer • rje 5/tcp # Remote Job Entry • rje 5/udp # Remote Job Entry • echo 7/tcp • echo 7/udp • discard 9/tcp sink null • discard 9/udp sink null • systat 11/tcp users • systat 11/udp users

  10. 在Linux中配置网络 • 使用命令行工具 • 使用GUI或TUI工具

  11. 使用命令行工具 • 基本网络配置命令: • ifconfig • ifup • ifdown • hostname

  12. ifconfig命令 • ifconfig命令用于查看和配置TCP/IP网络 • 命令实例: • # ifconfig eth0 • eth0 Link encap:Ethernet HWaddr 00:0C:29:FB:E4:89 • inet addr:192.168.201.2 Bcast:192.168.201.255 Mask:255.255.255.0 • inet6 addr: fe80::20c:29ff:fefb:e489/64 Scope:Link • UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 • RX packets:36 errors:0 dropped:0 overruns:0 frame:0 • TX packets:139 errors:0 dropped:0 overruns:0 carrier:0 • collisions:0 txqueuelen:1000 • RX bytes:4321 (4.2 KiB) TX bytes:13153 (12.8 KiB) • Interrupt:10 Base address:0x1400 • # ifconfig eth0 192.168.1.3 netmask 255.255.255.0

  13. 使用命令行工具 • route命令用于设置Linux系统的路由信息 • 察看路由信息: • route -n • 添加一个静态路由条目 • route add -net netaddr netmask gw ipaddr dev • 设置默认网关 • route add default gw ipaddr • 删除一个路由条目 • route del -net netaddr netmask gw ipaddr dev

  14. 使用GUI工具 • 系统设置|网络或者运行redhat-config-network

  15. 使用TUI工具 • 在文本模式下也可以使用netconfig这样的TUI工具进行网络配置

  16. 网络诊断工具 • ping命令通过ICMP协议进行网络连接测试 • traceroute命令可以追踪到达某个目的地所经过的路径 • netstat命令用来查看各种与网络相关的状态信息,其中包括:网络的连接状态、接口的统计信息、查看路由表、端口的监听情况等

  17. ping命令 • ping命令的基本用法为: • ping 选项 目标地址 • 常用选项包括: • -c:指定ping命令发出的ICMP消息的数量,如果不指定将会不断发送直至用户按“ctrl+c”中止命令 • -i:指定ping命令发出每个ICMP消息的间隔时间,默认值为1秒。出于安全考虑,只有超级用户可以将该值设置为小于0.2秒 • -s:设置发出的每个ICMP消息的数据包尺寸,默认为64字节,最大值为65507 • -t:设置ttl(Time to Live)

  18. traceroute命令 • # traceroute nis.nsf.net • traceroute to nis.nsf.net (35.1.1.48), 30 hops max, 38 byte packet • 1 helios.ee.lbl.gov (128.3.112.1) 19 ms 19 ms 19 ms • 2 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 39 ms 19 ms • 3 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 39 ms 19 ms • 4 ccngw-ner-cc.Berkeley.EDU (128.32.126.23) 39 ms 40 ms 39 ms • 5 ccn-nerif22.Berkeley.EDU (128.32.168.22) 39 ms 39 ms 39 ms • 6 128.32.197.4 (128.32.197.4) 40 ms 59 ms 59 ms • 7 121.119.2.5 (121.119.2.5) 59 ms 59 ms 59 ms • 8 129.140.70.12 (129.140.70.12) 99 ms 99 ms 80 ms • 9 129.140.71.6 (129.140.71.6) 129 ms 239 ms 319 ms • 10 129.140.81.7 (129.140.81.7) 220 ms 199 ms 199 ms • 11 nic.merit.edu (35.1.1.48) 239 ms 239 ms 239 ms

  19. netstat命令 • netstat命令的常用选项包括: • -a:显示所有监听和非监听的套接字 • -i:显示接口的统计信息 • -n:以数字形式而不是名称显示IP地址和端口 • -p:显示使用端口的进程的PID和程序名称 • -r:显示内核路由表 • -s:为每个协议显示统计信息

  20. 操作演示

  21. 本章小结 • 熟悉与TCP/IP网络配置有关的文件 • 熟练掌握使用命令行工具和GUI/TUI工具配置Linux网络的方法 • 熟练使用网络诊断命令

More Related