天天看点

solaris 9 x86网卡设置上网

(1)设置网络地址和子网掩码

1. /etc/hostname.interface

/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文件

/etc/hosts文件将网卡名与IP地址进行了映射,与/etc/hostname.interface 协同工作,配置本机网卡地址的IP地址。

# 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命令

检测网络状态

测试网络速度

(2)路由和网关

1. /etc/defaulrouter文件

/etc/defaulrouter文件配置系统的缺省路由,防止不必要的路由进程,适用于只有一个路由器通向其它网段的网络。系统安装时并没有该文件,是用户自己创建的。文件内容是缺省路由的地址。

#cat /etc/defaultrouter

172.16.255.254

优点:

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

(3)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  

继续阅读