linux网络配置&管理基础 [转载]

来源:互联网 发布:淘宝上的猛犸象牙真吗? 编辑:程序博客网 时间:2024/05/21 09:04
 
网络配置文件    LINUX 在 安装中 基本的配置 都已经完成了    都以文本方式 保存在/etc目录下
.
网络配置文件:/etc/sysconfig/network
查看命令:

[root@localhost ~]# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=localhost.localdomain
[root@localhost ~]#

可能因为一些LINUX 版本 不同上面显示的信息也不同     这个文件 可以用 /netcfg 来维护 不过需要 X服务器支持
主机名和IP 地址映射 : /etc/hosts
IP地址 的设计方便计算机的处理    但是记忆这些就比较枯燥了 为了 直接能访问主机 现在都采用域名方式 早期的域名就被保存在这个文件里
查看命令:

[root@localhost ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
::1       localhost.localdomain     localhost
[root@localhost ~]#
这个文件和WINDOWS 系统中的 WINDOWS/system32/etc 下的 HOSTS 采用相同的格式和功能

DNS 客户配置:/etc/resolv.conf
这个文件包含了域名顺序和DNS 服务器的主机地址
查看命令:

[root@localhost ~]# cat /etc/resolv.conf

nameserver 61.128.128.68          ;可使用多个DNS 服务器的地址
nameserver 61.128.192.68
[root@localhost ~]#

主机名:/etc/hostname        ;有些版本的LINUX 主机名是在/etc/sysconfig/network 文件里    有些除外
查看主机名:

[root@localhost ~]# hostname
localhost.localdomain
[root@localhost ~]#
网络服务:/etc/services
这个文件跟 WINDOWS 下的 WINDOWS/system32/drivers/etc/services 文件一样 给出了端口 和 服务名对照    很多系统都会读取这个文件

查看命令:

[root@localhost ~]# tail /etc/services         ;这里如果使用 cat 命令查看    会有很多  
nimspooler        48001/udp                         # Nimbus Spooler
nimhub            48002/tcp                         # Nimbus Hub
nimhub            48002/udp                         # Nimbus Hub
nimgtw            48003/tcp                         # Nimbus Gateway
nimgtw            48003/udp                         # Nimbus Gateway
com-bardac-dw     48556/tcp                         # com-bardac-dw
com-bardac-dw     48556/udp                         # com-bardac-dw
iqobject          48619/tcp                         # iqobject
iqobject          48619/udp                         # iqobject
# Local services
[root@localhost ~]#

网络协议文件:/etc/protocols
这个文件列出了 用户系统支持    TCP/IP 各种协议名称
查看命令:

[root@localhost ~]# tail /etc/protocols           
;这里如果使用 cat 命令查看    会有很多
sctp      132       SCTP              # Stream Control Transmission Protocol
fc        133       FC                # Fibre Channel
rsvp-e2e-ignore 134       RSVP-E2E-IGNORE
#         135                       # Mobility Header
udplite 136       UDPLite
mpls-in-ip        137       MPLS-in-IP
#     138-252 Unassigned                                         [IANA]
#     253       Use for experimentation and testing             [RFC3692]
#     254       Use for experimentation and testing             [RFC3692]
#     255                   Reserved                               [IANA]
[root@localhost ~]#

禁止访问服务 和准许访问服务 :/etc/hosts.deny 和 /etc/hosts.allow
这个很简单     前者是    禁止访问的网络服务    后者正好相反

网卡设备 :cat /etc/sysconfig/network-scripts/ifcfg-eth0
查看命令:

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:E0:4C:B0:4F:59
ONBOOT=yes
TYPE=Ethernet
[root@localhost ~]#


注意如果配置文件    改变 需要重新启动服务才可以生效
命令:

[root@localhost ~]#    service network restart
正在关闭接口 china:                                         [确定]
正在关闭接口 eth0:                                          [确定]
关闭环回接口:                                               [确定]
弹出环回接口:                                               [确定]
弹出界面 eth0:
正在决定 eth0 的 IP 信息...

网络端口配置 ifconfig
查看命令:

[root@localhost ~]# ifconfig
eth0        Link encap:Ethernet    HWaddr 00:E0:4C:B0:4F:59  
            inet6 addr: fe80::2e0:4cff:feb0:4f59/64 Scope:Link                       ;主机地址信息
            UP BROADCAST RUNNING MULTICAST    MTU:1500    Metric:1    ;MTU最大传输单元 metric 量度值
            RX packets:5719 errors:0 dropped:0 overruns:0 frame:0     ; RX    接收包
            TX packets:5838 errors:0 dropped:0 overruns:0 carrier:0      ;TX 传输包
            collisions:0 txqueuelen:1000
            RX bytes:3664215 (3.4 MiB)    TX bytes:671630 (655.8 KiB)
            Interrupt:153 Base address:0x6000

lo          Link encap:Local Loopback  
            inet addr:127.0.0.1    Mask:255.0.0.0
            inet6 addr: ::1/128 Scope:Host
            UP LOOPBACK RUNNING    MTU:16436    Metric:1
            RX packets:8835 errors:0 dropped:0 overruns:0 frame:0
            TX packets:8835 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:0
            RX bytes:6032605 (5.7 MiB)    TX bytes:6032605 (5.7 MiB)

ppp0        Link encap:Point-to-Point Protocol  
            inet addr:219.152.75.238    P-t-P:219.152.72.1    Mask:255.255.255.255
            UP POINTOPOINT RUNNING NOARP MULTICAST    MTU:1492    Metric:1
            RX packets:25 errors:0 dropped:0 overruns:0 frame:0
            TX packets:25 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:3
            RX bytes:1197 (1.1 KiB)    TX bytes:1705 (1.6 KiB)

[root@localhost ~]#

;errors 错误    
collisions 冲突     如果他们的数据 出现得太高 很可能是 硬件 或者网络介质损坏 如果看到接受和传输包的个数 异常    应该是 IP 出现混乱
          Interrupt:153 Base address:0x6000    网卡的 中断号和 基地址
eth0 是网卡    lo 是网络回送设备    eth0 对应MAC 地址   00:E0:4C:B0:4F:59       这个是由生产出来就有 不过可以通过 /etc/rc.d/init.d 中network加入    ifconfig eth0 hw ether XX:XX:XX:XX:XX

PPP0    点对点协议。。。 因为我是拨号连接。。。所以 有这个。。。

启用和 禁用网络接口
命令用法  
ifconfig interface [up    and down]
这个命令要求 ROOT    用户。使用
UP 是 开启     DOWN 是禁止
例子:

ifconfig eth0 down
ifconfig eth0 192.168.0.1 netmask 255.255.255.0 up

 

 原文地址http://hi.baidu.com/redhatd/blog/item/a927aa867424fc3e66096e47.html
原创粉丝点击