LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 4638|回复: 7

Solaris网络配置的相关文件

[复制链接]
发表于 2005-1-11 16:47:03 | 显示全部楼层 |阅读模式
在安装SOLARIS的过程中如果选择了DHCP的话就不会出现主机名的填写,在安装好之后就有一些服务就会因为没有读取到主机名而无法启动,比如SENDMAIL服务。不知道兄弟们出现过这个问题没有,反正我是出现过了,把问题的解决过程总结一下给有同样问题的兄弟参考参考。
看了看SUN的文档资料发现需要修改六个文件,这个六个文件名和目录罗列如下:
/etc/hosts
/etc/hostname.rtls0
/etc/nodename
/etc/net/ticots/hosts
/etc/net/ticotsord/hosts
/etc/net/ticlts/hosts

我修改好的文件如下:
hosts文件
127.0.0.1           localhost       loghost
10.143.158.103  sys-solaris      loghost

hostname.rtls0和剩下的四个文件里面都是空的,所以只需要写入主机名就行了
sys-solaris 这个是我机器的主机名
nodename这个文件在etc下面是没有的,需要自己创建一个。
有些论坛有用命令行来解决
用uname -S hostname
这个方法我试过了,运行这个命令后再键入hostname命令确实发现机器的名字变了,但是重新启动之后还是老样子。这个我也不知道是怎么回事,估计是写在缓冲里吧,搞不太明白。
以上的方法我在solaris10下实验通过了。如果有更好的方法请大家赐教,俺也是个菜鸟。
发表于 2005-1-12 09:07:22 | 显示全部楼层
太好了,替论坛的兄弟谢谢楼主,如果大家都向楼主那样,把自己遇到的问题分析总结并贴出来,那么LinuxSir的Solaris版就绝对比HANDBOOK更有价值了,呵呵。


这个帖子挺好的,但我希望再加上一些东西,比如不使用DHCP的时候,我们需要配置IP地址、子网掩码、主机名、网关等等,那么这些文件在哪里呢?又是如何修改呢?我感觉,把这些写上,会更丰满一点儿。你若有空,就简单写写,我这里也整理了一些,我会帮你写一点儿,然后我会把这个帖子加精,放到Solaris网络配置的索引里。最后,说声感谢。
 楼主| 发表于 2005-1-12 11:21:06 | 显示全部楼层
如果在安装过程中没选择DHCP的话系统会有填写主机名、IP地址、子网掩码、缺省路由。我前一次安装的时候没有搞明白这个缺省路由干什么用的,所以就没有选上,结果安装好之后发现DNS无法解析,而且只能PING通在同一个交换机上同一个网段的机器。这个时候才明白缺省路由是干什么用的了,这个建立的应该是一个到其他网段的路由。应该选上,填写的是网关地址。要是在安装后的解决的话我也不知道怎么解决,在CU上找了个帖子,但是只能解决本地网络的DNS问题,可以参考参考!版主有什么解决方法也拿上来看看
这个帖子原文如下,是E文的,不过很简单能看明白:
I find there are many guys don't know how to setup files to connected to internet and ask the same question again and again. So, I post my configuration file here for those who need reference for internet set up. Hopefully this can help some one a little.

OK, basicly there are 4 file you have to config at Solaris to go to internet:

1. /etc/hosts or /etc/inet/hosts
2. /etc/resolv.conf
3. /etc/nsswitch.conf
4. /etc/defaultrouter

What i have to say is that the files /etc/resolv.conf and /etc/defaultrouter are not existed by default system installation. you have to create that 2 file when you need setup internet.

The following are my configuration file: (192.168.0.3 is my solaris 9 system and 192.168.0.1 is the machine of Windows 2000/XP which has 2 network interfice, one connected to internet by 24.101.186.193 and one connected to solaris9 by interfice 192.168.0.1. You have to choose to share internet for the interface that connected to internet at windows as you have)

Cat /etc/hosts

127.0.0.1 localhost
192.168.0.3 lion loghost
192.168.0.1 router

---------------------------------------------

vi /etc/resolv.conf

nameserver 192.168.0.1

-----------------------------------------------
vi /etc/nsswitch.conf

hosts: files dns

-----------------------------------------------

vi /etc/defaultrouter

router 192.168.0.1

------------------------------------------------

Good luck.
发表于 2005-1-12 14:01:01 | 显示全部楼层
先加精,请兄弟们继续接着写,争取以后想找网络配置……这一个帖子就搞定,嘿嘿~~~~~
发表于 2005-5-3 19:19:34 | 显示全部楼层

ticotsord 是什么东东???

大家都一样,还是就你的机子才有的名字
回复 支持 反对

