分享

linux基础教管之网络配置

 乡间小路有风景 2013-05-26

1.liunx网络

1.1接口和命名规则

  eth[0-9]   以太网接口

  wlan[0-9]   无线网卡接口

  lo      本地回环接口

1.2linux常规网络配置文件

  1. /etc/hosts       主机文件

  2. /etc/resolv.conf        DNS文件

  3. etc/sysconfig/network-scripts/ifcfg-eth0  网卡配置文件

2.网络配置相关命令

2.1.ifconfig

ifconfig:用于配置和显示linux内核中网络接口的网络参数,包括ip地址、网络掩码、广播地址等。

redhat网卡配置文件:/etc/sysconfig/network-scripts/ifcfg-eth0

常用命令:

  1.启动/关闭网卡:     ifconfig eth0 down/up

  2.设置网络接口及掩码:   ifconfig eth0 192.168.1.1 netmask 255.255.255.0

  3.在一个网卡上增加多个ip:  ifconfig eth0:0 192.168.1.99

  4.修改MAC地址:      ifconfig eth0 hw ether 00:00:00:00:00:00:00           

  5.获得ip:            ifconfig | grep inet

实例:

2.2.route

Redhat配置文件:/etc/sysconfig/netwrk-scripts/route-eth0

route:用来显示和设置linux内核中的网络路由表

  1.显示路由表:      route -n

  2.查看缓冲表:      route -C

  3.添加路由:             route add[-net | -host] ... 

  4.删除路由:        route del[-net | -host] ...

实例:

  route add -net 192.168.1.5 gw 192.168.1.1 

2.3.ifdown/ifup

ifdown/ifup:禁用或启用网络接口

  1.ifdown eth0  禁用网络接口eth0

  2.ifup eth0    激活网络接口eth0

2.4.hostname

Redhat主机名配置文件:/etc/sysconfig/network

hostname:显示和设置linux系统的主机名称

2.5.ip

ip是iproute2软件包里的一个网络配置工具。

常用命令:

  • ip link set dev NAME { up | down }           改变设备属性
  • ip link show DEVICE                                显示设备属性
  • ip addr { add | del }   dev NAME { local | peer | broadcast ..}                         添加/删除协议地址(IP/IPv6)
  • ip route { add | del | change | append | replace | monitor }                            改变路由属性
2.6.重启网络服务

service network restart

/etc/init.d/network {start | stop | restart | status}

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多