SOLARIS11 设置静态IP

在下面的例子中,我们会手动的设置服务器静态IP为10.163.198.20.


首先切换到DefaultFixed  NCP,默认为Automatic

root@solaris:~# netadm enable -p ncp DefaultFixed

在一个多网卡的机器上,你可以使用dladm 命令决定哪个网络接口映射到哪个物理设备
root@solaris:~# dladm show-phys
LINK              MEDIA                STATE      SPEED  DUPLEX    DEVICE
net0              Ethernet             up         1000   full      e1000g0
net1              Ethernet             unknown    0      unknown   pcn0

创建一个静态IP包括两个步骤:

1.创建网络接口

2.创建IP地址


注意:一个网络接口有可能拥有多个IP地址(用过LINUX都应该知道)

root@solaris:~# ipadm create-ip net0
root@solaris:~# ipadm show-if
IFNAME     CLASS      STATE      ACTIVE      OVER
lo0        loopback   ok         yes         ---
net0       ip         down       no          ---
root@solaris:~# ipadm create-addr -T static -a 10.163.198.20/24 net0/acme #网络接口为net0,描述是acme
root@solaris:~# ipadm show-if
IFNAME      CLASS     STATE      ACTIVE      OVER
lo0         loopback  ok         yes         ---
net0        ip        ok         yes         ---
root@solaris:~# ipadm show-addr
ADDROBJ     TYPE      STATIC     ADDR
lo0/v4      static    ok         127.0.0.1/8
net0/acme   static    ok         10.163.198.20/24
lo0/v6      static    ok         ::1/128

添加一个默认路由

root@solaris:~# route -p add default 10.163.198.1
add net default: gateway 10.163.198.1
add persistent net default: gateway 10.163.198.1

使用SMF配置解析服务

The name service configuration is now stored and configured via SMF services instead of via configuration files in /etc. This change is part of a wider set of configuration changes in Oracle Solaris 11, which provides a greater degree of administrative auditability and control over system configuration, particularly during system updates.

The SMF service svc:/network/dns/client manages configuration information that used to be in /etc/resolv.conf. The SMF service svc:/system/name-service/switch manages configuration information that used to be in /etc/nsswitch.conf. In both cases, the configuration information is also stored in the legacy files for compatibility with other applications that might read them. You should not directly edit these legacy files. Changes made to properties are not reflected in the legacy files until the service is refreshed, restarted, or enabled.

Note: Specifying lists and strings as SMF properties requires quoting them or escaping parentheses and quotation marks to prevent the shell from interpreting them.

使用SMF配置DNS

在下面的例子中,我们使用了svccfg命令配置了DNS(svc:/network/dns/clientSMF 服务),反过来,我们也可以查看DNS的IP地址或者域名。

root@solaris:~# svccfg -s svc:/network/dns/client setprop \
config/search='("uk.acme.com" "us.acme.com" "acme.com")'

root@solaris:~# svccfg -s svc:/network/dns/client listprop config/search
config/search astring	"uk.acme.com" "us.acme.com" "acme.com"

root@solaris:~# svccfg -s svc:/network/dns/client setprop \
config/nameserver=net_address: '(10.167.162.20 10.167.162.36)'

root@solaris:~# svccfg -s svc:/network/dns/client listprop config/nameserver
config/nameserver net_address 10.167.162.20 10.167.162.36 

在更改配置后,需要刷新服务。

root@solaris:~# svcadm refresh svc:/network/dns/client 

It is not necessary to set the properties for every name service database. You can use the special property config/default to provide a default value. You can individually customize entries that can't use the default value.

使用SMF配置/etc/switch.conf

In the following example, we use the name service switch mechanism to allow our system to search through the DNS, LDAP, NIS, or local file sources for naming information. We again use the svccfg command on the svc:/system/name-service/switch SMF service:

root@solaris:~# svccfg -s svc:/system/name-service/switch setprop config/default = "files nis" 
root@solaris:~# svccfg -s svc:/system/name-service/switch setprop config/host = "files dns nis" 
root@solaris:~# svccfg -s svc:/system/name-service/switch setprop config/password  = "files nis" 
root@solaris:~# svcadm refresh svc:/system/name-service/switch 
或者:
 
root@solaris:~# svccfg
svc:> select name-service/switch
svc:/system/name-service/switch> setprop config/host="files dns nis"
svc:/system/name-service/switch> setprop config/default="files nis"
svc:/system/name-service/switch> setprop  config/password  = "files nis"
svc:/system/name-service/switch> refresh
svc:/system/name-service/switch> exit


Note: The config/host property defines both the hosts and ipnodes entries in /etc/nsswitch.conf, while the config/passwordproperty defines the passwd entry. The remaining properties have the same name as their /etc/nsswitch.conf entries.

Setting the Host Name

In Oracle Solaris 11, /etc/nodename has been removed and replaced with the config/nodename property of thesvc:/system/identity:node service.

To set the host name, we again use svccfg:

root@solaris:~# svccfg -s svc:/system/identity:node setprop config/nodename = astring: hostname
root@solaris:~# svcadm refresh svc:/system/identity:node
root@solaris:~# svcadm restart identity:node

Setting the host name this way will work for both automatic and manual network configurations.

/etc/hosts

In Oracle Solaris 11, the host's own entry in /etc/hosts is now the same as that of localhost. In previous versions of Oracle Solaris, this entry was associated with the first network interface.

root@solaris:~# cat /etc/hosts
#
# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# Internet host table
#
::1 solaris localhost 
127.0.0.1 solaris localhost loghost 

Note: Some application installers might fail due to changes in the /etc/hosts file. If you experience this, you might have to edit/etc/hosts directly.

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值