Friday, 31 August 2012

Centos 6/RHEL set up a Static IP

To set up a single Static IP on Centos 6/RHEL do the following

(This assumes you have an existing connection 'eth0')

Install iproute2 tools  

$ sudo yum -y install iproute  

First rename your existing file and get some information from it

$ sudo su

# cd /etc/sysconfig/network-scripts/

# mv ifcfg-eth0 ifcfg-eth0.bak

# cat ifcfg-eth0.bak   

Echo the HWADDR and UUID into your new ifcfg-eth0 file

# echo HWADDR="00:02:44:4B:52:D8" UUID="2609446d-e228-4600-ae9c-8230c1c3d7d3" > ifcfg-eth0

You can use the below commands to view the routing table.


$ route -n                            

$ netstat -nr                           

Add the lines below to complete the file


(Drop the UUID to the next line)

# vi ifcfg-eth0                       

DEVICE="eth0"
BOOTPROTO="static"
IPADDR=192.168.0.100
NETMASK=255.255.255.0
NETWORK=192.168.0.0
GATEWAY=192.168.0.1
NM_CONTROLLED="no"
ONBOOT="yes"
TYPE="Ethernet"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"


Save the file


Replace the four network values with your own, you can get all the information from the two commands above, this assumes you will know the static ip address range of your own router for the IPADDR.

(NETWORK will be under 'Destination', GATEWAY will be under 'Gateway' and NETMASK will be under 'Genmask'  using either route -n or netstat -nr commands)

# service network restart

To relaunch the new configuration

$ ifconfig -a                       

eth0      Link encap:Ethernet  HWaddr 00:02:44:4B:52:D8  
          inet addr:192.168.0.100  Bcast:192.168.0.255  
          Mask:255.255.255.0
          inet6 addr: fe80::202:44ff:fe4b:52d8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6071 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6899 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:3804377 (3.6 MiB)  TX bytes:1416715 (1.3 MiB)
          Interrupt:18 Base address:0x8000 

Some setups may require a reboot


See also a Static IP with a Network Bridge.





Centos 6/RHEL set up Static IP with Network Bridge

Setting up a Network Bridge on Centos 6/RHEL with a Static IP is relatively straightforward

The bridge enables virtual machines to be accessed from other hosts as if they are physical systems in the network.

$ sudo yum -y install bridge-utils

Rename your existing file and get some information from it

(This assumes you have an existing connection 'eth0')

$ sudo su

# cd /etc/sysconfig/network-scripts/

# mv ifcfg-eth0 ifcfg-eth0.bak

# cat ifcfg-eth0.bak    

Echo the HWADDR and UUID into your new ifcfg-eth0 file

# echo HWADDR="00:02:44:4B:52:D8" UUID="2609446d-e228-4600-ae9c-8230c1c3d7d3" > ifcfg-eth0

Add the lines below to complete the file

# vi ifcfg-eth0                       

DEVICE="eth0"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
NM_CONTROLLED="no"
ONBOOT="yes"
TYPE="Ethernet"
BRIDGE="br0"

(Drop the UUID to the next line)

Save the file

Install iproute2 tools  

$ sudo yum -y install iproute          
$ route -n                             

$ netstat -nr  

The above commands fetch needed information                         
Create a bridge file                                   

# vi ifcfg-br0                         add the following

DEVICE="br0"
BOOTPROTO="static"
IPADDR=192.168.0.100
NETMASK=255.255.255.0
NETWORK=192.168.0.0
GATEWAY=192.168.0.1
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
NM_CONTROLLED="no"
ONBOOT="yes"
PEERDNS="yes"
TYPE="Bridge"

Replace the 4 network values with your own, you can get all the information from the 2 commands above, this assumes you will know the static ip address range of your own router for the IPADDR.


(NETWORK will be under 'Destination', GATEWAY will be under 'Gateway' and NETMASK will be under 'Genmask'  using either route -n or netstat -nr commands)

# service network restart

To relaunch the new configuration

$brctl show                         

Shows the bridge details                   

$ ifconfig -a                        

Shows the new setup


