天天看點

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  

繼續閱讀