• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • Solaris 8網絡管理筆記

    發表于:2007-07-04來源:作者:點擊數: 標簽:
    Solaris 8 網絡 管理筆記 一、如何創建自己的啟動腳本 現在創建一個簡單的 服務器 進程啟動腳本。假設該進程的可執行文件為/sbin/sample_server,該進程將在運行水平3上啟動,運行水平2上關閉。 1 在/etc/init.d目錄下創建一個啟動腳本.將該腳本保存為文件/et
    Solaris 8網絡管理筆記

    一、如何創建自己的啟動腳本

     現在創建一個簡單的服務器進程啟動腳本。假設該進程的可執行文件為/sbin/sample_server,該進程將在運行水平3上啟動,運行水平2上關閉。
     1 在/etc/init.d目錄下創建一個啟動腳本.將該腳本保存為文件/etc/init.d/my_server.
    這個腳本如下所示:

    #!/sbin/sh
    case "" in
    'start')
         if [ -f /sbin/sample_server ]; then
            /sbin/sample_server
         fi
         ;;

    'stop')
         /usr/bin/pkill -x -u 0 sample_server
         ;;

    *)
         echo "Usage: { start | stop }"
         exit 1
         ;;
    esac
    exit 0
    ~
    ~
    ~
    ~
    ~
     2  使用命令將腳本鏈接至啟動和關閉目錄

    bash-2.03#ln -s /etc/init.d/sample_server /etc/rc3.d/S900my_server
    bash-2.03#ln -s /etc/init.d/sample_server /etc/rc2.d/K900my_server
    bash-2.03#netstat -a          這個命令會列出當前運行著的所有服務列表.顯示的是端口和套接字               的監聽狀態。

    二、DHCP 服務
     不知道有沒有人在Solaris中使用SUN的DHCP服務器,反正我是沒用過,呵呵,自己也只是隨便用用
     1 常用的DHCP配置實用程序
     dhtadm                                        DHCP配置表管理程序
     dhcpconfig                                    DHCP服務配置程序
     dhcpmgr(/usr/sadm/admin/bin/dhcpmgr)          圖形化的DHCP管理器
     dntadm                                        DHCP網絡表管理程序
     2 對于圖形化的服務配置方法,只要按提示配置即可,多數情況下是按回車

    bash-2.03# /usr/sadm/admin/bin/dhcpmgr     (配置界面會自動啟動)

     3 Solaris中傳統的DHCP配置實用程序是dhcpconfig,配置和解除服務都是用它,圖形程序在后臺也是使用的它。注意,如果對于提問不輸入任何的內容,多數將采用默認值,每個問題對應的默認值在方括號中。

    bash-2.03# dhcpconfig
    ***             DHCP Configuration              ***


    Would you like to:

           1) Configure DHCP Service

           2) Configure BOOTP Relay Agent

           3) Unconfigure DHCP or Relay Service

           4) Exit



    Choice: 1          # 1配置,3是解除

    ###     DHCP Service Configuration      ###
    ###     Configure DHCP data store and location  ###

    Enter data store (SUNWbinfiles, SUNWfiles or SUNWnisplus) [SUNWnisplus]: SUNWfiles  #選擇數據存儲,文本
    Enter full path to data location [/var/dhcp]:                                       # 數據存儲的路徑,可修改
    Enter location for hosts data (none, files, dns, or nisplus) [none]: files    # 數據存儲模式,如果不使用NIS+,選擇文本
    Enter default DHCP lease policy (in days) [3]:                                # IP更新策略,每一天一更新
    Do you want to allow clients to renegotiate their leases? ([Y]/N):y           # 同意客戶端更新IP地址
    Created DHCP configuration file.
    Created dhcptab.
    Added "Locale" macro to dhcptab.
    Added server macro to dhcptab - txd01.
    DHCP server started.

    ###     Common daemon option setup      ###

    Would you like to specify nondefault daemon options (Y/[N]):n        # DHCP的后臺程序指定,比如SYSLOG

    ###     DHCP server option setup        ###

    Would you like to specify nondefault server options (Y/[N]): n       # 設置DHCP的不同選項,為簡便,選 N

    ###     Select Networks For BOOTP/DHCP Support  ###

    Enable DHCP/BOOTP support of networks you select? ([Y]/N):y          # 同意啟用網絡上DHCP支持

    ###     Configure Local Networks        ###

    Configure BOOTP/DHCP on local LAN network: 192.168.0.0? ([Y]/N):y    # 本地網絡
    Do you want hostnames generated and inserted in the SUNWfiles hosts table? (Y/[N]):n
    Enter starting IP address [192.168.0.0]: 192.168.0.100               # IP地址池的初始IP
    Enter the number of clients you want to add (x < 255): 10            # IP地址池的IP數量
    Disable (ping) verification of 192.168.0.0 address(es)? (Y/[N]):n    # 不要關閉ping驗證
    \ 90% Complete.
    Configured 10 entries for network: 192.168.0.0.

    ###     Configure Remote Networks       ###

    Would you like to configure BOOTP/DHCP service on remote networks? ([Y]/N):

    三、常見的以太網故障解決方法命令
     1 ifconfig
    基本上會用solaris的人,就應該會用這個命令了,它可以列出系統安裝的所有的網絡接口的詳細信息.

    bash-2.03# ifconfig -a
    lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
           inet 127.0.0.1 netmask ff000000
    hme0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
           inet 192.168.0.188 netmask ffffff00 broadcast 192.168.0.255
           ether 8:0:20:a7:91:ce
    這個命令也可以用來創建和配置系統要安裝的網絡接口,后面我會有詳細的例子.
     2  netstat
    該命令有多種用途,例如顯示路由表、可用的服務端口以及目前建立的連接等。

    bash-2.03# netstat

    TCP: IPv4
      Local Address        Remote Address    Swind Send-Q Rwind Recv-Q  State
    -------------------- -------------------- ----- ------ ----- ------ -------
    u10.32783            192.168.0.118.6000   65219      0 24820      0 ESTABLISHED
    u10.32797            192.168.0.118.6000   65391      0 24820      0 ESTABLISHED
    u10.32798            192.168.0.118.6000   65291      0 24820      0 ESTABLISHED
    localhost.32904      localhost.32875      32768      0 32768      0 ESTABLISHED
    localhost.32875      localhost.32904      32768      0 32768      0 ESTABLISHED
    .....................................
    Active UNIX domain sockets
    Address  Type          Vnode     Conn  Local Addr      Remote Addr
    30000e57b08 stream-ord 300000731a8 00000000 /tmp/.X11-unix/X0                
    30000e57cb8 stream-ord 00000000 00000000                              


    在如下使用時,列出IPV4和IPV6地址、輸入和輸出數據包、錯誤數以及所有網絡接口的沖突次數。

    bash-2.03# netstat -i
    Name  Mtu  Net/Dest      Address        Ipkts  Ierrs Opkts  Oerrs Collis Queue
    lo0   8232 loopback      localhost      14681  0     14681  0     0      0    
    hme0  1500 u10           u10            83538  0     85852  0     0      0    

     3 snoop
    用來捕獲和顯示網絡流量。它可能是數據包級解決網絡問題最有用的命令。

    bash-2.03# snoop
    Using device /dev/hme (promiscuous mode)
            u10 -> 192.168.0.12 XWIN C port=32899
    192.168.0.12 -> u10          XWIN R port=32899
            u10 -> 192.168.0.12 XWIN C port=32899
    192.168.0.12 -> u10          XWIN R port=32899
            u10 -> 192.168.0.12 XWIN C port=32899
    192.168.0.12 -> u10          XWIN R port=32899
    192.168.0.12 -> u10          XWIN R port=32899
            u10 -> 192.168.0.12 XWIN C port=32899

    該命令持續顯示捕獲的數據包,直到按下Ctrl+C中斷該進程。該命令的輸出顯示了源和目的主機的主機名或IP地址,還顯示了數據包的類型、應用該數據包的服務和端口號。為了得到每個數據包的詳細信息,應如下使用snoop -v

    bash-2.03# snoop -v
    Using device /dev/hme (promiscuous mode)

    ETHER:  ----- Ether Header -----
    ETHER:  
    ETHER:  Packet 6 arrived at 15:35:1.27
    ETHER:  Packet size = 60 bytes
    ETHER:  Destination = 8:0:20:a7:91:ce, Sun
    ETHER:  Source      = 0:10:5c:ea:ef:6d,
    ETHER:  Ethertype = 0800 (IP)
    ETHER:  
    IP:   ----- IP Header -----
    IP:  
    IP:   Version = 4
    IP:   Header length = 20 bytes
    IP:   Type of service = 0x00
    IP:         xxx. .... = 0 (precedence)
    IP:         ...0 .... = normal delay
    IP:         .... 0... = normal throughput
    IP:         .... .0.. = normal reliability
    IP:   Total length = 40 bytes
    IP:   Identification = 36152
    IP:   Flags = 0x4
    IP:         .1.. .... = do not fragment
    IP:         ..0. .... = last fragment
    IP:   Fragment offset = 0 bytes
    IP:   Time to live = 128 seconds/hops
    IP:   Protocol = 6 (TCP)
    IP:   Header checksum = eb7e
    IP:   Source address = 192.168.0.12, 192.168.0.12
    IP:   Destination address = 192.168.0.188, u10
    IP:   No options
    IP:  
    TCP:  ----- TCP Header -----
    TCP:  
    TCP:  Source port = 6000
    TCP:  Destination port = 32899

    為了以文本格式保存的輸出,應使用重定向方法,而不是-0或-i參數.可用cat more查看.

    bash-2.03# snoop -v > snoop.txt
    Using device /dev/hme (promiscuous mode)

    4  ndd
    該命令用于顯示網絡驅動的信息。

    bash-2.03# ndd /dev/hme \?
    ?                             (read only)
    transceiver_inuse             (read only)
    link_status                   (read only)
    link_speed                    (read only)
    link_mode                     (read only)
    ipg1                          (read and write)
    ipg2                          (read and write)
    use_int_xcvr                  (read and write)
    pace_size                     (read and write)
    adv_autoneg_cap               (read and write)
    adv_100T4_cap                 (read and write)
    adv_100fdx_cap                (read and write)
    ......................................
    bash-2.03# ndd /dev/udp \?
    ?                             (read only)
    udp_wroff_extra               (read and write)
    udp_ipv4_ttl                  (read and write)
    udp_ipv6_hoplimit             (read and write)
    udp_smallest_nonpriv_port     (read and write)
    udp_do_checksum               (read and write)
    udp_smallest_anon_port        (read and write)
    udp_largest_anon_port         (read and write)
    udp_xmit_hiwat                (read and write)
    ....................................................
    后面的值(read and write)表示可修改,(read only)表示只讀不可修改。例如:

    bash-2.03# ndd /dev/udp udp_ipv4_ttl
    255
    表示UDP包的生存期是255,可修改用-set參數。

    bash-2.03# ndd -set /dev/udp udp_ipv4_ttl 50
    bash-2.03# ndd /dev/udp udp_ipv4_ttl
    50

     5 ping traceroute 這兩個命令就不用說了,地球人都知道。但還有一些常用的用法,可供參考.
    ping
    1)連續ping    

    bash-2.03# ping -s 192.168.0.1  
    PING 192.168.0.1: 56 data bytes
    64 bytes from 192.168.0.1: icmp_seq=0. time=1. ms
    64 bytes from 192.168.0.1: icmp_seq=1. time=0. ms
    64 bytes from 192.168.0.1: icmp_seq=2. time=0. ms
    64 bytes from 192.168.0.1: icmp_seq=3. time=0. ms
    64 bytes from 192.168.0.1: icmp_seq=4. time=0. ms
    64 bytes from 192.168.0.1: icmp_seq=5. time=0. ms
    ^C
    ----192.168.0.1 PING Statistics----
    6 packets transmitted, 6 packets received, 0% packet loss
    round-trip (ms)  min/avg/max = 0/0/1

    2)在ping命令中使用不同的確包長度    默認采用的是56+8字節長的數據包,然而為了檢測網絡對長數據包的響應情況可以在命令中指定包的長度.這對于掌握主機是否因為IP分片的原因而丟棄數據包非常有用.各位可試一下,我沒有在實際中用過.試驗的機子也是舊機型,不能超過1500.1400就可以,呵呵!

    bash-2.03# ping -s 192.168.0.1 1500
    PING 192.168.0.1: 1500 data bytes
    ^C
    ----192.168.0.1 PING Statistics----
    6 packets transmitted, 0 packets received, 100% packet loss
    bash-2.03# ping -s 192.168.0.1 1400
    PING 192.168.0.1: 1400 data bytes
    1408 bytes from 192.168.0.1: icmp_seq=0. time=2. ms
    1408 bytes from 192.168.0.1: icmp_seq=1. time=1. ms
    1408 bytes from 192.168.0.1: icmp_seq=2. time=1. ms
    ^C
    ----192.168.0.1 PING Statistics----
    3 packets transmitted, 3 packets received, 0% packet loss
    round-trip (ms)  min/avg/max = 1/1/2
    大家可以注意到長數據包的響應時間增加了.

    3)發送固定數量的ping包         比如發送三個

    bash-2.03# ping -s 192.168.0.1 1400 3
    PING 192.168.0.1: 1400 data bytes
    1408 bytes from 192.168.0.1: icmp_seq=0. time=1. ms
    1408 bytes from 192.168.0.1: icmp_seq=1. time=1. ms
    1408 bytes from 192.168.0.1: icmp_seq=2. time=1. ms

    ----192.168.0.1 PING Statistics----
    3 packets transmitted, 3 packets received, 0% packet loss
    round-trip (ms)  min/avg/max = 1/1/1

    6  arp 命令 增加一條記錄用-s,刪除用-d,pub關鍵字使得這些記錄對于所有的主機都是公開的.
    也可以手工增加多條記錄,使用一個文本文件記錄:
      <IP地址> <MAC地址> pub           再用命令 :
    arp -f <文件名>

    bash-2.03# arp -a

    Net to Media Table: IPv4
    Device   IP Address               Mask      Flags   Phys Addr
    ------ -------------------- --------------- ----- ---------------
    hme0   192.168.0.118        255.255.255.255       00:11:25:80:2f:d7
    hme0   192.168.0.12         255.255.255.255       00:10:5c:ea:ef:6d
    hme0   192.168.0.111        255.255.255.255       00:0d:61:97:04:08
    hme0   u10                  255.255.255.255 SP    08:00:20:a7:91:ce
    hme0   224.0.0.0            240.0.0.0       SM    01:00:5e:00:00:00
    bash-2.03# arp -s 192.168.0.13 11:11:11:11:11:11 pub
    bash-2.03# arp -a

    Net to Media Table: IPv4
    Device   IP Address               Mask      Flags   Phys Addr
    ------ -------------------- --------------- ----- ---------------
    hme0   192.168.0.118        255.255.255.255       00:11:25:80:2f:d7
    hme0   192.168.0.12         255.255.255.255       00:10:5c:ea:ef:6d
    hme0   192.168.0.111        255.255.255.255       00:0d:61:97:04:08
    hme0   192.168.0.13         255.255.255.255 SP    11:11:11:11:11:11
    hme0   u10                  255.255.255.255 SP    08:00:20:a7:91:ce
    hme0   224.0.0.0            240.0.0.0       SM    01:00:5e:00:00:00
    bash-2.03# arp -d 192.168.0.13
    192.168.0.13 (192.168.0.13) deleted
    bash-2.03# arp -a

    Net to Media Table: IPv4
    Device   IP Address               Mask      Flags   Phys Addr
    ------ -------------------- --------------- ----- ---------------
    hme0   192.168.0.118        255.255.255.255       00:11:25:80:2f:d7
    hme0   192.168.0.12         255.255.255.255       00:10:5c:ea:ef:6d
    hme0   192.168.0.111        255.255.255.255       00:0d:61:97:04:08
    hme0   u10                  255.255.255.255 SP    08:00:20:a7:91:ce
    hme0   224.0.0.0            240.0.0.0       SM    01:00:5e:00:00:00


    四、在Solaris中配置網絡接口

    1 配置實際網絡接口   Solaris中的網絡接口通常命名為hmen、erin、cen等,這里n是數字,單詞hme等表示一種綁定在網絡接口上的驅動類型(http://bbs.chinaunix.net/forum/viewtopic.php?t=503948&;highlight=jiangping上有更為詳細的說明)。數字n通常對于第一個接口是0,第二個是1,類推。如果給接口hme0配置IP為192.168.2.222,掩碼為255.255.255.0 如下:

      1)創建一個文件: /etc/hostname.hme0,只有一行內容,將主機名如下
     sun280
      2)編輯文件/etc/hosts,加入一行
     192.168.2.222    sun280
      3)編輯文件/etc/netmasks并增加如下一行
     192.168.2.222     255.255.255.0
    系統啟動時,網絡初始化腳本/etc/init.d/network將被執行,讀取這些文件并配置網絡接口.

     該配置是固化在系統中,也可以用命令ifconfig臨時更改網絡接口,重啟后無效.


    bash-2.03#ifconfig hme0 plumb
    bash-2.03#ifconfig hme0 192.168.2.222 netmask 255.255.255.0 up

    2 配置虛擬接口     如果在系統上安裝了一個hme0的網絡適配器,則可以使用類似hme0:n這樣的多個虛擬接口,這里的n大于等于1,hme0:1  hme0:2等.
      方法如下:
       創建一個文件/etc/hostname.hme0:1,記錄一行主機名
       sun280_1
       編輯/etc/hosts文件,增加
       192.168.1.111     sun280_1
       編輯文件/etc/netmasks文件,為這個新接口增加一行
       192.168.1.111     255.255.255.0
    再次重啟時,該接口就存在了.也可以手工配置:
    bash-2.03#ifconfig hme0:1 plumb
    bash-2.03#ifconfig hme0:1 192.168.1.111/24 up
    bash-2.03#ifconfig hme0:1
    配置完成后,可以使用ping命令來驗證接口是否得到響應.


    五、Solaris網絡中的路由配置

    1  靜態路由配置

    bash-2.03# netstat -rn

    Routing Table: IPv4
     Destination           Gateway           Flags  Ref   Use   Interface
    -------------------- -------------------- ----- ----- ------ ---------
    192.168.0.0          192.168.0.188         U        1      7  hme0
    224.0.0.0            192.168.0.188         U        1      0  hme0
    127.0.0.1            127.0.0.1             UH      24  20850  lo0
    ]bash-2.03# route add -net 192.168.0.0/24 192.168.0.1
    add net 192.168.0.0/24: gateway 192.168.0.1
    bash-2.03# netstat -rn

    Routing Table: IPv4
     Destination           Gateway           Flags  Ref   Use   Interface
    -------------------- -------------------- ----- ----- ------ ---------
    192.168.0.0          192.168.0.188         U        1      9  hme0
    192.168.0.0          192.168.0.1           UG       1      0  
    224.0.0.0            192.168.0.188         U        1      0  hme0
    127.0.0.1            127.0.0.1             UH      24  21100  lo0

     2  配置默認路由     創建/etc/defaultrouter文件,記錄下指定默認路由的IP地址即可.
     3  如果不想啟用路由功能,只要創建/etc/norouter文件即可.則IP轉發和動態路由都是關閉的.
     4  動態路由配置需要使用RIP和RDISC,本人在實際中應用極少.



    _________________
    佛曰:前世五百次的回眸才換來今生一次擦肩而過

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>