br0       Link encap:Ethernet  HWaddr 00:02:44:4B:52:D8  
          inet addr:192.168.0.100  Bcast:192.168.0.255 
          Mask:255.255.255.0       
          inet6 addr: fe80::202:44ff:fe4b:52d8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:154 errors:0 dropped:0 overruns:0 frame:0
          TX packets:212 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:32630 (31.8 KiB)  TX bytes:88381 (86.3 KiB)

eth0      Link encap:Ethernet  HWaddr 00:02:44:4B:52:D8
          inet6 addr: fe80::202:44ff:fe4b:52d8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1048 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1129 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:383206 (374.2 KiB)  TX bytes:240253 (234.6KiB)
          Interrupt:18 Base address:0x8000


Some setups may require a reboot



See also a simple Static IP without a bridge.












Wednesday, 29 August 2012

Centos 6/RHEL using Getinfo

A handy little script for gathering system information is

getinfo, it's available from elrepo

$ sudo rpm --import http://elrepo.org/RPM-GPG-KEY-elrepo.org

$ sudo rpm -Uvh http://elrepo.org/elrepo-release-6-5.el6.elrepo.noarch.rpm

$ sudo vi /etc/yum.repos.d/elrepo.repo    Disable it by default

$ sudo yum -y install getinfo

Running it will save information to a temp file or post it to pastebin.centos.org. 

All options can be run as a normal user but fdisk information can only be provided if run as root. 

Check first the contents of the output file to ensure it does not contain any sensitive information such as public IP addresses or hostnames.


Commands

1. Basic info - appropriate for any and all CentOS questions. - getinfo.sh basic

2. Disk/filesystem problem - Basic + full disk info - needs to be run as root - getinfo.sh disk

3. Hardware/driver/kernel problem - Basic + hardware and kernel info. - getinfo.sh driver

4. Network problem - Basic + full network info. - getinfo.sh network

5. Package problems with yum, rpm, and repos - Basic + rpm, yum, kernel. - getinfo.sh package

6. Everything - Run as either root or non-root, but won't get fdisk info unless root. - getinfo.sh all (the default)

As an example run as unprivileged user

$ getinfo.sh driver

 WARNING!!!
Not running as root. No fdisk, parted, blkid, or LVM information will be provide                                                                                                                                                             d!

Collecting system information for Driver questions. May take a few minutes.
uname...rpm...cat...getenforce...free...rpm...lspci...lsusb...rpm...***

########################
Results are in the file:
* /tmp/basedata.8UFpcW *
########################

Remember to hide sensitive information before posting.

Use cat to view the file

$ cat /tmp/basedata.8UFpcW

Some of the contents of the getinfo shell script output

 == BEGIN lspci -nn ==
