Posts Tagged ‘switch’

How to check if network ethernet cards are active on Linux server / detect the physical connected state of a network cable / connector?

Tuesday, November 1st, 2022

linux-check-connectivity-interface-software-implementation-of-multi-queue-support-in-Linux-using-commodity-Ethernet-NICs

Lets say you are administrating some Linux server and need to upgrade a switch and temporary move out traffic for ethernet interfaces connected via a Gigabit network to a Gigabit Cisco / Junper EX Series / HPE Aruba or Arista Platform network switch to a newer version of a switch or software.

Usually if you don't have control over the Network switch (if you're employeed in a large corporation), that migration will be handled by a colleague from the Network team in a prescheduled time slot and usually in a coordinated meeting, once the cabling is being physically moved by someone a person in the Computer Room (in DC) in the respective data center.

Then once the correct commands are executed on the network switch to remap the new cable to point to the right location on the Linux server, where the old switch was and the setup has to be double verified by the network team mate.

Once this is done either by a colleague or if you're in a smaller company and you work as one man army sysadmin and you have done it yourself.
Next step is to verify that the Ethernet LAN cards on the Linux server lets say 6 or 8 LAN cards are still connected and active to the preset Active LAN / VLANs.

On Linux this is pretty simple and there is many ways to do it with external tools like ethtool, if you're lucky and your server doesn't have to have a paranoid security rules to follow or have to be a minimilastic machine with a 100% PCI High security standards compliancy.

To check connectivity for all your ethernet interfaces you can simply run a one liner shell script like so:

[root@linux-server ~]# for i in $(ip a s|grep -i :|grep -v link|awk '{ print $2 }'|sed -e 's#:##g'|grep -v lo); do ethtool $i; done
Settings for eth0:
        Link detected: yes
Settings for eth1:
        Link detected: yes
Settings for eth2:
        Link detected: yes

So far so good but what if your RHEL / CentOS / Debian server doesn't have ethtool installed and you're not allowed to install it then how can you check whether network cable connector is indicating a network activity to the connected Ethernet LAN cards?

[root@linux-server ~]# for f in $(ls -1 /sys/class/net/); do echo "Eth inface: $f"; cat /sys/class/net/$f/operstate; done
Eth inface: eth0
up
Eth inface: eth1
up
Eth inface: eth2
up
Eth inface: lo
unknown

If your operstate returns something different like state unknown, e.g.:

root@linux-server ~]# cd /sys/class/net/
[root@linux-server net]# grep "" eth2/operstate
unknown
[root@linux-server net]#

[root@linux-server net]# grep "" eth{0,1,2,3}/operstate  
eth0/operstate:unknown
eth1/operstate:unknown
eth2/operstate:unknown
eth3/operstate:unknown

Then you need to check the carrier file

[root@linux-server net]# grep "" eth{0,1,2,3}/carrier
eth0/carrier:1
eth1/carrier:1
eth2/carrier:1
eth3/carrier:1

It could return either 0 or 1

The number 1 in the above output means that the network cable is physically connected to your network card’s slot meaning your network switch migration is success.

Method 2: Next, we will test a second network interface eth1:

[root@linux-server net]# cat /sys/class/net/eth1/carrier
[root@linux-server net]# cat: /sys/class/net/eth1/carrier: Invalid argument

This command’s output most likely means the the eth1 network interface is in powered down state.

So what have learned?

We have learned how to monitor the state of the network cable connected to a Linux ethernet device via external switch that is migrated without the use of any external tools like ethtool.

Migrate VMWare Linux Virtual Machine to Virtualbox – Convert VMware .VMX to .OVF (Open Virtual Format)

Monday, June 2nd, 2014

migrate_vmware-virtual-machine-toto-virtualbox-vmx-to-ovf-migration

VMWare Virtual Machines are usually stored in OVA Format  which is bundle of OVF(Open Virtualization Format) and in multiple *.VMDK files.
Though other Virtual Machines are supposed to also support these "open virtualization format", different VM vendors implement and support it differently, therefore though in theory VirtualBox and QEMU are said to support OVA Format. Attempts to import such usually will fail. In this little article I will explain how VMWare stored (exported) VirtualMachine machine can be succesfully imported to VirtualBox.
 

1. Locate where is Virtualbox .vmx files from Window search or via dir command

