warshining的个人空间 https://blog.eetop.cn/?396521 [收藏] [复制] [分享] [RSS]

日志

局域网内Solaris更改hosts的问题

已有 7809 次阅读| 2010-12-29 17:41 |个人分类:Linux

Solaris的ip地址存在etc/hosts下面,修改需要超级用户ID,进入超级用户的命令“su -root”,登陆上去之后,vi打开hosts文件,注意,一般在超级用户下,权限为rwx,但修改时会有提示:read only。
对只读文件会提示,ROOT可以用w!来强制写入。一般wq!强制写入外加退出。

虽然修改完了hosts内容,是否能上网还不清楚,下面的文章从网络上粘贴过来的,希望有用。

完成solaris安装后,请注意修改三部分文件

 
1.使root用户可以使用telnet功能:修改/etc/default/login文件,请注释掉root行:
 1)打开telnet服务:
   # svcadm enable telnet
    svcadm是Solaris下最新的网络服务管理系统,要了解它和svcs的使用方法,请参见其帮助手册。
 2) 开放root登录权限:修改/etc/default/login文件,注释掉其中的:CONSOLE=/dev/console
 
2.打开ftp功能:
 Solaris 9以前 修改 /etc/ftpusers,将root行注释掉
 Solaris 9 修改/etc/ftpd/ftpusers,将root行注释掉

3.设置ip地址:
 1)ifconfig命令用于配置网卡地址,改动后立即生效,但并不保存配置,下次启动后失效。
查看网卡、ip状态
 # ifconfig -a
 lo0: flags=849 mtu 8232
 inet 127.0.0.1 netmask ff000000
系统会显示网络接口的名称,接口的状态(up or down),接口的IP地址和掩码等信息
更改网络接口的IP地址:
   #ifconfig hme0 down
   #ifconfig hme0 211.101.149.233 netmask 255.255.255.0 up
首先,使用down命令参数把网络接口hme0的服务暂时停止,然后再用ifconfig命令给接口分配新的IP地址和掩码,并启动网络接口服务也可以通过改变文件/etc/hosts中的IP地址的值并重新启动系统来更改机器的IP地址。
 2)想要永久更改配置,则要更改配置文件
和网卡基本设置相关的配置文件放在/etc/inet和/etc目录下,包括:
/etc/hosts -> /etc/inet/hosts (文件中的每一行记录表示hostname和ip地址的对应关系)
/etc/hostname. (文件内容和文件的扩展名构成hostname和interface设备名的对应关系)
/etc/netmasks (文件中的每一行记录表示和netmask的对应关系)
/etc/dhcp. (dhcp)
/etc/defaultrouter
/etc/nsswitch.conf
创建和修改配置文件后,需要重启系统才能使设置生效。

 /etc/hosts——主机名解析。是一个中介的机制来进行IP地址和易记名称的转换,实现域名的本机解析。DNS和/etc/hosts这两种方法。DNS解析的功能上较为强大,但是因为涉及的内容很广。/etc/hosts解析的功能不如DNS,但是设置内容简单。
 /etc/inet/ipnodes文件同时存储IPv4 和IPv6 地址。此外,也可以存储以传统的点分十进制或CIDR 表示法表示的IPv4 地址。此文件作为将主机名与其IPv4 和IPv6 地址进行关联的本地数据库。该文件与/etc/hosts一起存储网络中每台计算机(包括pine本身)的网络地址。/etc/inet/ipnodes文件同时存储IPv4和IPv6地址。/etc/inet/ipnodes文件与/etc/hosts文件使用相同的格式约定。
 /etc/hostname.XXX——网络接口名
 /etc/netmasks——网络掩码
 /etc/nsswitch.conf——configuration file for the name-service switch。设定解析顺序,比如 files nis dns ... ,如果找不到nsswitch文件,默认解析方式是dns。
 /etc/defaultrouter包括主机的路由地址。选用动态路由协议,则可将/etc/defaultrouter文件置为空。若选择静态协议,只需在/etc/defaultrouter文件中填入缺省路由器名,这样当Unix路由器找不到寻径路由时便将IP包发往缺省路由器。
 MS:两个文件的优先级是:/etc/inet/ipnodes先,/etc/hosts后。
 常见问题:
在/etc/hosts文件中修改了IP地址,重启后,发现机器的IP地址还是原来的,是怎么回事?
问题可能出在/etc/inet/ipnodes文件。该文件的语法跟/etc/hosts相同,但优先级高于/etc/hosts。如果 /etc/inet/ipnodes文件中保留了原来的IP地址,那么/etc/hosts中相同hostname的IP设置将被忽略。将ipnodes 文件中的IP地址一行删掉,或改成新的IP地址,重启后,问题就消失了。
 
举例l:以网卡hme0为例(网卡名是什么,就是hostname.XXX):
#more /etc/hostname.hme0
hostname
#more /etc/hosts
127.0.0.1 localhost
172.16.255.2 hostname loghost
#vi /etc/hosts
#more /etc/hosts
127.0.0.1 localhost
172.16.3.3 hostname loghost
#more /etc/netmasks
#
# The netmasks file associates Internet Protocol (IP) address
# masks with IP network numbers.
#
# network-number netmask
#
# The term network-number refers to a number obtained from the Internet Network
# Information Center. Currently this number is restricted to being a class
# A, B, or C network number. In the future we should be able to support
# arbitrary network numbers per the Classless Internet Domain Routing
# guidelines.
#
# Both the network-number and the netmasks are specified in
# "decimal dot" notation, e.g:
#
# 128.32.0.0 255.255.255.0
#vi /etc/netmasks
#more /etc/netmasks
#
# The netmasks file associates Internet Protocol (IP) address
# masks with IP network numbers.
#
# network-number netmask
#
# The term network-number refers to a number obtained from the Internet Network
# Information Center. Currently this number is restricted to being a class
# A, B, or C network number. In the future we should be able to support
# arbitrary network numbers per the Classless Internet Domain Routing
# guidelines.
#
# Both the network-number and the netmasks are specified in
# "decimal dot" notation, e.g:
#
# 128.32.0.0 255.255.255.0
172.16.3.0 255.255.255.0
# reboot
总结一下,要修改Solaris的IP地址,主要需要改三个文件,分别是/etc/hosts, /etc/netmasks, /etc/inet/ipnodes。如果想修改网关的话,还需要改/etc/defaultrouter文件。

点赞

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 注册

  • 0

    周排名
  • 0

    月排名
  • 0

    总排名
  • 0

    关注
  • 5

    粉丝
  • 0

    好友
  • 14

    获赞
  • 52

    评论
  • 3742

    访问数
关闭

站长推荐 上一条 /1 下一条


手机版| 小黑屋| 关于我们| 联系我们| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2025-10-6 22:42 , Processed in 0.021153 second(s), 7 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
返回顶部