00:00.0 Host bridge [0600]: Intel Corporation 82G33/G31/P35/P31 Express DRAM Con                                                                                                                                                             troller [8086:29c0] (rev 02)
00:01.0 PCI bridge [0604]: Intel Corporation 82G33/G31/P35/P31 Express PCI Expre                                                                                                                                                             ss Root Port [8086:29c1] (rev 02)
00:19.0 Ethernet controller [0200]: Intel Corporation 82562V-2 10/100 Network Co                                                                                                                                                             nnection [8086:10c0] (rev 02)
00:1a.0 USB controller [0c03]: Intel Corporation 82801I (ICH9 Family) USB UHCI C                                                                                                                                                             ontroller #4 [8086:2937] (rev 02)
00:1a.1 USB controller [0c03]: Intel Corporation 82801I (ICH9 Family) USB UHCI C                                                                                                                                                             ontroller #5 [8086:2938] (rev 02)
00:1a.2 USB controller [0c03]: Intel Corporation 82801I (ICH9 Family) USB UHCI C                                                                                                                                                             ontroller #6 [8086:2939] (rev 02)
00:1a.7 USB controller [0c03]: Intel Corporation 82801I (ICH9 Family) USB2 EHCI                                                                                                                                                              Controller #2 [8086:293c] (rev 02)
00:1b.0 Audio device [0403]: Intel Corporation 82801I (ICH9 Family) HD Audio Con                                                                                                                                                             troller [8086:293e] (rev 02)
00:1d.0 USB controller [0c03]: Intel Corporation 82801I (ICH9 Family) USB UHCI C                                                                                                                                                             ontroller #1 [8086:2934] (rev 02)
00:1d.1 USB controller [0c03]: Intel Corporation 82801I (ICH9 Family) USB UHCI C                                                                                                                                                             ontroller #2 [8086:2935] (rev 02)
00:1d.2 USB controller [0c03]: Intel Corporation 82801I (ICH9 Family) USB UHCI C                                                                                                                                                             ontroller #3 [8086:2936] (rev 02)
00:1d.7 USB controller [0c03]: Intel Corporation 82801I (ICH9 Family) USB2 EHCI                                                                                                                                                              Controller #1 [8086:293a] (rev 02)
00:1e.0 PCI bridge [0604]: Intel Corporation 82801 PCI Bridge [8086:244e] (rev 9                                                                                                                                                             2)
00:1f.0 ISA bridge [0601]: Intel Corporation 82801IR (ICH9R) LPC Interface Contr                                                                                                                                                             oller [8086:2916] (rev 02)
00:1f.2 IDE interface [0101]: Intel Corporation 82801IR/IO/IH (ICH9R/DO/DH) 4 po                                                                                                                                                             rt SATA Controller [IDE mode] [8086:2920] (rev 02)
00:1f.3 SMBus [0c05]: Intel Corporation 82801I (ICH9 Family) SMBus Controller [8                                                                                                                                                             086:2930] (rev 02)
00:1f.5 IDE interface [0101]: Intel Corporation 82801I (ICH9 Family) 2 port SATA                                                                                                                                                              Controller [IDE mode] [8086:2926] (rev 02)
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation G92 [GeForce 8800 G                                                                                                                                                             T] [10de:0611] (rev a2)
== END   lspci -nn ==

== BEGIN lsusb ==
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 003: ID 0781:556b SanDisk Corp.
Bus 002 Device 002: ID 0644:0201 TEAC Corp.
Bus 004 Device 002: ID 04f3:0212 Elan Microelectronics Corp. Laser Mouse
Bus 005 Device 002: ID 413c:2003 Dell Computer Corp. Keyboard
Bus 008 Device 002: ID 046d:0b05 Logitech, Inc.
Bus 008 Device 003: ID 413c:8130 Dell Computer Corp.
Bus 008 Device 004: ID 046d:c718 Logitech, Inc.
Bus 008 Device 005: ID 046d:c719 Logitech, Inc.
== END   lsusb ==

== BEGIN rpm -qa kmod\* kmdl\* ==
kmod-nvidia-319.23-1.el6.elrepo.i686
== END   rpm -qa kmod\* kmdl\* ==

Thursday, 23 August 2012

Centos 6/RHEL VMware-Workstation import VirtualBox Windows Vista image

With the release of VirtualBox-4.1 it is fairly easy to export an image in the VMDK format to import into VMware-Workstation should the need arise, either through bad planning or simply through a desire to do so.

This tutorial walks through the installation of Windows Vista as an example on VirtualBox, then the cloning and exporting of it into VMware-Workstation in a fully working condition. If you have not yet installed VirtualBox go here for a quick tutorial. It also assumes that you have VMware-Workstation installed somewhere though not necessarily on the same machine. The host operating system is Centos 6 Linux.


The main thing to remember when first installing the guest OS on VirtualBox is to ensure that the hard disk type chosen is the VMDK format, in case the need arises to move it.


The following shows the installation of Windows Vista onto VirtualBox and then the cloning of it into VMware-Workstation.


Installing on VirtualBox - Create Virtual Disk



Open VirtualBox and create new virtual disk


Assign a suitable ram amount

Create a new disk


Select the VMDK box


Select fixed disk 

Select a disk size

Hit 'Create' and wait

After a few minutes your disk will be created and ready to install the operating system. We do this as in the images below.

Be aware that during the installation it is probably best to select full screen mode and you may have to toggle between VM and your computer occasionally with Right Ctrl.

Installing on VirtualBox - Vista Installation

Now open up VirtualBox and click on the newly created machine in the left column to start the first run wizard.

Select the CD/DVD Drive

Double click on the VM (left column) to start the procedure

Go through the install procedure





Until finished and installed

Below is the OS as installed after completing the steps described above.


Windows Vista installed on Virtualbox