I'm a console guy, so I prefer looking for VMWare's .vmx from command line:
 

C:\Users\GGEORGI7> cd c:\ C:\> dir /s *.vmx

 

Volume in drive C is PC COE
Volume Serial Number is XXXX-XXXX

Directory of C:\Users\ggeorgi7\Documents\Virtual Machines\Debian 7

06/02/14 11:06 AM 2,687 Debian 7.vmx
05/28/14 15:44 PM 370 Debian 7.vmxf
2 File(s) 3,057 bytes


2. Switch to wherever the VMWare virtualmachine .vmx file is located

 

C:\> cd \Users\ggeorgi7\Documents\Virtual Machines\Debian 7
 

N.B. !Make sure the VMWare Virtualmachine is Shutdown (if it is Suspended converted file will not be properly implemented inside VirtualBox!). Whether the migrated virtualhost is suspended, launch VMWare, restore its state and Shut it down properly before starting migration with ovftool.
 

3. Remove Vmware-tools, Reset Display settings and Input D (before exporting to OVF) in VMWare

a) Remove vmware-tools

Vmware-tools kernel modules and stuff compiled specific for VMWare are no longer needed and might pose issues, thus it is always a good idea if previously installed in VMWare to wipe them out with cmd:

vmware-uninstall-tools.pl

uninstall-vmware-tools-linux-screenshot-migrating-vmware-to-virtualbox
b) Reset Display Device and Input Devices

Inside VMWare virtual machine Linux host, before shutting it down run:

mv /etc/X11/xorg.conf /etc/X11/xorg.conf.vmware

c) Remove Incomptable devices

To prevent issues with sound – its necessary to remove VMWare device created for soundcard, in order to let VirtualBox create its soundcard device on 1st boot after migration. To do so click on Virtual Machine and from context menu click Settings then in  Hardware tab select Sound Card and Remove:
 

Settings -> Hardware -> Sound Card (Click Remove)

vmware-migration-remove-soundcard-to-make-work-sound-work-in-virtualbox


4. Make a Clone (Backup) of Virtual Machine

Its always a good idea to create backup of VMWare VM to be migrated just in case something goes wrong during migration, so you have a way to step back to the already working one. Once files are copied it might be a good idea to use use some archiver like PeaZip or 7-Zip to save some disk space.
 

mkdir SomeFolder
copy Path_To_Virtual_Machine Folder_for_Backup_Virtual_Machine

 


In my case this was

 

 

mkdir \Temp\VMWare-machine-backup
C:\>copy "C:\Users\ggeorgi7\Documents\Virtual Machines\Debian 7"\ c:\Temp\VM
ware-machine-backup

Restoring later VMWare VirtualMachines in case of some failure is done by simply copying backuped files to VMWare Working Directory folder

In case if Wondering

Where is stored VMWare Virtual Machines?

 

Check in:
 

VM -> Settings -> Options


vmware-working-directory-folder-where-are-stored-vmware-virtualmachines

5. Use VMWare ovftool.exe to convert .VMX to Open Virtualization Format (.OVF)

 

Though export from .VMX to .OVF it can be also done from VMWare GUI from:
 

File -> Export to OVF

Anyways I think it is better to do it via OVFTool console tool:

The most common location for  VMWare Workstation is:
 

C:\Program Files (x86)\Vmware\Vmware Workstation\OVFTool


For VMware Player it is:

C:\Program Files (x86)\Vmware\Vmware Player\OVFTool

Very important thing to mention here is you have to be cautious, Never to run together VMWare and VirtualBox.
!! Before proceeding to next OVTool .vmx to .ovf migration Shutdown the VirtualMachine and as a best practice close VMware completely.

cd Location-directory-ofOVFTool
ovftool.exe Path-folder-to_VMVM_file.vmx Path-folder_to_VM_exportVM_file_export.ovf

C:\> cd "\Program Files (x86)\VMware\VMware Workstation"\OVFTool
C:\Program Files (x86)\VMware\VMware Workstation\OVFTool>ovftool.exe "\Users\ggeorgi7\Documents\Virtual Machines\Debian 7\Debian 7.vmx" C:\Users\ggeorg i7\vmware-debian-export.ovf

 

vmware-ovftool-convert-vmware-linux-virtual-machine-to-virtualbox


