2014年11月17日 星期一

Solaris 11 ipfilter 防火牆


啟動客制policy: (指定ipf執行時參照的設定檔,如果沒有設定此部份,必須每次手動啟動設定擋
# svccfg -s ipfilter:default setprop firewall_config_default/policy = astring: "custom"
# svccfg -s ipfilter:default listprop firewall_config_default/policy
firewall_config_default/policy astring     custom
# svccfg -s ipfilter:default setprop firewall_config_default/custom_policy_file = astring: "/etc/ipf/ipf.conf"
# svccfg -s ipfilter:default listprop firewall_config_default/custom_policy_file
firewall_config_default/custom_policy_file astring /etc/ipf/ipf.conf
客制policy 檔案:
Run the firewall service:
# svcadm refresh ipfilter:default
# svcs -a | grep ipfilterdisabled Sep_20 svc:/network/ipfilter:default
# svcs -xv svc:/network/ipfilter:default
svc:/network/ipfilter:default (IP Filter)
 State: disabled since September 20, 2013 12:21:20 PM PDT
Reason: Disabled by an administrator.
 See: http://support.oracle.com/msg/SMF-8000-05
 See: man -M /usr/share/man -s 5 ipfilter
Impact: This service is not running.
# svcadm enable svc:/network/ipfilter:default
# svcs -xv svc:/network/ipfilter:default
svc:/network/ipfilter:default (IP Filter)
 State: online since September 23, 2013 05:46:51 AM PDT
 See: man -M /usr/share/man -s 5 ipfilter
 See: /var/svc/log/network-ipfilter:default.log
Impact: None.


啟動 IP Filter服務
# svcadm enable network/ipfilter


關閉封包過濾及允許所有的網路上的封包.
# ipf –D

啟動 IP Filter.
# ipf -E


Activate packet filtering.
# ipf -f filename

(Optional) Activate NAT.
# ipnat -f filename


可以由複製/etc/nwam/loc/NoNet/ipf.conf 範例
# cp /etc/nwam/loc/NoNet/ipf.conf /etc/ipf/ipf





移除kernel中啟動的rule.
# ipf -Fa
這個指令會將所有的封包過濾rule 停用.

移除流入封包過濾rule.
# ipf -Fi
這個指令會將所有流入的封包過濾rule 停用.

移除流出封包過濾
# ipf -Fo
        這個指令會將所有流出的封包過濾rule 停用.






Some Commonly used ipf commands
==================================

ipf -E                          : Enable ipfilter when running
                                : for the first time.
                                : (Needed for ipf on Tru64)

ipf -f /etc/ipf/ipf.conf        : Load rules in /etc/ipf/ipf.conf file
                                : into the active firewall.

ipf -Fa -f /etc/ipf/ipf.conf    : Flush all rules, then load rules in
                                : /etc/ipf/ipf.conf into active firwall.

ipf -Fi                         : Flush all input rules.

ipf -I -f /etc/ipf/ipf.conf     : Load rules in /etc/ipf/ipf.conf file
                                : into inactive firewall.

ipf -V                          : Show version info and active list.

ipf -s                          : Swap active and inactive firewalls.

ipfstat                         : Show summary

ipfstat -i                      : Show input list

ipfstat -o                      : Show output list

ipfstat -hio                    : Show hits against all rules

ipfstat -t -T 5                 : Monitor the state table and refresh every  
                                : 5 seconds. Output is similiar to      
                                : 'top' monitoring the process table.

Monitoring
=============


ipmon -s S                      : Watch state table.

ipmon -sn                       : Write logged entries to syslog, and
                                : convert back to hostnames and servicenames.

ipmon -s [file]                 : Write logged entries to some file.

ipmon -Ds                       : Run ipmon as a daemon, and log to
                                : default location. 
                                : (/var/adm/messages for Solaris , maybe.)
                                : (/var/log/syslog for Tru64)



參考文件:
http://blog.ls-al.com/solaris-ipfilter-pools/
http://blog.ls-al.com/solaris-11-firewall/











Solaris IP 設定

新增及移除IP 及 Interface

# ipadm create-addr  -T static -a local=192.168.1.2/24 net0/v4

# ipadm show-addr
ADDROBJ           TYPE     STATE        ADDR
lo0/v4            static   ok           127.0.0.1/8
net0/v4           static   ok           192.168.1.2/24     新增
net0/test1        static   ok           192.168.1.3/28
net0/test2        static   ok           192.168.2.3/28     準備移除
lo0/v6            static   ok           ::1/128
net0/v6           addrconf ok           fe80::a00:27ff:fe3f:2d92/10

# ipadm delete-addr net0/test2

# ipadm show-addr
ADDROBJ           TYPE     STATE        ADDR
lo0/v4            static   ok           127.0.0.1/8
net0/v4           static   ok           192.168.1.2/24
net0/test1        static   ok           192.168.1.3/28
net0/test2        static   ok           192.168.2.3/28      此時以經移除掉
lo0/v6            static   ok           ::1/128
net0/v6           addrconf ok           fe80::a00:27ff:fe3f:2d92/10


新增gateway

# route -p add default 192.168.1.128
add net default: gateway 192.168.1.128
add persistent net default: gateway 192.168.1.128

# netstat -nr    檢視routing table

Routing Table: IPv4
  Destination           Gateway           Flags  Ref     Use     Interface
-------------------- -------------------- ----- ----- ---------- ---------
default              192.168.1.128        UG        2          1                                     192.168.1.128為gateway
127.0.0.1            127.0.0.1            UH        2         32 lo0
192.168.1.0          192.168.1.3          U         3        336 net0
192.168.1.0          192.168.1.11         U         3          1 net0

Routing Table: IPv6
  Destination/Mask            Gateway                   Flags Ref   Use    If
--------------------------- --------------------------- ----- --- ------- -----
::1                         ::1                         UH      2       0 lo0
fe80::/10                   fe80::a00:27ff:fe3f:2d92    U       2       0 net0


變更gateway

# route -f add default 192.168.1.254
default              192.168.1.128        done
add net default: gateway 192.168.1.254

# netstat -nr

Routing Table: IPv4
  Destination           Gateway           Flags  Ref     Use     Interface
-------------------- -------------------- ----- ----- ---------- ---------
default              192.168.1.254        UG        2          1                     變更gateway為192.168.1.254
127.0.0.1            127.0.0.1            UH        2         32 lo0
192.168.1.0          192.168.1.3          U         3        364 net0
192.168.1.0          192.168.1.11         U         3          1 net0

Routing Table: IPv6
  Destination/Mask            Gateway                   Flags Ref   Use    If
--------------------------- --------------------------- ----- --- ------- -----
::1                         ::1                         UH      2       0 lo0
fe80::/10                   fe80::a00:27ff:fe3f:2d92    U       2       0 net0
root@ai-client:~#




2014年10月20日 星期一

Solaris 11 NFS 設定

啟動NFS服務

# svcadm enable network/nfs/server

關閉NFS服務

# svcadm disable network/nfs/server

開啟automounter

# svcadm enable system/filesystem/autofs


檢查伺服器是否啟動NFS 服務

# svcs network/nfs/server


# svcs network/nfs/server
STATE          STIME    FMRI
disabled       18:03:46 svc:/network/nfs/server:default    目前狀態是關閉的


指令列mount 一個NFS
# mount -F nfs -o ro kitty:/export/home /mnt

Server端分享/export/home目錄給client,並僅有ro的權限
# share -F nfs -o ro=client  /export/home 

檢視目錄分享狀態
#cat /etc/dfs/sharetab
/export/home    export_home     nfs     sec=sys,ro=client


在Client端的vfstab加入一行,讓開機時自動mount起來
svcadm enable  network/nfs/client
server:/export/home     -       /mnt    nfs     0       yes      ro




======================================================================
關於Client Mount 沒有R/W權限

In fact, in this case root would be restricted - not by the target directories permissions but due to would be restricted, as share does not have "anon=0" or "root=<access list>" options - therefore the client's root user is "nobody" to the NFS server.

Server:
root@solaris:~# share -F nfs -o anon=0 /zpool/fs1
root@solaris:~# share
zpool_fs1       /zpool/fs1      nfs     anon=0,sec=sys,rw
root@solaris:~#

Client:
root@S11-ai-installed:/# mount -F nfs 192.168.1.222:/zpool/fs1 /a
可以成功寫入的

================= 分隔線 ===================================
限制由特定Client登入

Server
root@solaris:~# share -F nfs -o anon=0:root=192.168.1.110 /zpool/fs1
root@solaris:~# showmount -e
export list for solaris:
/zpool/fs1 (everyone)









啟動 Solaris 10 VNC Server


  • 檢查VNC 服務

# svcs -a | grep -i vnc
disabled       Sep_19   svc:/application/x11/xvnc-inetd:default
  • 啟動VNC 服務
# svcadm enable svc:/application/x11/xvnc-inetd:default


  • 預設VNC服務是不開啟的,修改一些設定
# svcs svc:/application/x11/xvnc-inetd:default
STATE          STIME    FMRI
maintenance     9:27:11 svc:/application/x11/xvnc-inetd:default

  • 在/etc/services 加入一行
vnc-server         5900/tcp          # Xvnc

  • 設定和啟動gnu 顯示管理給 VNC
# cat >/etc/X11/gdm/custom.conf <<!
   [xdmcp]
   Enable=true
   [security]
   DisallowTCP=false
   AllowRoot=true
   AllowRemoteRoot=true
   !

  • 重新啟動和驗證 VNC Server
 # svcadm disable svc:/application/x11/xvnc-inetd:default 
 # svcadm enable svc:/application/x11/xvnc-inetd:default
 # svcs svc:/application/x11/xvnc-inetd:default 
  
   STATE STIME FMRI
online 14:46:43 svc:/application/x11/xvnc-inetd:default
  • 完成,使用Client軟體測試

2014年9月9日 星期二

Solaris 11 設定IP由DCHP到固定IP

步驟一:檢查NCP

此時系統使用DHCP所以DefaultFixed為 Disabled












步驟二:設定NCP

# netadm enable -p ncp DefaultFixed





步驟三:檢查連結狀態

# dladm show-phys
 步驟四:建立一個新的interface

# ipadm create-ip net0




步驟五:檢查新建立的interface





設定IP
 # ipadm create-addr –T static –a local=192.168.1.222/24 net0

檢查interface的狀態
# ipadm show-if


# ipadm show-addr








如果要Unplumb 或是 Delete interface
# ipadm delete-ip net0