使用道具 举报

发表于 2005-5-3 22:00:58 | 显示全部楼层
与版本有关吧,要考SCSA才需要明白那个。
通常 sys-unconfig 再重新启动就可以重新设置这些个东西
回复 支持 反对

使用道具 举报

发表于 2005-10-10 23:40:37 | 显示全部楼层
Configuring network interface cards
Getting your interfaces to talk

Lance Spitzner
http://www.spitzner.net/

Last Revised: March 23, 2004

This article is the first of a two part series. In this first article we will cover how to configure, troubleshoot, and modify system interfaces. The second article will cover static routing tables for systems with two or more interfaces. In both articles I will be focusing on TCP/IP in a Ethernet environment.
Interfaces

Network Interface Cards are what allow your system to talk to the network. When they don't work, neither do you. I will cover how to configure, troubleshoot, and modify your interfaces. I will not be covering routing issues, that will follow in the next article. My goal here is to get your interface up and properly running.

The first place to start is installing and testing the hardware. Once you have installed the hardware, SPARC systems can be tested at the EPROM level to verify the network interface cards. Use the manual that accompanies the interface card on how to test that specific card. Solaris x86 is a little different, as there is no true EPROM, and the drivers are different. However, Solaris x86 2.6 is Plug and Play compatible, and I have had fairly good luck adding network interface cards.

Once you have confirmed at the hardware and driver level that everything works, the fun can begin. The place to start is the ifconfig command. This powerful command allows you configure and modify your interfaces in real time. However, any modifications made with ifconfig are not permanent. When the system reboots, it will default to its previous configuration. I will first show you how to make all modifications with the ifconfig command. The second half of this article will cover making these modifications permanent by modifying the proper configuration files.
ifconfig

ifconfig -a

will show you which interfaces are currently installed and active. Remember, just because you added the physical network interface card does NOT mean it is active. If you do an ifconfig before you have configured the device, the interface will not show up. Once configured however, the typical output of the ifconfig -a command would look like this:

lo0: flags=849<UP,LOOPBACK,RUNNING,MULTICAST> mtu 8232
           inet 127.0.0.1 netmask ff000000
elxl0: flags=863<UP,BROADCAST,NOTRAILERS,RUNNING,MULTICAST> mtu 1500
          inet 192.168.1.132 netmask ffffff00 broadcast 192.168.1.255
          ether 8:0:20:9c:6b:2d

Here we see two interfaces, lo0 and elxl0. lo0 is the standard loopback interface found on all systems. elxl0 is a 10/100 Mbps interface. All hme interfaces are 10/100 Mbps, all le interfaces are 10 Mbps, all qe interface are quad 10 Mbps, and qfe interfaces are quad 10/100 Mbps. There are three lines of information about the interface. The first line is about the TCP/IP stack. For the interface elxl0, we see the system is up, running both broadcast and multicast, with a mtu (maximum transfer unit) of 1500 bytes, standard for an Ethernet LAN. Notrailers is a flag no longer used, but kept for backwards compatibility reasons.

The second line is about the IP addressing. Here we see the IP address, netmask in hexadecimal format, and the broadcast address. The third line is the MAC address. Unlike most interfaces, Sun Microsystems's interfaces derive the MAC addressing from the NVRAM, not the interface itself. Thus, all the interfaces on a single SPARC system will have the same MAC address. This does not cause a problem in routing, since most NICs are always on a different network. Note, you must be root to see the MAC address with the ifconfig command, any other user will only see the first two lines of information.

The first step in bringing up an interface is "plumbing" the interface. By plumbing, we are implementing the TCP/IP stack. We will use the above interface, elxl0, as an example. Lets say we had just physically added this network interface card and rebooted, now what? First, we plumb the device with the plumb command.

ifconfig elxl0 plumb

This sets up the streams needed for TCP/IP to use the device. However, the stack has not been configured as you can see below.

elxl0: flags=842<BROADCAST,RUNNING,MULTICAST> mtu 1500
           inet 0.0.0.0 netmask 0
           ether 8:0:20:9c:6b:2d

The next step is to configure the TCP/IP stack. We configure the stack by adding the IP address, netmask, and then telling the device it is up. All this can be down in one command, as seen below.

  ifconfig elxl0 192.168.1.132 netmask 255.255.255.0 up

This single command configures the entire device. Notice the up command, which initializes the interface. The interface can be in one of two states, up or down. When an interface is down, the system does not attempt to transmit messages through that interface. A down interface will still show with the ifconfig command, however it will not have the word "up" on the first line.
Virtual interfaces

