网络常用文件

/etc/sysconfig/network(该文件用来指定服务器上的网络配置信息 包含了控制和网络有关的文件和守护程序的行为的参数)
[root@liulangyu ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=liulangyu
NETWORKING_IPV6=no
PEERNTP=no
GATEWAY=109.200.3.227

/etc/hosts 中包含了IP 地址和主机名之间的映射还包括主机名的别名IP地址的设计使计算机容易识别但对于人却很难记住它们为了解决这个问题创建了/etc/hosts 这个文件
[root@liulangyu ~]# cat /etc/hosts
127.0.0.1 localhost
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.141.9.173 test222
10.51.180.179 liulangyu

/etc/services 中包含了服务名和端口号之间的映射
[root@liulangyu ~]# cat /etc/services
keyshadow       19315/udp               # Key Shadow for SASSAFRAS
mtrgtrans       19398/tcp               # mtrgtrans
mtrgtrans       19398/udp               # mtrgtrans
hp-sco          19410/tcp               # hp-sco
hp-sco          19410/udp               # hp-sco
hp-sca          19411/tcp               # hp-sca
hp-sca          19411/udp               # hp-sca
hp-sessmon      19412/tcp               # HP-SESSMON
hp-sessmon      19412/udp               # HP-SESSMON
最左边一列是主机服务名 中间一列是端口号/ 后面是端口类型 可以是TCP 也可以是UDP 任何后面的列都是前面服务的别名在这个文件中也存在着别名它们出现在端口号后面
双网卡配置

/etc/host.conf 文件指定如何解析主机名Linux 通过解析器库来获得主机名对应的IP 地址
[root@liulangyu ~]# cat /etc/host.conf
multi on
"multi" 指定是否"/etc/hosts"文件中指定的主机可以有多个地址值为on 表示允许拥有多个IP 地址的主机一般称为具有多个网络界面

/etc/nsswitch.conf/etc/nsswitch.conf 文件是由Sun 公司开发并用于管理系统中多个配置文件查找的顺序
[root@iZ25cgyal4wZ ~]# cat /etc/nsswitch.conf
#
# /etc/nsswitch.conf
#
# An example Name Service Switch config file. This file should be
# sorted with the most-used services at the beginning.
#
# The entry '[NOTFOUND=return]' means that the search for an
# entry should stop if the search in the previous entry turned
# up nothing. Note that if the search failed due to some other reason
# (like no NIS server responding) then the search continues with the
# next entry.
#
# Valid entries include:
#
#    nisplus            Use NIS+ (NIS version 3)
#    nis            Use NIS (NIS version 2), also called YP
#    dns            Use DNS (Domain Name Service)
#    files            Use the local files
#    db            Use the local database (.db) files
#    compat            Use NIS on compat mode
#    hesiod            Use Hesiod for user lookups
#    [NOTFOUND=return]    Stop searching if not found so far
#

# To use db, put the "db" in front of "files" for entries you want to be
# looked up first in the databases
#
# Example:
#passwd:    db files nisplus nis
#shadow:    db files nisplus nis
#group:     db files nisplus nis
passwd:     files
shadow:     files
group:      files
#hosts:     db files nisplus nis dns
hosts:      files dns
# Example - obey only what nisplus tells us...
#services:   nisplus [NOTFOUND=return] files
#networks:   nisplus [NOTFOUND=return] files
#protocols:  nisplus [NOTFOUND=return] files
#rpc:        nisplus [NOTFOUND=return] files
#ethers:     nisplus [NOTFOUND=return] files
#netmasks:   nisplus [NOTFOUND=return] files    
bootparams: nisplus [NOTFOUND=return] files
ethers:     files
netmasks:   files
networks:   files
protocols:  files
rpc:        files
services:   files
netgroup:   nisplus
publickey:  nisplus
automount:  files nisplus
aliases:    files nisplus


/etc/resolv.conf 配置DNS 客户它包含了主机的域名搜索顺序和DNS服务器的地址每一行应包含一个关键字和一个或多个的由空格隔开的参数
[root@network-scripts ~]# cat /etc/resolv.conf
options timeout:1 attempts:1 rotate
nameserver 10.143.22.118
nameserver 10.143.22.116
nameserver 表明DNS 服务器的IP 地址可以有很多行的nameserver 每一个带一个I P 地址在查询时就按nameserver 在本文件中的顺序进行且只有当第一个nameserver没有反应时才查询下面的nameserve


系统网络设备的配置文件保存在/etc/sysconfig/network-scripts”目录下ifcfg-eth0 包含第一块网卡的配置信息ifcfg-eth1 包含第二块网卡的配置信息
[root@liulangyu network-scripts]# cat ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=10.51.180.189
NETMASK=255.255.248.0
[root@liulangyu network-scripts]# cat ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=static
IPADDR=101.200.1.46
NETMASK=255.255.252.0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值