Asignar direccion IP estática en Opensolaris

De Joaquina
Saltar a: navegación, buscar

En este instructivo se explica rápidamente la configuración estática de red en Opensolaris. La misma fue probada y funcionó correctamente en un Opensolaris 2008.11 y en Solaris 10

Beyond DHCP with DNS and Routing in OpenSolaris

I've finally had time to install OpenSolaris on bare metal. Previously I've installed it under VirtualBox on my Mac and Linux machines. The networking configuration really had me pulling out my hair. If you knew me, you'd know I don't have much hair so this means I was really desperate. Here's some helpful pointers to get started with networking beyond the default DHCP settings for DNS hostname resolution and routing.


Background

First, I should provide some background. My office (home office) networking scheme includes a cable modem, 3 non-commercial routers (networks), and a switch. I'm running "Bind" on a Kubuntu machine as my DNS server. I know, I'll convert all this over to OpenSolaris when I learn more about it. So each machine on my networks has an assigned IP address and hostname mapped by the DNS server. Naturally, when I run my OpenSolaris machine, I want it to have a static IP address and a hostname. In the future I'm going to look into MultiCast DNS. But for now, I just wanted to add my new OpenSolaris machine to my network.


Changing From a DHCP assigned IP Address to a Static IP Address

The first step is to configure NWAM (Network Auto-Magic) so my wired ethernet interface is used instead of my wireless interface. I also need to tell it to use a static IP address for the wired interface. To do this, I edited the NWAM config file "llP" like this:

   pfexec vi /etc/nwam/llp

I changed it to look like this:

   e1000g0 static 192.168.1.17
   ath0 dhcp

Notice that the wired interface is before the wireless interface. This is how NWAM determines which interface to use first. Note - the nwamd man page states, "Note, however, that this interface is Volatile and may change in a future release."

Since I changed NWAM, I have to restart nwamd (the NWAM daemon).

   pfexec svcadm restart nwam



Comentario extra (de Ary):

Otra forma de cambiar de DHCP a IP estática es deshabilitar el servicio nwam (configuración automática de red) y habilitar el default:

svcadm disable svc:/network/physical:nwam

svcadm enable svc:/network/physical:default

luego se crea un archivo llamado /etc/hostname.[driver_de_placa_de_red] y dentro de ese archivo se coloca una sola linea con dirección IP y máscara de red

En mi caso:

   #echo 10.0.0.6/24 > /etc/hostname.rge0


Fin comentario (de Ary)



Getting DNS to Work Correctly

Since I went to all that work when I setup Bind (DNS), I really wanted to use it. My DNS server does forwarding so if the hostname lookup fails, the request is forwarded to "real" DNS servers somewhere in the ether to get IP addresses for hostnames like "yahoo.com" and "davidbotterill.com" (couldn't resist the plug :) ).

OpenSolaris by default uses NIS (Network Information Service) AKA YellowPages. So I had to tell NIS to use DNS for hostname resolution. This is a fairly simple task. I simply had to copy the provided nsswitch file like this.

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

The DNS client is already running. I know this because I ran this command.

   svcs -a | grep dns 

and saw this result

   online   14:17:45 svc:/network/dns/client:default

If you remember from networking 101, the DNS client uses "/etc/resolv.conf" to find the "nameserver". So I ran

   pfexec vi /etc/resolv.conf

made sure I had this entry in there.

   nameserver 192.168.1.2


Routing

So now I had a static IP. Doing "dig yahoo.com" returned valid IP addresses. But, I could still not "ping yahoo.com". You guessed it. There was a routing problem. I dug around in some of the service configuration files, particularly "/lib/svc/method/net-routing-setup" and found that without DHCP, OpenSolaris routing checks for this static route file.

   /etc/defaultrouter

Apparently, if I had real routers that supported RIP (Routing Information Protocol), OpenSolaris would discover the route out to the internet automatically. But remember, I'm running home routers not Cisco routers. :) I think some of them support RIP but I'll save that for another day.

In the "/etc/defaultrouter" file I put the IP address of my gateway (the router IP address) for the network my OpenSolaris machine is on. In my case this is "192.168.1.1". Now I need to restart the routing by running the following command.

   pfexec svcadm restart network/routing-setup


Fuente: [[1]]

Autor: Ary