---
title: "solaris 10操作系统静态ip设置"
author: "libin123"
date: "2010-05-23T18:33:44Z"
tags: []
categories: ["操作系统"]
slug: "solaris-10-ip"
draft: false
lastmod: "2010-05-24T10:18:56Z"
id: 673350
url: "https://dbua.iteye.com/blog/673350"
---

新安装了solaris 10操作系统,安装成功之后,发现不能上网,其实在安装操作系统的过程中,已经设置了静态的IP地址,但要使机器能上网,还得配置一些网络设置,具体如下:

假如想设置的网络配置信息

为：hostname:mysolaris IP：192.168.0.12 子网掩码：255.255.255.0 网关：192.168.0.1 dns(假设的):192.168.0.1

设置IP需要修改三个文件，个体的操作步骤如下：

1）、修改/etc/hosts文件，添加要设置的IP地址.

#vi /etc/hosts

添加IP，具体内容：192.168.0.12 mysolaris loghost

保存/etc/hosts文件.

添加IP，格式为：ip hostname loghost

#more /etc/hosts

::1 localhost

127.0.0.1 localhost

192.168.0.12 mysolaris loghost

2）、修改/etc/netmasks文件.

#vi /etc/netmasks

添加子网掩码：192.168.1.0 255.255.255.0

保存/etc/netmasks文件.

添加子网掩码的格式为：xxx.xxx.xxx.0 xxx.xxx.xxx.xxx

#more /etc/netmasks

192.168.1.0 255.255.255.0

3)、修改/etc/defaultrouter文件.

#vi /etc/defaultrouter

添加默认路由：192.168.0.1

保存/etc/defaultrouter文件.

#more /etc/defaultrouter

192.168.0.1

修改完这三个文件，IP地址的设置已经完成。但如果想上网还得需要配置dns,dns配置的信息如下：

1、修改/etc/resolv.conf文件，如果/etc/resolv.conf文件不存在，则需要创建它(touch /etc/resolv.conf)。

#vi /etc/resolv.conf

添加内容：nameserver  192.168.0.1

保存/etc/resolv.conf文件.

2、修改/etc/nsswitch.conf文件.

#vi /etc/nsswitch.conf

在文件中的hosts: files 后添加dns 即：hosts: files dns

保存/etc/nsswitch.conf文件.

重新启动系统即可。

ip   和子网掩码   执行这个命令：ifconfig   eth0   192.168.1.123   netmask   255.255.255.0 up  
网关的设定执行这个命令：   route   add   default   gw   192.168.1.3  
把这两个命令写到/etc/rc.local   或者/etc/rc.d/rc.local   里面都可以的，这样就可以永久保存