Before moving on to the configuration files, I would first like to cover virtual interfaces. A virtual interface is one or more logical interfaces assigned to an already existing interface. Solaris can have up to 255 virtual interfaces assigned to a single interface.

Once again, lets take the interface elxl0 as an example. We have already covered how to configure this device. However, lets say the device is on a VLAN (virtual LAN) with several networks sharing the same wire. We can configure the device elxl0 to answer to another IP address, say 172.20.15.4. To do so, the command would be the same as used for elxl0, except the virtual interface is called elxl0:*, where * is the number you assign to the virtual interface. For example, virtual interface one would be elxl0:1. The command to configure it looks as follows.

ifconfig elxl0:1 172.20.15.4 netmask 255.255.0.0 up

Once you have configured the virtual interface, you can compare elxl0 and elxl0:1 with the ifconfig command.

elxl0: flags=843<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
          inet 192.168.1.132 netmask ffffff00 broadcast 192.168.1.255
          ether 8:0:20:9c:6b:2d
elxl0:1: flags=842<BROADCAST,RUNNING,MULTICAST> mtu 1500
          inet 172.20.15.4 netmask ffff0000 broadcast 172.20.255.255

Here you see the two devices, both of which are on the same physical device. Notice how the virtual interface elxl0:1 has no MAC address, as this is the same device as elxl0. We can repeat this process all the way up to elxl0:255. The operating system and most applications will treat these virtual devices as totally independent devices.

Note, Matthew A. Domurat has identified a "bug" with Solaris 2.6. When working with virtual interfaces, Solaris 2.6 will randomly select one of the interfaces as its source address for every packet sent. These are the patches to fix this:

    * 105786-05: SunOS 5.6: /kernel/drv/ip patch
    * 105787-04: SunOS 5.6_x86: /kernel/drv/ip patch

Configuration files

Now you know how to configure your network interface cards. Unfortunately, any modifications, additions, or deletions you make with ifconfig are only temporary, you will lose these configurations when you reboot. I will now discuss what files you have to configure to make these changes permanent.

The place to start is the file /etc/hostname.*, where * is the name of the interface. In the case of elxl0, the file name is /etc/hostname.elxl0. The virtual interface elxl0:1 would have the file name /etc/hostname.elxl0:1. This file has a single entry, the name of the interface. This name is used in the /etc/hosts file to resolve name to IP address.

The file /etc/hostname.* is critical, this is what causes the device to be plumbed. During the boot process, the /etc/rcS.d/S30network.sh file reads all the /etc/hostname.* files and plumbs the devices. Once plumbed, the devices are configured by reading the /etc/hosts and the /etc/netmasks file. By reading these two files, the device is configured for the proper IP and netmask, and brought to an up state. Lets take the device elxl0 as an example. During the boot process, /etc/rcS.d/S30network.sh looks for any /etc/hostname.* files. It finds /etc/hostname.elxl0, which contains the following entry.

  homer

/etc/rcS.d/S30network.sh looks in /etc/hosts and resolves the name homer with an IP address of 192.168.1.132. The device elxl0 is now assigned this IP address. The script then looks at /etc/netmasks to find the netmask for that IP address. With this information, the startup script brings up interface elxl0 with an IP address of 192.168.1.132 and a netmask of 255.255.255.0. It may seem redundant having the script review the netmask of a class C address. However, do not forget that, starting with 2.6, Solaris supports both classless routing and VLSM (Variable Length Subnet Masks), both of which I will discuss in my next article.

As you have seen in this example, there are three files that must be modified for every interface. The first is /etc/hostname.*, this is the file you create to designate the interface's name. The second file is /etc/hosts, here you resolve the IP to the interface name. Last is /etc/netmasks, this is where you define the netmask of the IP address.
Troubleshooting

Once you have mastered the tricks to modifying your interfaces, troubleshooting should be easier. Several things I always look for when troubleshooting an interface. First, when working with an unfamiliar machine, often you do not know how many physical interfaces are on the machine. A quick way to tell is use dmesg, this will give you information on the physical hardware. Look for le0, iprb0, elxl0, or rtls0. These are the names assigned to the physical devices.

If an interface is not responding to the network, check to be sure it is the correct IP address and netmask. The ifconfig command is a quick and temporary way to change IP and netmask information for troubleshooting purposes. MTU (maximum transfer unit) is another possibility. Some systems may have problems communicating due to fragmented packets. Changing the mtu size may solve that problem. You'll notice that you did not have to set the mtu size in the examples above, these are set to defaults automatically, such as 1500 for Ethernet interfaces.

If that fails, try bringing the face down, then reinitializing it with the up command. If nothing else works, unplumb the device, then plumb it again. Basically, this reinstalls the TCP/IP stack.
Conclusion

