solaris11网络相关配置

2019-01-26  本文已影响0人  mo371

By 2018-12-27

1、首先的确定solaris的NCP是否为手动配置模式
Automatic       自动
DefaultFixed    手动
root@sol-11:~# netadm list
TYPE        PROFILE        STATE
ncp         Automatic      disabled
ncp         DefaultFixed   online
loc         Automatic      offline
loc         NoNet          offline
loc         DefaultFixed   online
2、NCP从自动网络配置模式转换为手动配置模式
root@sol-11:~# netadm enable -p ncp DefaultFixed
3、如果出现下列情况,说明已经是手动状态
root@sol-11:~# netadm: DefaultFixed NCP is enabled; 
root@sol-11:~# automatic network management is not available. 
root@sol-11:~# netadm list' is only supported when automatic network management is active.
4、确认要配置的接口
root@sol-11:~# dladm show-phys 
LINK              MEDIA                STATE      SPEED  DUPLEX    DEVICE
net0              Ethernet             up         1000   full      e1000g0
5、创建net0,配置net0的IP v4地址,查看地址是否生效
root@sol-11:~# ipadm create-ip net0
root@sol-11:~# ipadm create-addr -T static -a 192.168.1.100/24 net0/v4
root@sol-11:~# ipadm show-addr
ADDROBJ           TYPE     STATE        ADDR
lo0/v4            static   ok           127.0.0.1/8
net0/v4           static   ok           192.168.1.100/24
lo0/v6            static   ok           ::1/128
删除ip地址
root@sol-11:~# ipadm delte-addr net0/v4
6、配置,并查看网关
root@sol-11:~# route -p add default 192.168.1.1
root@sol-11:~# netstat -rn
Routing Table: IPv4
  Destination           Gateway           Flags  Ref     Use     Interface
-------------------- -------------------- ----- ----- ---------- ---------
default              192.168.1.1          UG        2       1474          
127.0.0.1            127.0.0.1            UH        2         40 lo0      
192.168.0.0          192.168.1.100         U         5       1815 net0     
Routing Table: IPv6
  Destination/Mask            Gateway                   Flags Ref   Use    If  
--------------------------- --------------------------- ----- --- ------- -----
::1                         ::1                         UH      2       4 lo0
7、配置DNS
root@sol-11:~# 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@sol-11:~# svcadm refresh dns/client
root@sol-11:~# svcadm restart dns/client
检查
root@sol-11:~# more /etc/resolv.conf
#
# _AUTOGENERATED_FROM_SMF_V1_
#
# WARNING: THIS FILE GENERATED FROM SMF DATA.
#   DO NOT EDIT THIS FILE.  EDITS WILL BE LOST.
# See resolv.conf(4) for details.
nameserver      8.8.8.8
nameserver      8.8.4.4
如果不存在resolv.conf文件,则:
#svcs dns/client
如果出现disabled       Jul_11   svc:/network/dns/client:default
执行#svcadm enable dns/client 开启这个功能 
若出现如下错误:
svc:/network/dns/client> setprop config/nameserver = (8.8.8.8  8.8.4.4)
Multiple string values or string values with spaces must be quoted with '"'. 
使用该方式进行更改:
setprop config/nameserver=net_address: 8.8.8.8
setprop config/nameserver = (8.8.8.8  8.8.4.4)
删除search localdomain:
svc:/network/dns/client> delprop config/search
8、配置name-server
root@sol-11:~# 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
root@sol-11:~# svcadm refresh name-service/switch
root@sol-11:~# svcadm restart name-service/switch
9、最关键一步验证
root@sol-11:~# ping www.baidu.com
www.baidu.com is alive
10、配置好了net0,下面是如何修改及删除IP配置:
a.)如果要删除net0 IP v4地址,添加新地址
root@sol-11:~# ipadm delete-addr net0/v4
root@sol-11:~# ipadm create-addr -T static -a 192.168.1.200/24 net0/v4

b.) 如果要删除网关
root@sol-11:~# route delete default 192.168.1.1

c.)如果要删除net0网卡
root@sol-11:~# ipadm delete-ip net0

附加:

查看网关、链路、ip地址

root@sol11:~# route -p show
persistent: route add default  x.x.x.x
persistent: route add default  x.x.x.x
persistent: route add -inet6 default  x.x.x.x
persistent: route add -inet6 default  x.x.x.x

查看链路状态:
root@sol11:~# dladm show-link
LINK                CLASS     MTU    STATE    OVER
net0                phys      1500   up       --
net3                phys      1500   up       --
zone1/net3          phys      1500   up       --
net1                phys      1500   up       --
net2                phys      1500   up       --
zone1/net2          phys      1500   up       --
zone1/net0          vnic      1500   up       net0
root@lz-cache5:~# ipadm show-addr
ADDROBJ           TYPE     STATE        ADDR
lo0/v4            static   ok           127.0.0.1/8
lo0/v4a           static   ok           x.x.x.x/32
net0/v4           static   ok           x.x.x.x/30
net1/v4           static   ok           x.x.x.x/30
lo0/v6            static   ok           ::1/128
lo0/v6a           static   ok          x.x.x.x/128
net0/v6           addrconf ok          fe80::525d:acff:fe05:d17c/10
net0/v6add        static   ok          x.x.x.x/127
net1/v6           addrconf ok          fe80::525d:acff:fe05:d17d/10
net1/v6add        static   ok          x.x.x.x/127
查看端口速率:
# dladm show-phys
LINK              MEDIA                STATE      SPEED  DUPLEX    DEVICE
net2              Ethernet             up         1000   full      bge0
net5              Ethernet             unknown    0      unknown   bge5
net1              Ethernet             unknown    0      unknown   bge3
net4              Ethernet             unknown    0      unknown   bge4
net3              Ethernet             up         1000   full      bge1
net0              Ethernet             unknown    0      unknown   bge2
上一篇下一篇

猜你喜欢

热点阅读