Convertion will take about 30 minutes on a normal computer hardware lets say (Dual Core PC 2Ghz with 4 Gb of RAM).
If you get a “failed to open disk” error during convertion, its likely that the virtual machine is still running or wasn’t shut down properly – boot the virtual machine and perform a shut down.

6. Launch VirtualBox, Install Guest Additions to enable Copy / Paste and USB support in Virtual Machine

After the process completes, you can boot the virtual machine. If you haven't earlier uninstalled vmware-tools  uninstall VMware Tools, and install VirtualBox’s Guest Additions (in order to allow Copy / Paste between VirtualBox and guess OS).
 

7. Launch VirtualBox and Import exported .OVF

Once Virtual Machine is exported, to import it into VirtualBox, launch VirtualBox and choose:
 

File -> Import Appliance


virtualbox-import-vmware-old-virtual-machine-to-new-linux import vmware appliance

virtualbox-import-vmware-previously-installed-virtual-machine-linux import appliance virtualbox
 

Create PDF file from (png, jpg, gif ) images / pictures in Linux

Tuesday, September 14th, 2010

I’ve recently received a number of images in JPEG format as a feedback on a project plan that was constructed by a team I’m participating at the university where I study.

Somebody from my project group has scanned or taken snapshots of each of the hard copy paper feedback and has sent it to my mail.

I’ve received 13 images so I had to open them one by one to get each of the Project Plan to read the feedback on the page this was really unhandy, so I decided to give it a try on how to generate a common PDF file from all my picture files.

Thanksfully it happened to be very easy and trivial using the good old Image Magick

In order to complete the task of generating one PDF from a number of pictures all I did was.1. Switch to the directory where I have saved all my jpeg images

debian:~# cd /home/hipo/Desktop/my_images_directory/

2. Use the convert binary part of imagemagick package to generate the actual PDF file from the group of images

debian:~# convert *.jpg outputpdffile.pdf

If the images are numbered and contain many scanned pages of course you can always pass by all the images to the /usr/bin/convert binary, like for instance:

debian:~# convert 1.jpg 2.jpg 3.jpg 4.jpg 5.jpg outputpdffile.pdf
Even though in my case I had to convert to PDF from multiple JPEG (JPG) pictures, convertion with convert is not restricted to convert only from JPEG, but you can also convert to PDF by using other graphical file formats.

For instance to convert multiple PNG pictures to a single PDF file the command will be absolutely the same except you change the file extension of the graphic files e.g.:

debian:~# convert 1.PNG 2.PNG 3.PNG 4.PNG 5.PNG OUTPUT-PDF-FILE.PDF

I was quite happy eventually to know Linux is so flexible and such a trivial things are able to be completed in such an easy way.

How to renew IP address, Add Routing and flush DNS cache on Windows XP / Vista / 7

Friday, November 25th, 2011

There are two handy Windows commands which can be used to renew IP address or flush prior cached DNS records which often create problems with resolving hosts.

1. To renew the IP address (fetch address from DHCP server) C:> ipconfig /release
C:> ipconfig /renew

In above cmd ipconfig /release will de-assign the IP address configured on all Windows LAN and Wireless interfaces, whether ipconfig /renew will send request for IP address to the DNS server.

To unassign and assign again IP address from DHCP server only for a particular LAN or WLAN card:

C:> ipconfig /release LAN
C:> ipconfig /renew LAN
C:> ipconfig /release WLAN
C:> ipconfig /renew WLAN

2. Adding specific routing to Windows

Windows has a Route command similar by syntax to Linux’s route command.
To add routing via a specific predefined IP addresses on Windows the commands should be something like:

C:> Route add 192.168.40.0 mask 255.255.255.0 192.168.41.253
C:> Route add 0.0.0.0 mask 0.0.0.0 192.168.41.254
The first command adds IP 192.168.40.0 in the network of 255 hosts to be routed via 192.168.41.253
The second one adds 192.168.41.254 as a default gateway for all outbound traffic from the Windows host.
To make permanent routing -p switch is used.
3. To clear Windows DNS cache (flush DNS cached records) C:> ipconfig /flushdns
This will clear all IP records corresponding to hostnames previously cached on the Windows host. Using ipconfig /flushdns is especially handy when IP address for a specific DNS host is changed. Flushing the Windows DNS cache can save us a lot of waiting before the domain example.com starts resolving to the new IP address let’s say 1.2.3.4 instead of the old one 2.2.2.2

