solaris网络管理基础培训

第一章 网络地址和掩码
1. /etc/hostname.interface

Interface是网卡的型号 , 有le、hme等 。Le是十兆网卡 , hme为百兆网卡等等 。后面跟一个数字 , 第一个十兆网卡为le0 , 第二个为le1;第二个百兆网卡为hme0 , 第二个为hme1等等 。
文件的内容是这块网卡的名字 , 如Sunrise、Sunny 。
#more /etc/hostname.le0
Sunrise
# more /etc/hostname.hme0
Sunny

2. /etc/hosts文件

系统名与IP地址的映射
与/etc/hostname.interface 协同工作 , 配置本机网卡地址
# more /etc/hosts
127.0.0.1 localhost loGhost
172.16.255.1 Sunrise
172.18.255.1 Sunny

系统名不是机器名 , 机器名是唯一的 , 要更改机器名 , 用命令:hostname 。
有了/etc/hostname.interface和/etc/hosts两个文件 , 系统就知道如何配置网卡了 , 如第一个百兆网卡的名字是Sunny , 其对应的地址是172.18.255.1 。

3. /etc/netmasks文件

将网络的IP地址与网络地址联系一起 , 划分子网
如果是标准网段 , 则不需要配置

标准网段:
A类网:0-127(127用于本地地址) 掩码:255..0.0.0
B类网:128-191 掩码:255.255.0.0
C类网:192-223 掩码:255.255.255.0
D类网:224-254(用于多址广播)

要配一个B类地址:172.16.255.1掩码为:255.255.255.0 , 则在/etc/netmasks文件中写:172.16.255.0 255.255.255.0

4. ifconfig命令

检测网络端口状态
#ifconfig -a
配置网络端口地址
#ifconfig le0 172.16.255.1 netmask 255.255.255.0
配置网络端口状态
#ifconfig le0 up/down
配置网络端口是否可用
#ifconfig le0 plumb/unplumb

5. ping命令

检测网络状态
测试网络速度

第二章 网络服务

1. /etc/services文件

网络服务协议的端口号
网络协议的服务类型

#cat /etc/inet/services
ftp-data 20/tcp
ftp 21/tcp
telnet 23/tcp
smtp 25/tcp mail
sunrpc 111/udp rpcbind
sunrpc 111/tcp rpcbind


每个TCP/IP应用层服务如(FTP、Telnet)都在传输层有一个端口号 。/etc/services文件包含了每个能识别出的服务协议所对应的静态端口号 。应用应使用唯一分配的端口号向传输提供者和远程对等实体标识自己 。
文件中每一项都由服务名及其相关的端口号、传输协议提供者组成 。有些服务可以在TCP和UDP上都可以运行 。这时 , 此服务被列出两次 。

2. /etc/inetd.conf文件


# cat /etc/inet/inetd.conf
ftp stream tcp nowait root /usr/sbin/in.ftpd in.ftpd
telnet stream tcp nowait root /usr/sbin/in.telnetd in.telnetd
login stream tcp nowait root /usr/sbin/in.rlogind in.rlogind
talk dgram udp wait root /usr/sbin/in.talkd in.talkd
...

Unix并不是让每种服务的守护进程都在自己的端口上等待请求 , 而是将代表各个服务守护进程等待请求的任务交给一个叫inetd的服务进程 。这样就可以大大减少对系统资源的占用 。只有当超级服务进程发现一个服务请求时 , 它才调用该服务的守护进程 。/etc/inetd.conf配置文件允许inetd在启动时决定自己将代表哪些服务等待服务请求 。如果一种服务的守护进程没有包含在inetd.conf文件中 , 那么当inetd接收到该服务的请求时 , 会把该请求丢弃 。
文件的字段:
service_name 这是文件/etc/services中列出的服务的标志符 。
socket_type 用来标志使用的数据传输服务的类型 。
proto 标识传输协议的名字 。是UPD和TCP
flags 可以被设为"等待"和"非等待" 。如果被设为"等待" 状态 , inetd在恢复监听端口上的其他请求时 , 必须等待服 务协议释放将其连接到网络的连接 。"非等待"可以使 inetd立即监听其他的请求 。大多数TCP协议的采用"非等 待"方式 , 而UDP采用"等待"方式 。
user 表示调用服务的用户名 。
server_pathname 表示inetd在响应相关服务请求时必须调用的 服务程序的完整路径名 。
Args 该域包括服务的程序所使用的命令行参数 。即以程序名开 始 , 然后跟随用户设置的参数 。

第三章 路由和网关

1. /etc/defaulrouter文件

配置缺省网关
防止不必要的路由进程
适用于只有一个路由器通向其它网段
单一路由占用较小的路由表资源

该文件保存了缺省路由得信息 。系统安装时并没有该文件 , 是用户自己创建的 。文件内容是缺省路由的地址 。
#cat /etc/defaultrouter
172.16.255.254

优点:
占用资源少 , 只有一条路由条目 。

2. /etc/gateways文件

路由表文件
net gateway metric
dest. net 目标网段
router 下一跳路由器的地址
count 跳数

3. route命令

route add|delete [host|net] destination [gateway ]
Add a route
#route add net 128.50.3.0 192.168.1.1 1
Delete a route
#route delete net 128.50.2.0 192.168.12.2

4. 查看路由表

# netstat -r
Routing Table:
Destination Gateway Flags Ref Use Interface
----------- ---------- ----- --- --- ---------
localhost localhost UH 0 2272 lo0
202.96.0.0 192.168.12.1 U 3 562 le0
10.103.0.0 192.168.12.2 U 3 562 le0
#
Destination 目标网络或主机
Gateway 转发数据包的主机
Flags 这条路由的状态 , 这个参数有这样几个选项:
U 端口处于激活状态(up)
H 目标是个主机 , 而不是网段

Ref 同一个网络接口地址拥有的路由条目数量
Use 通过这条路由的包数量 , 对于localhost来说 , 这个数字代表 所有接收的包数量
Interface 路由的网络接口

第四章 DNS客户端的设置

1. /etc/resolv.conf文件

记录DNS服务器的地址和域名
关键字:
domainname
nameserver
# more /etc/resolv.conf
nameserver 172.16.255.3
domainname sunrise.com.cn

2. /etc/nsswitch.conf文件

记录主机名的搜索顺序等信息
# more /etc/nsswitch.conf
#
# /etc/nsswitch.dns:
#
# An example file that could be copIEd over to /etc/nsswitch.conf; it uses
# DNS for hosts lookups, otherwise it does not use any other naming service.
#
# "hosts:" and "services:" in this file are used only if the
# /etc/netconfig file has a "-" for nametoaddr_libs of "inet" transports.

passwd: files
group: files
# You must also set up the /etc/resolv.conf file for DNS name
# server lookup. See resolv.conf(4).
hosts: files dns
ipnodes: files



将这个文件的hosts记录配置成hosts: files dns

3. nslookup命令

用于查询DNS服务器
用于验证客户端的设置
用于下载DNS数据库

# nslookup
Default Server: ns.zjhzptt.net.cn
Address: 202.96.96.68

> www.sun.com
Server: ns.zjhzptt.net.cn
Address: 202.96.96.68

Non-authoritative answer:
Name: www.sun.com
Address: 192.18.97.241

>
启动时 , nslookup缺省地以本地服务器为目标 。响应中包括目标服务器的名字和地址 。
>是提示符 , 这意味着可以开始发送名字服务询问或配置 。

请大家好好学习 , 在为新人指点 , 我们一起努力