• VMware

    Learn about VMware virtualization for its products like vsphere ESX and ESXi, vCenter Server, VMware View, VMware P2V and many more

  • Linux

    Step by step configuration tutorials for many of the Linux services like DNS, DHCP, FTP, Samba4 etc including many tips and tricks in Red Hat Linux.

  • Database

    Learn installation and configuration of databases like Oracle, My SQL, Postgresql, etc including many other related tutorials in Linux.

  • Life always offers you a second chance ... Its called tomorrow !!!

    Sunday, September 25, 2016

    How to monitor network bandwidth in Linux using netperf

    We have many tools available online which can help us monitor network bandwidth usage within a network between differnt Linux machines.

    In this article I will show how netperf can be used to monitor network performance between two Linux machines

    Brief information on my setup:

    Server

    My server IP is 192.169.32.15 where I have 2 bond interfaces as below
    # ifconfig bond0
    bond0     Link encap:Ethernet  HWaddr 00:17:A4:77:00:38
              inet addr:
    192.169.32.15  Bcast:192.169.32.31  Mask:255.255.255.224
              UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
              RX packets:9042150 errors:0 dropped:4553 overruns:0 frame:0
              TX packets:2277574 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0
              RX bytes:13654658052 (13022.0 Mb)  TX bytes:153728769 (146.6 Mb)

    # ifconfig bond1
    bond1     Link encap:Ethernet  HWaddr 38:63:BB:2F:E5:A9
              inet addr:192.169.32.37  Bcast:192.169.32.63  Mask:255.255.255.224
              UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
              RX packets:28334533 errors:0 dropped:2 overruns:0 frame:0
              TX packets:2066047 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0
              RX bytes:42898423316 (40911.1 Mb)  TX bytes:136362958 (130.0 Mb)


    The ethernet speed assigned to both interfaces eth0 and eth1 under bond0 is 1 GB
    # ethtool eth0 | grep -i Speed
            Speed: 1000Mb/s

    # ethtool eth1 | grep -i Speed
            Speed: 1000Mb/s

    so if we use bond0 for our network operations then ethernet bandwidth must not exceed 1 GB

    The ethernet speed assigned to both interfaces eth2 and eth3 under bond1 is 3 GB
    # ethtool eth0 | grep -i Speed
            Speed: 3000Mb/s

    # ethtool eth1 | grep -i Speed
            Speed: 3000Mb/s

    so if we use bond1 for our network operations then ethernet bandwidth must not exceed 3 GB

    Client

    My clinet node is 192.169.32.17 where as well I have 2 bond interfaces in the same subnet as my server
    # ifconfig  bond0
    bond0     Link encap:Ethernet  HWaddr 00:17:A4:77:00:44
              inet addr:
    192.169.32.17  Bcast:192.169.32.31  Mask:255.255.255.224
              UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
              RX packets:2263768 errors:0 dropped:5390 overruns:0 frame:0
              TX packets:8626819 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0
              RX bytes:150407672 (143.4 Mb)  TX bytes:12455852277 (11878.8 Mb)

    # ifconfig  bond1
    bond1     Link encap:Ethernet  HWaddr 38:63:BB:2F:56:C1
              inet addr:192.169.32.38  Bcast:192.169.32.63  Mask:255.255.255.224
              UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
              RX packets:2067482 errors:0 dropped:16 overruns:0 frame:0
              TX packets:28335782 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0
              RX bytes:136453804 (130.1 Mb)  TX bytes:41070143636 (39167.5 Mb)

    The ethernet speed assigned to bond0 and bond1 is same as server i.e. 1 GB and 3 GB respectively

    Let us start our test

    Installed netperf on both the machines

    NOTE: I would recommend to disable the firewall on both server and client for the monitoring purpose as at times your firewall might stop netperf from sending traffic to client machine

    On Server
    server # rpm -Uvh /tmp/netperf-2.6.0-3.3.x86_64.rpm
    warning: /tmp/netperf-2.6.0-3.3.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID f388ca22
    Preparing...                ########################################### [100%]
       1:netperf                ########################################### [100%]

    Start netperf on any free port number
    # netserver -p 16604
    Starting netserver with host 'IN(6)ADDR_ANY' port '16604' and family AF_UNSPEC

    # netstat -ntlp | grep 16604
    tcp        0      0 :::16604        :::*                  LISTEN      3624/netserver

    So our port has been opened by netperf

    On Client
    client #  rpm -Uvh /tmp/netperf-2.6.0-3.3.x86_64.rpm
    warning: /tmp/netperf-2.6.0-3.3.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID f388ca22
    Preparing...                ########################################### [100%]
       1:netperf                ########################################### [100%]

    In the below example we are sending traffic for 100 seconds to host server IP 192.169.32.15
    # netperf -H 192.169.32.15 -p 16604 -l 100
    MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.169.32.15 () port 0 AF_INET : demo
    enable_enobufs failed: setsockopt
    Recv   Send    Send
    Socket Socket  Message  Elapsed
    Size   Size    Size     Time     Throughput
    bytes  bytes   bytes    secs.    10^6bits/sec

    11796480 11796480 11796480    100.07    
    994.23

    So bond0 network traffic is within our limit as provided to the interface i.e. 1 GB/s

    Lets validate bond1

    Here my server IP of bond1 is 192.169.32.37
    # netperf -H 192.169.32.37 -p 16604 -l 100
    MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.169.32.37 () port 0 AF_INET : demo
    enable_enobufs failed: setsockopt
    Recv   Send    Send
    Socket Socket  Message  Elapsed
    Size   Size    Size     Time     Throughput
    bytes  bytes   bytes    secs.    10^6bits/sec

    11796480 11796480 11796480    100.02  
    2982.72

    bond1 network traffic is also within our provided limit i.e. 3 GB/s

    I hope the article was helpful

    Follow the below links for more helpful tutorials

    Tutorial for Monitoring Tools SAR and KSAR with examples in Linux
    Basic iptables tutorial in Linux I
    Basic iptables tutorial in Linux II
    Creating an internal network using VMware Workstation
    Setting up custom TCP/IP Keep Alive Parameter in Linux
    What is virtual memory, paging and swap space?
    How to take remote desktop of Windows from Linux
    How to detect new hard disk attached without rebooting in Linux
    How to detect new NIC/Ethernet card without rebooting in Linux
    15 practical examples of rpm command usage in Linux
    Why is sudo command asking for root password in Linux
    How to configure bridged network in Oracle Virtual Box (Linux)
    How to configure passwordless sudo for a user in Linux
    Understanding Load Average in Linux and when to be worried about it?
    How to run a process in background or bring to foreground in Linux
    How to configure logrotate for a new log file in Red Hat Linux

    Friday, September 16, 2016

    How to downgrade HP Emluex CNA NIC card firmware version

    This article will guide you with steps used to perform upgrade as well as downgrade of Emulex Converged Network Adapters firmware version running on HP hardware

    For the demonstration of this article I will be using FlexFabric 20Gb 2-port 650FLB Adapter.

    Check the NIC adapter type installed in your blade
    # dmidecode |grep  'NIC'
    HP BIOS NIC PCI and MAC Information
            NIC 1: PCI device 06:00.0, MAC address 00:17:A4:77:00:02
            NIC 2: PCI device 06:00.1, MAC address 00:17:A4:77:00:04
            NIC 3: PCI device 06:00.2, MAC address D0:BF:9C:F0:80:69
            NIC 4: PCI device 06:00.3, MAC address D0:BF:9C:F0:80:71
            NIC 5: PCI device 06:00.4, MAC address D0:BF:9C:F0:80:6A
            NIC 6: PCI device 06:00.5, MAC address D0:BF:9C:F0:80:72
                    NIC.FlexLOM.1.1
                    HP FlexFabric 20Gb 2-port
    650FLB Adapter - NIC
                    NIC.FlexLOM.1.2
                    HP FlexFabric 20Gb 2-port 650FLB Adapter - NIC
                    NIC.FlexLOM.1.3
                    HP FlexFabric 20Gb 2-port 650FLB Adapter - NIC
                    NIC.FlexLOM.1.4
                    HP FlexFabric 20Gb 2-port 650FLB Adapter - NIC
                    NIC.FlexLOM.1.5
                    HP FlexFabric 20Gb 2-port 650FLB Adapter - NIC
                    NIC.FlexLOM.1.6
                    HP FlexFabric 20Gb 2-port 650FLB Adapter - NIC

    To check the currently installed firmware and driver version on the NIC card
    # ethtool -i eth0
    driver: be2net
    version: 10.7.110.29
    firmware-version: 10.7.110.34
    bus-info: 0000:06:00.0
    supports-statistics: yes
    supports-test: yes
    supports-eeprom-access: yes
    supports-register-dump: no

    As you see my firmware version is 10.7.110.34 while the driver version of the NIC card is 10.7.110.29
    This set of firmware and driver is from HP SPP 2016.04, so let us first perform a downgrade of the firmware to SPP 2015.04

    The CNA firmware version available with SPP 2015.04 is "hp-firmware-cna-emulex-2015.02.02-1.1.x86_64.rpm"

    Steps to downgrade NIC firmware

    Install the CNA rpm
    # rpm -Uvh /tmp/hp-firmware-cna-emulex-2015.02.02-1.1.x86_64.rpm
    Preparing...                ########################################### [100%]
       1:hp-firmware-cna-emulex ########################################### [100%]

    Unlike any other rpm the above command doesnot exactly installs the firmware, instead it will just extract the rpm content to it's respective location.

    Content of the firmware rpm is as below
    # rpm -ql hp-firmware-cna-emulex-2015.02.02-1.1
    /usr/lib/x86_64-linux-gnu/hp-firmware-cna-emulex-2015.02.02-1.1
    /usr/lib/x86_64-linux-gnu/hp-firmware-cna-emulex-2015.02.02-1.1/.cpq_package.inc
    /usr/lib/x86_64-linux-gnu/hp-firmware-cna-emulex-2015.02.02-1.1/.hpsetup
    /usr/lib/x86_64-linux-gnu/hp-firmware-cna-emulex-2015.02.02-1.1/CP025738.xml
    /usr/lib/x86_64-linux-gnu/hp-firmware-cna-emulex-2015.02.02-1.1/elxflashStandalone-linux-10.2.477.23-1.zip
    /usr/lib/x86_64-linux-gnu/hp-firmware-cna-emulex-2015.02.02-1.1/fwmatrix.txt
    /usr/lib/x86_64-linux-gnu/hp-firmware-cna-emulex-2015.02.02-1.1/installer
    /usr/lib/x86_64-linux-gnu/hp-firmware-cna-emulex-2015.02.02-1.1/readme.txt
    /usr/lib/x86_64-linux-gnu/hp-firmware-cna-emulex-2015.02.02-1.1/reference.xml
    /usr/lib/x86_64-linux-gnu/hp-scexe-compat
    /usr/lib/x86_64-linux-gnu/hp-scexe-compat/CP025738.scexe

    # cd /usr/lib/x86_64-linux-gnu/hp-firmware-cna-emulex-2015.02.02-1.1

    # unzip elxflashStandalone-linux-10.2.477.23-1.zip

    # cd elxflashStandalone-linux-10.2.477.23-1/lx

    Next execute the below command to start the downgrade
    # ./elxflash.sh /ucna /sysfs  /f
    Thu Sep 15 23:52:01 2016
    HBA=OCe14100-NIC, Port Type=NIC, MAC=00:17:A4:77:00:08,
    Update=Firmware, Image=oc14-10.2.477.23.ufi, New=10.2.477.23, Old=10.7.110.34, Status=Success

    Thu Sep 15 23:52:01 2016
    HBA=OCe14100-NIC, Port Type=NIC, MAC=00:17:A4:77:00:08,
    Update=Firmware, Image=oc14-10.2.477.23.ufi, New=10.2.477.23, Old=10.7.110.34, Status=Success

    Thu Sep 15 23:52:01 2016
    HBA=OCe14100-NIC, Port Type=NIC, MAC=30:8D:99:62:FF:75,
    Update=Firmware, Image=oc14-10.2.477.23.ufi, New=10.2.477.23, Old=10.7.110.34, Status=Success

    Thu Sep 15 23:52:02 2016
    HBA=OCe14100-NIC, Port Type=NIC, MAC=30:8D:99:62:FF:7D,
    Update=Firmware, Image=oc14-10.2.477.23.ufi, New=10.2.477.23, Old=10.7.110.34, Status=Success

    Thu Sep 15 23:52:02 2016
    HBA=OCe14100-NIC, Port Type=NIC, MAC=30:8D:99:62:FF:76,
    Update=Firmware, Image=oc14-10.2.477.23.ufi, New=10.2.477.23, Old=10.7.110.34, Status=Success

    Thu Sep 15 23:52:02 2016
    HBA=OCe14100-NIC, Port Type=NIC, MAC=30:8D:99:62:FF:7E,
    Update=Firmware, Image=oc14-10.2.477.23.ufi, New=10.2.477.23, Old=10.7.110.34, Status=Success

    elxflash: All required firmware and/or boot code downloads succeeded - Return Code=0

    Please reboot system to activate new firmware.

    So the script executed successfully with Return Code "0"

    The new firmware version is as seen below
    # ethtool -i eth0
    driver: be2net
    version: 10.7.110.29
    firmware-version: 10.7.110.34 [
    10.2.477.23]
    bus-info: 0000:06:00.0
    supports-statistics: yes
    supports-test: yes
    supports-eeprom-access: yes
    supports-register-dump: no

    NOTE:  A reboot is required to activate the new firmware

    Steps to update NIC firmware

    Currently installed firmware
    # ethtool -i eth0
    driver: be2net
    version: 10.2.477.6
    firmware-version: 10.2.477.23
    bus-info: 0000:06:00.0
    supports-statistics: yes
    supports-test: yes
    supports-eeprom-access: yes
    supports-register-dump: no

    So the currently installed NIC driver version is 10.2.477.6 and the firmware version is 10.2.477.23 which are from SPP 2015.04

    Let us update the NIC card to the firmware version from HP SPP 2016.04 i.e. "hp-firmware-cna-emulex-2016.02.02-1.1.x86_64.rpm"

    Install the rpm
    # rpm -Uvh /tmp/hp-firmware-cna-emulex-2016.02.02-1.1.x86_64.rpm
    warning: /tmp/hp-firmware-cna-emulex-2016.02.02-1.1.x86_64.rpm: Header V3 RSA/SHA1 signature: NOKEY, key ID b1275ea3
    Preparing...                ########################################### [100%]
       1:hp-firmware-cna-emulex ########################################### [100%]

    Content of the rpm is as below
    # rpm -ql hp-firmware-cna-emulex
    /usr/lib/x86_64-linux-gnu/hp-firmware-cna-emulex-2016.02.02-1.1
    /usr/lib/x86_64-linux-gnu/hp-firmware-cna-emulex-2016.02.02-1.1/.cpq_package.inc
    /usr/lib/x86_64-linux-gnu/hp-firmware-cna-emulex-2016.02.02-1.1/.hpsetup
    /usr/lib/x86_64-linux-gnu/hp-firmware-cna-emulex-2016.02.02-1.1/CP029026.xml
    /usr/lib/x86_64-linux-gnu/hp-firmware-cna-emulex-2016.02.02-1.1/elxflashStandalone-linux-10.7.110.34-1.zip
    /usr/lib/x86_64-linux-gnu/hp-firmware-cna-emulex-2016.02.02-1.1/fwmatrix.txt
    /usr/lib/x86_64-linux-gnu/hp-firmware-cna-emulex-2016.02.02-1.1/hpsetup
    /usr/lib/x86_64-linux-gnu/hp-firmware-cna-emulex-2016.02.02-1.1/readme.txt
    /usr/lib/x86_64-linux-gnu/hp-firmware-cna-emulex-2016.02.02-1.1/reference.xml
    /usr/lib/x86_64-linux-gnu/hp-scexe-compat
    /usr/lib/x86_64-linux-gnu/hp-scexe-compat/CP029026.scexe

    Follow the below steps to perform the update

    # cd /usr/lib/x86_64-linux-gnu/hp-firmware-cna-emulex-2016.02.02-1.1

    # ll
    total 38932
    -r--r--r-- 1 root root    64057 Jan 13  2016 CP029026.xml
    -rw-r--r-- 1 root root      271 Jan 13  2016 .cpq_package.inc
    drwxr-xr-x 5 root root     4096 Jan  9  2016 elxflashStandalone-linux-10.7.110.34-1
    -r--r--r-- 1 root root 38047305 Jan 13  2016 elxflashStandalone-linux-10.7.110.34-1.zip
    -r--r--r-- 1 root root      881 Jan 13  2016 fwmatrix.txt
    -r-xr-xr-x 1 root root     6737 Jan 13  2016 hpsetup
    -r-xr-xr-x 1 root root  1653176 Jan 13  2016
    .hpsetup
    -r--r--r-- 1 root root      423 Jan 13  2016 readme.txt
    -r--r--r-- 1 root root    18222 Jan 13  2016 reference.xml

    # ./.hpsetup
    ---------------------------------------------------
    Loading references...done.
    Performing discovery...
    Preparing the Emulex Kit...done
    Performing flash -- DO NOT INTERRUPT!
    Executing flash engine: ./elxflashStandalone*/lx/elxflash.sh /ucna /sysfs  /update 1>> /var/cpq/Component.log 2>> /var/cpq/Component.log 3>> /var/cpq/Component.log
    Flash Engine exit code: 0
    All updates were successful.  Reboot needed.
    Flash complete [1]

    So the update has completed successful with Exit Code 1 which means a reboot is required to activate the new firmware

    OR the update can also be done as we did our downgrade using the below steps

    # cd /usr/lib/x86_64-linux-gnu/hp-firmware-cna-emulex-2016.02.02-1.1

    # unzip elxflashStandalone-linux-10.7.110.34-1.zip

    # cd elxflashStandalone-linux-10.7.110.34-1/lx/

    # ./elxflash.sh /ucna /sysfs  /update

    Fri Jul  1 13:18:28 2016
    HBA=OCe14100-NIC, Port Type=NIC, MAC=00:17:A4:77:00:4A,
    Update=Firmware, Image=oc14-10.7.110.34.ufi, New=10.7.110.34, Old=10.2.477.23, Status=Success

    Fri Jul  1 13:18:28 2016
    HBA=OCe14100-NIC, Port Type=NIC, MAC=00:17:A4:77:00:4A,
    Update=Firmware, Image=oc14-10.7.110.34.ufi, New=10.7.110.34, Old=10.2.477.23, Status=Success

    Fri Jul  1 13:18:28 2016
    HBA=OCe14100-NIC, Port Type=NIC, MAC=70:10:6F:58:3B:B1,
    Update=Firmware, Image=oc14-10.7.110.34.ufi, New=10.7.110.34, Old=10.2.477.23, Status=Success

    Fri Jul  1 13:18:28 2016
    HBA=OCe14100-NIC, Port Type=NIC, MAC=70:10:6F:58:3B:B1,
    Update=Firmware, Image=oc14-10.7.110.34.ufi, New=10.7.110.34, Old=10.2.477.23, Status=Success

    Fri Jul  1 13:18:28 2016
    HBA=OCe14100-NIC, Port Type=NIC, MAC=70:10:6F:58:3B:B2,
    Update=Firmware, Image=oc14-10.7.110.34.ufi, New=10.7.110.34, Old=10.2.477.23, Status=Success

    Fri Jul  1 13:18:28 2016
    HBA=OCe14100-NIC, Port Type=NIC, MAC=70:10:6F:58:3B:B2,
    Update=Firmware, Image=oc14-10.7.110.34.ufi, New=10.7.110.34, Old=10.2.477.23, Status=Success

    Fri Jul  1 13:18:28 2016
    HBA=OCe14100-NIC, Port Type=NIC, MAC=70:10:6F:58:3B:B3,
    Update=Firmware, Image=oc14-10.7.110.34.ufi, New=10.7.110.34, Old=10.2.477.23, Status=Success

    Fri Jul  1 13:18:28 2016
    HBA=OCe14100-NIC, Port Type=NIC, MAC=70:10:6F:58:3B:B3,
    Update=Firmware, Image=oc14-10.7.110.34.ufi, New=10.7.110.34, Old=10.2.477.23, Status=Success


    elxflash: All required updates succeeded - Return Code=0

    Please reboot system to activate new firmware.

    Either way you will can perform the NIC firmware update.

    Updated NIC firmware version can be seen below.
    # ethtool -i eth0
    driver: be2net
    version: 10.2.477.6
    firmware-version: 10.2.477.23 [
    10.7.110.34]
    bus-info: 0000:06:00.0
    supports-statistics: yes
    supports-test: yes
    supports-eeprom-access: yes
    supports-register-dump: no

    NOTE: The new firmware will be activated after a reboot of the blade

    I hope this article was useful.

    Follow the below links for more tutorials

    Step by Step Linux Boot Process Explained In Detail
    10 examples to help you understand top command usage in Unix/Linux
    Script to take backup of any critical directory in Unix/Linux
    Configure Red Hat Cluster using VMware, Quorum Disk, GFS2, Openfiler
    Tutorial for Monitoring Tools SAR and KSAR with examples in Linux
    How to configure Samba 4 Secondary Domain Controller
    How to secure Apache web server in Linux using password (.htaccess)
    How to register Red Hat Linux with RHN (Red Hat Network )
    15 tips to enhance security of your Linux machine
    Why is Linux more secure than windows and any other OS
    What is the difference between "su" and "su -" in Linux?
    What is kernel-PAE in Linux?
    What is swappiness and how do we change its value?
    How to log iptables messages in different log file
    What are the s and k scripts in the etc rcx.d directories
    What is virtual memory, paging and swap space?

    Tuesday, September 13, 2016

    How to configure TFTP server in Linux

    About TFTP from wiki page
    Trivial File Transfer Protocol (TFTP) is a simple, lockstep, File Transfer Protocol which allows a client to get a file from or put a file onto a remote host. One of its primary uses is in the early stages of nodes booting from a local area network. TFTP has been used for this application because it is very simple to implement.
    As explained above we use TFTP server mostly for performing PXE netboot on client nodes within the network.

    Manually install tftp rpm on your linux distribution. This can be done depending upon your distribution.

    On RedHat and CentOS you can use "yum install tftp", while on SuSE distro you can use "zypper install tftp"

    Once you have successfully installed tftp rpm follow the below steps
    # rpm -qa | grep tftp
    tftp-0.48-101.31.27

    Create the directiry which you plan on using for TFTP share
    # mkdir /tftpboot
    NOTE: I will change permission of my tftp dir to 777 as I am going to demonstrate my server by uploading few files which will be done as 'nobody' user so I would need fill access to my tftp directory. Generally if you just plan on using it for PXE environment then 644 permission is more than enough.

    # chmod 777 /tftpboot
    Make the necessary changes to your tftp config file as below
    # vi /etc/xinetd.d/tftp
    # default: off
    # description: tftp service is provided primarily for booting or when a \
    #       router need an upgrade. Most sites run this only on machines acting as
    #       "boot servers".
    service tftp
    {
            socket_type             = dgram
            protocol                = udp
            wait                    = yes
            flags                   = IPv4  
    <-- If you also have IPv6 in your network, mention both values (eg. IPv4  IPv6)
            port                    = 69
            user                    = root
            server                  = /usr/sbin/in.tftpd
            server_args             = -c -s /tftpboot  <-- This is the tftp directory which will contain all files which can be picked by client
            disable                 = no  <-- Make sure this is 'no'
    }

    Save and exit the file

    Restart the xinetd services
    # /etc/init.d/xinetd restart
    Shutting down xinetd: (waiting for all children to terminate)                  
    done
    Starting INET services. (xinetd)                                               done

    Let us test our tftp server
    For this example I am going to use my Onboard Administrator from my HPE enclosure and will attempt to upload supportdump from the OA to my tftp server (192.169.32.10)

    Login to OA CLI using Puttylogin as: HPadmin

    -----------------------------------------------------------------------------
    WARNING: This is a private system.  Do not attempt to login unless you are an
    authorized user.  Any authorized or unauthorized access and use may be moni-
    tored and can result in criminal or civil prosecution under applicable law.
    -----------------------------------------------------------------------------

    Firmware Version: 4.50
    Built: 07/24/2015 @ 04:06
    OA Bay Number:  1
    OA Role:       Active
    HPadmin@10.43.21.136's password:

    HP BladeSystem Onboard Administrator
    (C) Copyright 2006-2015 Hewlett-Packard Development Company, L.P.

    Type 'HELP' to display a list of valid commands.

    Bangalore1-01-01> 
    upload SUPPORTDUMP tftp://192.169.32.10/log1

    Starting background task to collect debug data. Return status will be displayed when it is done. You can continue working during this process or log off.


    Bangalore1-01-01>

    Successfully uploaded file

    Let us go back and check our tftp server if the files are successfully uploaded
    cc01-nds-ins:/tftpboot # ll
    total 624
    -rw-rw-rw- 1 nobody nobody 605352 Sep 13 16:16 log1

    Well looks like our TFTP server is working as expected.

    Follow the below links for more tutorials

    Configure Red Hat Cluster using VMware, Quorum Disk, GFS2, Openfiler
    Tutorial for Monitoring Tools SAR and KSAR with examples in Linux
    How to configure Samba 4 Secondary Domain Controller
    How to secure Apache web server in Linux using password (.htaccess)
    How to register Red Hat Linux with RHN (Red Hat Network )
    Red hat Enterprise Linux 5.5 Installation Guide (Screenshots)
    15 tips to enhance security of your Linux machine
    Why is Linux more secure than windows and any other OS
    What is the difference between "su" and "su -" in Linux?
    What is kernel-PAE in Linux?
    What is swappiness and how do we change its value?
    How to log iptables messages in different log file
    What are the s and k scripts in the etc rcx.d directories
    What is virtual memory, paging and swap space?
    10 examples to help you understand top command usage in Unix/Linux

    How to fix "mountd: refused mount request: unmatched host"

    Error:

    On Client (192.169.32.17)
    # mount 192.169.32.10:/export/home/deepak /mnt
    mount.nfs: access denied by server while mounting 192.169.32.10:/export/home/deepak

    On NFS Server (192.169.32.10)
    # tail -n 1 /var/log/messages
    Sep 13 00:00:32 cc01-nds-ins rpc.mountd[29613]: refused mount request from 192.169.32.17 for /export/home/deepak (/export/home/deepak): unmatched host

    Solution:

    This error is occurring because the NFS server is unaware of the client network attempting to access the NFS shares.

    As for my case below are the list of directories which are shared using NFS server
    # exportfs -v
    /export/home/deepak               10.10.10.0/255.0.0.0(ro,wdelay,root_squash,no_subtree_check)
    /export/home/rahul                10.10.10.0/255.0.0.0(ro,wdelay,no_root_squash,no_subtree_check)
    /root/upgrade/scripts             10.10.10.0/255.0.0.0(rw,wdelay,no_root_squash,no_subtree_check)

    As you see the directories are shared for 10.10.10.0/255.0.0.0 subnet while my client server IP is in a different subnet 192.169.32.0/255.255.255.224

    So I need to add this subnet in my exports share

    On NFS Server (192.169.32.10)

    Add a new line in /etc/exports file as shown below
    # vi /etc/exports
    /export/home/deepak 192.169.32.0/255.255.255.224(ro,sync,no_subtree_check)

    Refresh the share
    # exportfs -ra
    List the updated share information
    # exportfs -v
    /export/home/deepak              10.10.10.0/255.0.0.0(ro,wdelay,root_squash,no_subtree_check)
    /export/home/deepak              192.169.32.0/255.255.255.224(ro,wdelay,root_squash,no_subtree_check)
    /export/home/rahul               10.10.10.0/255.0.0.0(ro,wdelay,no_root_squash,no_subtree_check)
    /ISS/export-upgrade              10.10.10.0/255.0.0.0(rw,wdelay,no_root_squash,no_subtree_check)
    Let us re-attempt to access the NFS share from our client

    On Client (192.169.32.17)

    # mount -t nfs 192.169.32.10:/export/home/deepak /mnt
    # mount | grep export
    192.169.32.10:/export/home/deepak on /mnt type nfs (rw,addr=192.169.32.10)


    I hope this tutorial was helpful.

    Follow the below links for more tutorials:

    Sunday, September 11, 2016

    How to preserve symbolic link while copying a file in Linux

    Below set of commands are executed on Suse Linux Enterprise Server 11 SP 3 operating system,

    There can be many scenarios of copying symbolic links between different directories, let me try to explain some of the cases with examples to help you understand

    I have created few sample files and symbolic links to demonstrate this example
    # mkdir /tmp/src_file
    # cd /tmp/src_files

    # ll
    total 0
    -rw-r--r-- 1 root root  0 Sep 11 17:53 a
    -rw-r--r-- 1 root root  0 Sep 11 17:53 b
    -rw-r--r-- 1 root root  0 Sep 11 17:53 c
    lrwxrwxrwx 1 root root 13 Sep 11 17:53
    cron_allow -> ../cron.allow
    lrwxrwxrwx 1 root root 12 Sep 11 17:53 cron_deny -> ../cron.deny

    Copy symbolic links as files

    Above I have two smylinks cron_allow and cron_deny, Let us copy them to /tmp/dst_files as normal files instead of symlinks

    # cp -LRv /tmp/src_files/* /tmp/dst_files/
    `/tmp/src_files/a' -> `/tmp/dst_files/a'
    `/tmp/src_files/b' -> `/tmp/dst_files/b'
    `/tmp/src_files/c' -> `/tmp/dst_files/c'
    `/tmp/src_files/cron_allow' -> `/tmp/dst_files/cron_allow'
    `/tmp/src_files/cron_deny' -> `/tmp/dst_files/cron_deny'

    # ll /tmp/dst_files/
    total 8
    -rw-r--r-- 1 root root  0 Sep 11 18:03 a
    -rw-r--r-- 1 root root  0 Sep 11 18:03 b
    -rw-r--r-- 1 root root  0 Sep 11 18:03 c
    -rw-r--r-- 1 root root 28 Sep 11 18:03 cron_allow
    -rw-r--r-- 1 root root 15 Sep 11 18:03 cron_deny

    As you see both symlinks are converted into normal file. Let us match the content of these with the original file
    # sdiff cron_allow /tmp/cron.allow
    root                                                         root
    deepak                                                       deepak
    amit                                                         amit
    rahul                                                        rahul

    From the 'man' page
    ‘-L’ ,‘--dereference’ - Follow symbolic links when copying from them. With this option, cp cannot create a symbolic link. For example, a symlink (to regular file) in the source tree will be copied to a regular file in the destination tree.


    Copy symlinks as symlinks (not a file)

    # cp -Prv /tmp/src_files/* /tmp/dst_files/
    `/tmp/src_files/a' -> `/tmp/dst_files/a'
    `/tmp/src_files/b' -> `/tmp/dst_files/b'
    `/tmp/src_files/c' -> `/tmp/dst_files/c'
    `/tmp/src_files/cron_allow' -> `/tmp/dst_files/cron_allow'
    `/tmp/src_files/cron_deny' -> `/tmp/dst_files/cron_deny'

    # ll /tmp/dst_files/
    total 0
    -rw-r--r-- 1 root root  0 Sep 11 18:06 a
    -rw-r--r-- 1 root root  0 Sep 11 18:06 b
    -rw-r--r-- 1 root root  0 Sep 11 18:06 c
    lrwxrwxrwx 1 root root 13 Sep 11 18:06
    cron_allow -> ../cron.allow
    lrwxrwxrwx 1 root root 12 Sep 11 18:06 cron_deny -> ../cron.deny

    This can also be achieved with some more arguments like below
    # cp -dv /tmp/src_files/* /tmp/dst_files/
    `/tmp/src_files/a' -> `/tmp/dst_files/a'
    `/tmp/src_files/b' -> `/tmp/dst_files/b'
    `/tmp/src_files/c' -> `/tmp/dst_files/c'
    `/tmp/src_files/cron_allow' -> `/tmp/dst_files/cron_allow'
    `/tmp/src_files/cron_deny' -> `/tmp/dst_files/cron_deny'

    Copy symlinks with same permissions and ownership as from source directory

    Normally if you copy a file the permission of the target location is changed to the user which was used to copy the file (considering that user as the new owner of the target location)

    Let us change the permission and owner of one of the file from our source directory
    # ll
    total 0
    -rwxrwxrwx 1 oamsys root  0 Sep 11 17:53 a
    -rwxrwxrwx 1 oamsys root  0 Sep 11 17:53 b
    -rw-r--r-- 1 root   root  0 Sep 11 17:53 c
    lrwxrwxrwx 1 root   root 13 Sep 11 17:53
    cron_allow -> ../cron.allow
    lrwxrwxrwx 1 root   root 12 Sep 11 17:53 cron_deny -> ../cron.deny

    After copying
    # cp -dv /tmp/src_files/* /tmp/dst_files/
    `/tmp/src_files/a' -> `/tmp/dst_files/a'
    `/tmp/src_files/b' -> `/tmp/dst_files/b'
    `/tmp/src_files/c' -> `/tmp/dst_files/c'
    `/tmp/src_files/cron_allow' -> `/tmp/dst_files/cron_allow'
    `/tmp/src_files/cron_deny' -> `/tmp/dst_files/cron_deny'

    # ll /tmp/dst_files/
    total 0
    -rwxr-xr-x 1 root root  0 Sep 11 18:12 a
    -rwxr-xr-x 1 root root  0 Sep 11 18:12 b
    -rw-r--r-- 1 root root  0 Sep 11 18:12 c
    lrwxrwxrwx 1 root root 13 Sep 11 18:12 cron_allow -> ../cron.allow
    lrwxrwxrwx 1 root root 12 Sep 11 18:12 cron_deny -> ../cron.deny

    So considering my umask value i.e. 0022 the file permission were updated to 755 and ownership has been changed to 'root'' as the files were copied using 'root' user.

    So how do I preserve these permissions along with symlinks
    # cp -dav /tmp/src_files/* /tmp/dst_files/
    `/tmp/src_files/a' -> `/tmp/dst_files/a'
    `/tmp/src_files/b' -> `/tmp/dst_files/b'
    `/tmp/src_files/c' -> `/tmp/dst_files/c'
    `/tmp/src_files/cron_allow' -> `/tmp/dst_files/cron_allow'
    `/tmp/src_files/cron_deny' -> `/tmp/dst_files/cron_deny'

    # ll /tmp/dst_files/
    total 0
    -
    rwxrwxrwx 1 oamsys root  0 Sep 11 17:53 a
    -rwxrwxrwx 1 oamsys root  0 Sep 11 17:53 b
    -rw-r--r-- 1 root   root  0 Sep 11 17:53 c
    lrwxrwxrwx 1 root   root 13 Sep 11 17:53 cron_allow -> ../cron.allow
    lrwxrwxrwx 1 root   root 12 Sep 11 17:53 cron_deny -> ../cron.deny

    So everything looks on track now.

    From 'man' page
           -a, --archive
                  same as -dR --preserve=all

    Copy symlinks with relative path

    One big question here, for me the copying of symbolic link is working fine because we are copying the symlink in the same parent directory and the target file is always accessible by the symlink.

    Let me show you some more examples
    # ll
    total 0
    -rwxrwxrwx 1 oamsys root  0 Sep 11 17:53 a
    -rwxrwxrwx 1 oamsys root  0 Sep 11 17:53 b
    -rw-r--r-- 1 root   root  0 Sep 11 17:53 c
    lrwxrwxrwx 1 root   root 13 Sep 11 17:53
    cron_allow -> ../cron.allow
    lrwxrwxrwx 1 root   root 12 Sep 11 17:53 cron_deny -> ../cron.deny

    Here above the symlink cron_allow is pointing to /tmp/cron.allow, but what I copy these files to a completely different location where relative path"../cron.allow" is inaccessible

    # cp -Prv /tmp/src_files/* /tmp/test/new_dst/
    `/tmp/src_files/a' -> `/tmp/test/new_dst/a'
    `/tmp/src_files/b' -> `/tmp/test/new_dst/b'
    `/tmp/src_files/c' -> `/tmp/test/new_dst/c'
    `/tmp/src_files/cron_allow' -> `/tmp/test/new_dst/cron_allow'
    `/tmp/src_files/cron_deny' -> `/tmp/test/new_dst/cron_deny'

    # ll /tmp/test/new_dst/
    total 0
    -rwxr-xr-x 1 root root  0 Sep 11 18:19 a
    -rwxr-xr-x 1 root root  0 Sep 11 18:19 b
    -rw-r--r-- 1 root root  0 Sep 11 18:19 c
    lrwxrwxrwx 1 root root 13 Sep 11 18:19
    cron_allow -> ../cron.allow
    lrwxrwxrwx 1 root root 12 Sep 11 18:19 cron_deny -> ../cron.deny

    # cd /tmp/test/new_dst/
    # less cron_allow
    cron_allow: No such file or directory

    So ../cron.allow is not accessible. To avoid such scenarios it is always  recommended to use full path of the target file for a symlink.

    Currently I am now aware of a single command which can fix this, if someone knows than please put in your comment which can be used to overcome such scenarios

    As of now I use scripting to fix these issues (a small sample script)
    #!/bin/sh

    src="/tmp/src_files"
    dst="/tmp/test/new_dst"

    #clean destination
    if [ -d $dst ]; then
       echo "Cleaning target directory $dst"
       rm -f $dst/*
    fi

    #copy files
    for i in `ls $src`; do
       path=""
       if [  -L $i ]; then
          path=`readlink -f $i`
          ln -s $path $dst/$i
       else
          cp -vP $i $dst
       fi
    done

    # Listing target directiry files
    ls -al $dst


    Follow the below links for more tutorials

    How to find the path of any command in Linux
    How to configure a Clustered Samba share using ctdb in Red Hat Cluster
    How to delete an iscsi-target from openfiler and Linux
    How to perform a local ssh port forwarding in Linux
    How to use yum locally without internet connection using cache?
    What is umask and how to change the default value permanently?
    Understanding Partition Scheme MBR vs GPT
    How does a successful or failed login process works in Linux
    How to find all the process accessing a file in Linux
    How to exclude multiple directories from du command in Linux
    How to configure autofs in Linux and what are its advantages?
    How to resize software raid partition in Linux
    How to configure Software RAID 1 mirroring in Linux
    How to prevent a command from getting stored in history in Linux