Some priceless wireless stuff & my switch from wireless ipw3945 driver to iwl3945, how to make iwl3945 driver work much more decent

Thursday, September 10th, 2009

Since I upgraded to the latest Debian unstable I was forced to switch from the good old ipw3945 wireless driver to the newer one with which I had a bunch of unpleasent experienced, that was a good reason for me to kept myself back to the ipw3945. Anyways all my attempts to port the already 2 years old ipw3945 without a development to my 2.6.30-1-amd64 left void.Therefore I had to unwillingly switch to the iwl3945 driver. To do so I had to:
1. edit /etc/modprobe.d/00local.conf and remove the line

install iwl3945 /bin/true

2. edit /etc/modprobe.d/blacklist.conf and comment the line

blacklist iwl3945

3. edit /etc/modprobe.d/ipw3945.conf and comment out
install ipw3945 /sbin/modprobe –ignore-install ipw3945 ;
sleep 2 ; /sbin/ipw3945d –quiet
remove ipw3945 /etc/init.d/ipw3945d modprobe-stop && modprobe -r –ignore-remove ipw3945
4. edit /etc/udev/rules.d/70-persistent-net.rules and comment out
SUBSYSTEM==”net”, DRIVERS==”ipw3945″, ATTR{address}==”00:1c:bf:bd:24:59″, ATTR{type}==”1″, NAME=”wlan0″SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”00:1c:bf:bd:24:59″, ATTR{type}==”1″, KERNEL==”wlan*”, NAME=”wlan0″
5. Last but not least:
rmmod iwl3945; modprobe iwl3945;

That so far was required to switch from ipw3945 to iwl3945.

Unfortunately after the switch I was pretty unhappy of the behaviour of the iwl3945 driver.
Like for example the driver won’t detect many of the wireless networks during scan compared to the one detected by the old ipw3945 driver.
I googled and found in Google many contradictions considering which driver (ipw3945 or iwl3945) prooves to be better. Some praised ipw3945 and tended to hold unto it while others were proclaiming that iwl3945 works in a much better manner.
Again some Googling and thinking over the created problem led me to a website which suggsted a helpful tip on how to intialize
the iwl3945 driver. That tip IMPROVED A LOT! the scanning behaviour of the iwl3945 driver.
Here is the tip itself:
Edit /etc/modprobe.d/iwl3945.conf and add to it the following: alias wlan0 iwl3945# the line below disables iwl3945 wireless driver hardware scanningoptions iwl3945 disable_hw_scan=1# extend the network channels detected to 13options lbm_cw_cfg80211 ieee80211_regdom=EU

After all is done the only left thing is to:
reload the iwl3945 driver
rmmod iwl3945modprobe iwl3945
And Hooray! It works Again! You will notice now much more networks are being detected
and apart from that scanning returns results every time you scan for wireless networks
To conclude the post I’ll say a few words on the line:
options lbm_cw_cfg80211 ieee80211_regdom=EU
as well as explain briefly about wicdMany of you would wonder what is that about, well it’s about that on how many channels
would wireless networks be detected. For example in the European Union wireless networks
could be configured to work on channels up to 13, just to compare in the USA less channels
are available thus the default behaviour of the iwl3945 driver is not to detect wireless
networks on channels above 10 (I believe?). The above example communicates to the cfg80211 kernel
module that more wireless channels are available since we’re in the EU (European Union).
For kernels below version 2.6.24 you might need to use the variable:
options lbm_cw_cfg80211 ieee80211_regdom=EU instead of the one I add above.

.Well let me conclude the post with some handy wireless manager I use some time ago.
Longly I (suffered) with Gnome’s default gnome-network-manager, nevertheless it’s proven thatpain doesn’t waste forever.
Mine would not too:

I Googled just to know if there are Good alternatives to gnome-network-manager and I found the nifty Wicd manager. Which behaviour I like much more than the classicwifi-radar or gnome-network-manager.
This days I heavily use the nice Wicd peace of soft.
So in case if you still don’t have it installed on your GNU/Linux go for it!
If you want to give some credits for this I hope helpful post please give them to God :)END—–