netadm 配置文件切换
Oracle Solaris 11 OS 包括以下 NCP:
DefaultFixed。允许您使用 dladm 或 ipadm 命令管理网络。
Automatic。允许您使用 netcfg 或 netadm 命令管理网络。
root@solaris:~# netadm enable -p ncp DefaultFixed
root@solaris:~# netadm enable -p ncp Automatic
用netcfg命令创建的配置文件用
root@solaris:~# netcfg
netcfg> create ncp cai #创建一个ncp 叫cai
netcfg:ncp:cai> create ncu phys net2 #创建ncu 对应link net2
Created ncu 'net2'. Walking properties ...
activation-mode (manual) [manual|prioritized]> #没有输入为默认
mac-address>
autopush>
mtu>
netcfg:ncp:cai:ncu:net2> list #查看内容
ncu:net2
type link
class phys
parent "cai"
activation-mode manual
enabled true
netcfg:ncp:cai:ncu:net2> end #保存推出
Committed changes
netcfg:ncp:cai> create ncu ip net2 #创建ncu ip接口
Created ncu 'net2'. Walking properties ...
ip-version (ipv4,ipv6) [ipv4|ipv6]> ipv4 #ip版本这儿选IPv4
ipv4-addrsrc [dhcp|static]> static #配置类型为静态
ipv4-addr> 188.188.3.248/22 #ip地址
ipv4-default-route> 188.188.1.1 #网关
netcfg:ncp:cai:ncu:net2> list #查看网络参数
ncu:net2
type interface
class ip
parent "cai"
enabled true
ip-version ipv4
ipv4-addrsrc static
ipv4-addr "188.188.3.248/22"
ipv4-default-route "188.188.1.1"
netcfg:ncp:cai:ncu:net2> end #保存推出
Committed changes
netcfg:ncp:cai> end #保存推出
netcfg> end
root@solaris:~# netadm list #查看新创建的配置cai
TYPE PROFILE STATE
ncp Automatic disabled
ncp DefaultFixed online
ncp cai disabled #here
loc Automatic offline
loc NoNet offline
loc DefaultFixed online
启用用户创建的配置文件
root@solaris:~# netadm enable cai
用netcfg配置dns
root@solaris:~# svccfg -s dns/client
svc:/network/dns/client> setprop config/nameserver = (8.8.8.8 8.8.4.4)
svc:/network/dns/client> listprop config
config application
config/value_authorization astring solaris.smf.value.name-service.dns.client
config/nameserver net_address 8.8.8.8 8.8.4.4
svc:/network/dns/client> exit
root@solaris:~#
root@solaris:~# svcadm refresh dns/client
root@solaris:~# svcadm restart dns/client
root@solaris:~# svccfg -s name-service/switch
svc:/system/name-service/switch> setprop config/host = "files dns"
svc:/system/name-service/switch> listprop config
config application
config/default astring files
config/value_authorization astring solaris.smf.value.name-service.switch
config/printer astring "user files"
config/host astring "files dns"
svc:/system/name-service/switch> exit
删除用netcfg创建的用户自定义配置文件
root@solaris:~# netadm list
TYPE PROFILE STATE
ncp Automatic disabled
ncp DefaultFixed online
loc Automatic offline
loc NoNet offline
loc DefaultFixed online
loc test.loc offline
loc acme.test.ncp offline
root@solaris:~# netcfg #进入config模式
netcfg> help destroy
usage: destroy {-a | <object-type> [<class>] <object-name>}
Destroys the specified profile or resource.
netcfg> destroy -a #清除所有用户自定义配置
ncp 'Automatic' cannot be removed
ncp 'DefaultFixed' cannot be removed
loc 'Automatic' cannot be removed
loc 'NoNet' cannot be removed
loc 'DefaultFixed' cannot be removed
All user-defined entities destroyed
netcfg> end #保存退出
root@solaris:~# netadm list
TYPE PROFILE STATE
ncp Automatic disabled
ncp DefaultFixed online
loc Automatic offline
loc NoNet offline
Oracle Solaris 11 OS 包括以下 NCP:
DefaultFixed。允许您使用 dladm 或 ipadm 命令管理网络。
Automatic。允许您使用 netcfg 或 netadm 命令管理网络。
root@solaris:~# netadm enable -p ncp DefaultFixed
root@solaris:~# netadm enable -p ncp Automatic
用netcfg命令创建的配置文件用
root@solaris:~# netcfg
netcfg> create ncp cai #创建一个ncp 叫cai
netcfg:ncp:cai> create ncu phys net2 #创建ncu 对应link net2
Created ncu 'net2'. Walking properties ...
activation-mode (manual) [manual|prioritized]> #没有输入为默认
mac-address>
autopush>
mtu>
netcfg:ncp:cai:ncu:net2> list #查看内容
ncu:net2
type link
class phys
parent "cai"
activation-mode manual
enabled true
netcfg:ncp:cai:ncu:net2> end #保存推出
Committed changes
netcfg:ncp:cai> create ncu ip net2 #创建ncu ip接口
Created ncu 'net2'. Walking properties ...
ip-version (ipv4,ipv6) [ipv4|ipv6]> ipv4 #ip版本这儿选IPv4
ipv4-addrsrc [dhcp|static]> static #配置类型为静态
ipv4-addr> 188.188.3.248/22 #ip地址
ipv4-default-route> 188.188.1.1 #网关
netcfg:ncp:cai:ncu:net2> list #查看网络参数
ncu:net2
type interface
class ip
parent "cai"
enabled true
ip-version ipv4
ipv4-addrsrc static
ipv4-addr "188.188.3.248/22"
ipv4-default-route "188.188.1.1"
netcfg:ncp:cai:ncu:net2> end #保存推出
Committed changes
netcfg:ncp:cai> end #保存推出
netcfg> end
root@solaris:~# netadm list #查看新创建的配置cai
TYPE PROFILE STATE
ncp Automatic disabled
ncp DefaultFixed online
ncp cai disabled #here
loc Automatic offline
loc NoNet offline
loc DefaultFixed online
启用用户创建的配置文件
root@solaris:~# netadm enable cai
用netcfg配置dns
root@solaris:~# svccfg -s dns/client
svc:/network/dns/client> setprop config/nameserver = (8.8.8.8 8.8.4.4)
svc:/network/dns/client> listprop config
config application
config/value_authorization astring solaris.smf.value.name-service.dns.client
config/nameserver net_address 8.8.8.8 8.8.4.4
svc:/network/dns/client> exit
root@solaris:~#
root@solaris:~# svcadm refresh dns/client
root@solaris:~# svcadm restart dns/client
root@solaris:~# svccfg -s name-service/switch
svc:/system/name-service/switch> setprop config/host = "files dns"
svc:/system/name-service/switch> listprop config
config application
config/default astring files
config/value_authorization astring solaris.smf.value.name-service.switch
config/printer astring "user files"
config/host astring "files dns"
svc:/system/name-service/switch> exit
删除用netcfg创建的用户自定义配置文件
root@solaris:~# netadm list
TYPE PROFILE STATE
ncp Automatic disabled
ncp DefaultFixed online
loc Automatic offline
loc NoNet offline
loc DefaultFixed online
loc test.loc offline
loc acme.test.ncp offline
root@solaris:~# netcfg #进入config模式
netcfg> help destroy
usage: destroy {-a | <object-type> [<class>] <object-name>}
Destroys the specified profile or resource.
netcfg> destroy -a #清除所有用户自定义配置
ncp 'Automatic' cannot be removed
ncp 'DefaultFixed' cannot be removed
loc 'Automatic' cannot be removed
loc 'NoNet' cannot be removed
loc 'DefaultFixed' cannot be removed
All user-defined entities destroyed
netcfg> end #保存退出
root@solaris:~# netadm list
TYPE PROFILE STATE
ncp Automatic disabled
ncp DefaultFixed online
loc Automatic offline
loc NoNet offline
loc DefaultFixed online
本问由笔者参考oracle文档实验步骤所写原创
作者:john
转载请注明出处!