openindiana下配置静态IP

来源:互联网 发布:数据录入员靠谱吗 编辑:程序博客网 时间:2024/06/10 20:10

Introduction

OpenIndiana 151a is by default installed to use NWAM and DHCP dynamic IPs. In many situations it would be preferred to set up a static IP for the server, something which is difficult to do through nwam.  There a few guides to use NWAM for Static IPs (examples: A, B, or C) but none seem straight forward.

GUI Way (easiest)

Using su, sudo or pfexec to acquire the required privileges:

Commands

# svcadm disable svc:/network/physical:nwam
# svcadm enable svc:/network/physical:default
# cp /etc/nsswitch.dns /etc/nsswitch.conf
# network-admin

network-admin

Connections

General

DNS

Hosts

This last command will open a window in gnome in which you can fill in the required values.

Console Way

Commands (Solaris 11 and OpenIndiana 151):

# ipadm create-addr -T static -a 1.2.3.4/24 e1000g0/v4static
# route -p add default 1.2.3.254
# cp /etc/nsswitch.dns /etc/nsswitch.conf

# vi /etc/hosts
# vi /etc/resolv.conf

Commands:

# svcadm disable svc:/network/physical:nwam
# svcadm enable svc:/network/physical:default
# cp /etc/nsswitch.dns /etc/nsswitch.conf
# vi /etc/hosts
# vi /etc/resolv.conf
# vi /etc/defaultrouter
# vi /etc/hostname.NIC
# svcadm restart svc:/network/physical:default

files

The following files need to be edited.  Change the parts necessary, where oibox is the current computer name, example.net is the domain name (or workgroup). 

/etc/hosts
# Internet host table
#
127.0.0.1localhost.localdomain localhost.local localhost loghost oibox oibox.local oibox.localdomain oibox.example oibox.example.net
::1localhost.localdomain localhost.local localhost loghost oibox oibox.local oibox.localdomain oibox.example oibox.example.net
/etc/resolv.conf
nameserver8.8.8.8
nameserver8.8.4.4
/etc/defaultrouter
192.168.1.1

Note the file /etc/hostname._NIC_ will be something like /etc/hostname.bnx0 where the suffix is your physical NIC.

/etc/hostname.NIC
192.168.1.16

Potential Issues and Workarounds

Typically it is always a good ideas do all this work in a true console (direct keyboard plus screen or a BMC/iLOM/IMM device) as you may lose all networked connectivity to your system.

firewalls

 

The use of ipfilter (a firewall) can prevent the changes above from working.  To check if ipfilter is active

# svcs ipfilter

The following command to disable ipfilter may solve issues in trying to get a static IP to work.

# svcadm disable ipfilter 

alternate set of files changes 

A more traditional set of changes (similar to what sys-unconfig would do), allowing the system to have multiple IP addresses with different hostnames on each of your physical interfaces.  The below assumes you want the server to have Static IP: 192.168.1.16, hostname: oibox, a default route of 192.168.1.1, and to use google's DNS name servers of 8.8.8.8 and 8.8.4.4.   This is what I do, it is different than the above "files" section, and is based on information at http://www.outside-the-box.com/?p=185

/etc/hosts
# Internet host table
#
::1            oibox.local localhost loghost
127.0.0.1      oibox.local localhost loghost
192.168.1.16   oibox oibox.example.net
/etc/resolv.conf
nameserver8.8.8.8
nameserver8.8.4.4
/etc/defaultrouter
192.168.1.1

Note the file /etc/hostname._NIC_ will be something like /etc/hostname.bnx0 where the suffix bnx0, pcn0, nge0, etc. is your physical NIC identifier.

/etc/hostname.NIC
oibox

ssh keys

You may wish to generate a new set of ssh keys to do this you will need to remove the keys, the will be regenerated automatically on next system reboot.

# rm  /etc/ssh/*key*

Other

This section needs to be merged with http://wiki.openindiana.org/oi/4.2+Network+management 

 
以上转自 http://wiki.openindiana.org/oi/Static+IP
以上经本人测试通过
原创粉丝点击