Cloning from VirtualBox

Now we are going to clone the Windows Vista VM into a state ready to import into VMware-Workstation.

With your VM shut down but selected in the left panel, go to 'Machine' > 'Clone' remembering to check the
'reinitialise the mac address' box.

Click 'Next' and at the next screen select 'Full Clone', then hit 'clone' and wait.


It takes quite a while to complete, when it does you will have a new clone folder in your VirtualBox VMs directory.

Now copy over the new clone to the VMware directory which should be in your home directory.

Once it has copied over we are ready to start the import.

Importing into VMware-Workstation

Open up VMware and start the New Virtual Machine wizard.

Select advanced options

Leave at defaults


Select install OS later

Select OS type  

Browse to the folder you copied earlier

Select a suitable ram amount

Select network connection

Select hard drive controller

Important: Select use existing disc

Browse to the cloned disk and select it

Select convert to newer format

Click finish and your cloned disk is imported ready to start.


So now your new import will be showing as 'Windows Vista' unless you specified otherwise, hit 'Power on this Virtual Machine'
and let it load up. You will get something resembling the image below.

  Windows Vista cloned from VirtualBox into VMware-Workstation

You can now install VMware tools and finish any drivers etc. The above procedure can be performed on any OS you have installed, not only Windows Vista. 

Check out a similar tutorial using Debian Linux as the guest OS.













Centos 6/RHEL VMware-Workstation import VirtualBox Debian Linux image

With the 4.1 release of VirtualBox it is fairly easy to export an image in the VMDK format to import into VMware-Workstation should the need arise, either through bad planning or simply through a desire to do so.

This tutorial walks through the installation of Debian Linux on VirtualBox, then the cloning and exporting of it into VMware-Workstation in a fully working condition. If you have not yet installed VirtualBox go to the quick tutorial. It also assumes that you have VMware-Workstation installed somewhere though not necessarily on the same machine. The host operating system is Centos 6 Linux.


I used a Debian disk but you should be able to use any distro.


The main thing to remember when first installing the guest OS on VirtualBox is ensure that the hard disk type chosen is the VMDK format, in case the need arises to move it.


The following shows the installation of a Debian Linux distro onto VirtualBox and then the cloning of it into VMware-Workstation.


Installing on VirtualBox



Open VirtualBox and create new virtual disk


Assign a suitable ram amount

Create a new disk


Select the VMDK format


Select fixed disk 

Assign a disk size

Hit 'Create' and wait

After a few minutes your disk will be created and ready to install the operating system. I am not going to go into that here as I assume that if you are a Linux user you will know how to install an operating system whether it is on a VM or a physical drive. Just be aware that during the installation process it is probably best to select full screen mode and you may have to toggle between VM and your computer occasionally with Right Ctrl.

Below is the OS as I installed it after completing the steps described above.

Debian installed on Virtualbox

Cloning from VirtualBox

Now we are going to clone the Debian VM into a state ready to import into VMware-Workstation.

With your VM shut down but selected in the left panel, go to 'Machine' > 'Clone' remembering to check the
'reinitialise the mac address' box


Click 'Next' and at the next screen select 'Full Clone', then hit 'clone' and wait. It takes quite a while to complete, when it does you will have a clone folder in your VirtualBox VMs directory.

Now copy the clone folder to the VMware directory which should be in your home directory. Do this manually via your file manager as it can get messy in the terminal due to folder name spaces.

Once it has copied over we are ready to start the import.

Importing into VMware-Workstation

Open up VMware and start the New Virtual Machine wizard.

Select advanced options

Leave at defaults

Select install OS later

Select OS type and browse to the folder you copied earlier

Select a suitable ram amount

Select network connection

Select hard drive controller

Select use existing disc

Browse to the cloned disk and select it

Select convert to newer format

Click finish and your cloned disk is imported ready to start.

So now your new import will be showing as 'Other Linux' unless you specified a distribution, hit 'Power on this Virtual Machine'
and let it load up. You will get something resembling the image below.

  Debian cloned from VirtualBox into VMware-Workstation

You can now install VMware tools and finish any drivers etc. The above procedure can be performed on any OS you have installed, not just Linux guests.

Check out a similar tutorial using Windows Vista as the guest OS.