Network Interface Cards are critical to your systems networking capability. Understanding the configuration of your interface(s) ensures your system's productivity. Next month we will look at routing tables, and ensure that once your interfaces are configured and up, your packets will know where to go.
Author's bio

Lance Spitzner enjoys learning by blowing up his Unix systems at home. Before this, he was an Officer in the Rapid Deployment Force, where he blew up things of a different nature. You can reach him at lance@honeynet.org.
用ifconfig应该跟linux差不多吧
回复 支持 反对

使用道具 举报

发表于 2005-10-10 23:44:39 | 显示全部楼层
Configuring networking

Keith Parkansky
http://www.execpc.com/~keithp

Last revised: May 1, 2002

Networking information in Solaris is stored in text files. Configuration is done by filling in the appriopriate data to these files and invoking specific commands in a terminal window.

   1. Pop up the menu above the "Text Note" icon and click on Text Editor. Use the editor to open the file:

  /boot/solaris/devicedb/master

      and use the Find feature (under Edit on the menu bar) to locate the model number of your NIC - example: 3C905 (3Com) or 9432 (SMC). Note that the Find feature is case sensitive in the CDE text editor.
   2. If your NIC is in the HCL it will be in the master file. The line for the SMC 9432 I'm using in my system looks like this:

  pci10b8,a011 pci10b8,a011 net pci spwr.bef

      I have the "spwr.bef" bolded because this is the driver name and you'll need to know the driver name for other files. Remember it.

      I'll save you some work if you have a 3Com 3C905 NIC. The line will be:

  pci10b7,9200 pci10b7,9200 net pci elxl.bef

   3. Use the editor to open the file:

  /etc/driver_aliases

      (Opening this file will automatically close the master file.) If your NIC is supported it will be listed here also. The line for my SMC NIC was:

  spwr "pci10b8,a011"

      which you can see is the same information found in the master file just rearranged a bit.
   4. If you know what is the actual device driver name for your NIC you can verify if the device was properly detected and the driver loaded by looking in /dev directory and searching for files which names begin with the driver name, eg. /dev/spwr0 or /dev/elxl0 for devices used in our example. The number after the driver name in the file name is the consecutive number of the NIC in your system (numbered 0, 1, 2, etc.) using the same driver.
   5. Use the editor to open the file:

  /etc/hosts

      and enter a new line in it with the IP address you want to give the system on your network and its' hostname. I called my machine "solarisi" so I entered:

  192.168.10.20     solarisi solarisi.bigsunfan.com     loghost

      Make sure you press Enter after typing this in to create a new (blank) line beneath it!

      With your changes, the resulting the file should look like this:

  127.0.0.1          localhost
  192.168.10.20      solarisi solarisi.bigsunfan.com     loghost

      Note that the bigsunfan.com domain need not to be a registered domain. I simply use it as an example.

      Don't forget to save the file. Click on File on menu and select Save.

      A note about Sendmail and the hosts file.

      Sendmail is a mail server, or more professionally, a Mail Transport Agent, MTA in short. It is installed by deafult and started automatically when you boot your system. Sendmail is picky when it comes to FQDNs (Full Qualified Domain Names). When you booted your system you may have seen the infamous Sendmail error:

  sendmail[nnn]: My unqualified host name (solarisi) unknown;
  sleeping for retry

      If you are not going to run a mail server, simply turn Sendmail off by renaming its startup file:

      mv /etc/rc2.d/S88sendmail /etc/rc2.d/noS88sendmail

      Otherwise, you need to specify FQDN of your host in /etc/hosts file. For more details see Configuring Sendmail tutorial.
   6. Check if the file

  /etc/hostname.driver_nameNIC_number

      exists. Use the ACTUAL WORD "hostname" in the name of the file, NOT the hostname you gave your system. The driver_name is the name I said you should remember above, and the NIC_number is the number of the NIC in your system. Since I only have one NIC in my system, my file was named:

  /etc/hostname.spwr0

      The file should contain your host name, the same as in /etc/hosts file. If there is no such file, or it contains improper value you need to correct it.

      You could also enter the IP address instead of the host name which is needed if you want to assign multiple IP addresses to a single interface, such as with hosting multiple Web sites on a single server (Apache's virtual hosting), create multiple files using the above naming convention but append a :1 and :2 etc. to the file name for each additional file. Each file should have a single, different IP address. For example:
      /etc/hostname.spwr0                       contains 192.168.10.20
      /etc/hostname.spwr0:1         contains 192.168.10.21
      /etc/hostname.spwr0:2         contains 192.168.10.22
   7. Now you set up an appropriate subnet mask. Open the file

  /etc/netmasks

      and the top of the file has comments that explain the contents. You basically just enter your "network number" (NOT your system's IP address) followed by the subnet mask for your network. Given that the address I gave my system above (192.168.10.20) is a Class C IP address, my netmasks file looked like this:

  192.168.10.0        255.255.255.0

      The following table may help you determine what your network number and subnet mask should be based on the first number of your system's IP address:

      IP Number Class         Network Address Range         Subnet Mask         Private Address Range
      A         1.0.0.0 to 126.0.0.0         255.0.0.0         10.x.x.x
      B         128.0.0.0 to 191.255.0.0         255.255.0.0         172.16.x.x to 172.31.x.x
      C         192.0.0.0 to 223.255.255.0         255.255.255.0         192.168.0.x to 192.168.255.x

      If you're setting up a small network in your home or office and you're not sure what IP address to use, use any address given in the "rivate Address Range" above for a Class C network. This will allow you to have up to 254 nodes (aka "hosts" in TCP/IP lingo) on your network.

      Once you've got the appropriate network and mask addresses entered, save the file.

   8. The /etc/hosts file mentioned above is used to resolve machine names to IP addresses on your local network. If you are connecting your system to a network that is connected to the Internet and you plan to use it to surf the Web, or have another need to resolve Internet domain names, you'll need to specify your ISP's DNS servers. This is done using another file called

  /etc/resolv.conf

      Note:  When you save the following newly created files the /etc directory should already be selected as the target for the saved file. That's why no path is specified for file saves. However, verify that //etc/ is in the "path or folder name" field when saving these files.

      Create the new file using the text editor by clicking on File and then on New and enter the following lines:

  domain enter-your-ISP's-domain
  nameserver enter-IP-address-of-primary-DNS-server
  nameserver enter-IP-address-of-secondary-DNS-server

      Be sure to hit Enter at the end of the last line and then save the file with the name resolv.conf

      The above file is used if your system is not part of a domain. If it is, ex: you are going to use your system as an Internet server, you have to list your domain name on the domain line and list your ISP's domain (for DNS) using the search keyword. For example:

  domain your-domain.com
  nameserver 172.31.214.78
  nameserver 10.138.14.2
  search your-ISPs-domain.com

   9. If your system is on a network that has a default gateway, you'll need to create

  /etc/defaultrouter

      file for tha. If your system is going to be an Internet server the default gateway is likely the address of the router interface that connects you to your ISP.

      Create a new file using the text editor (click on File and then on New) and simply enter one IP address. This IP address however will be for your default gateway. Be sure to hit Enter at the end of the address and then save the file as /etc/defaultrouter
  10. Unfortunately, simply creating the resolv.conf file earlier doesn't mean your system will automatically start to use it. Again, this file is only necessary if you will use your system to access the Internet or other large network where DNS servers are used to resolve system names. This includes simply using your system as a workstation to surf the Web. It doesn't have to be a server.

      Yet another file called nsswitch.conf is used to "tell" your system which name resolution methods to use (host files, DNS, etc) and in which order to use them. Fortunately, the Solaris installation includes several different pre-written versions of the nsswitch file. The default file only uses the host file to resolve machine names.

      In order for your system to use DNS servers, you'll have to issue the following command at the # prompt in a "This Host" window:

      cp /etc/nsswitch.dns /etc/nsswitch.conf

      Note:  At this stage all files related to network configuration are filled in, but the notworking on your system is not yet working properly. You can either reboot your system by typing in init 6 to make Solaris to reread configuration files and setup networking accordingly, or alternatively perform the following steps.
  11. Plumb the network interface with the following command

      ifconfig spwr0 plumb
  12. Make the interafce up by typing in

      ifconfig spwr0 192.168.10.20 netmask 255.255.255.0 up

      The IP part 192.168.10.20 of the above command is the IP assigned to the interface, in other words the IP of your host, and the netmask part 255.255.255.0 is the netmask specified in /etc/netmasks file.

      You should now be able to communicate with systems on your local network. You can verify this with ping command.
  13. Add the default route to routing table as follows

      route add default 192.168.10.1

      where 192.168.10.1 is the IP of the gateway on your network. This should be the IP specified in /etc/defaultrouter file discussed above.

You should now be able to communicate with all systems on the Internet. Verify this with ping command, or simply fire up a web browser.

Related man pages:

    * hosts,
    * resolv.conf,
    * nsswitch.conf,
    * netmasks,
    * defaultrouter,
    * ifconfig
    * route
    * ping.
还有一帖 没看完
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表