Showing posts with label xenserver. Show all posts
Showing posts with label xenserver. Show all posts

Monday, January 30, 2017

Using tcpdump to see vlan traffic in xenserver

Short version: it is a bit convoluted, bordering into the Rube Goldberg domain.

If you are in a hurry, you can now move onto something more interesting. If you instead want to hear me ranting and typing annoying commands, read on.

If we talking about building servers to virtualize hosts, we will end up talking about multiple networks organized in vlans which then need to be fed to this vm server. Of course running a 802.1q trunk sometimes does not work perfectly, so we need to be prepared to look behind the curtain. If the vm server is running Linux, like if it was running KVM or Xen, we can unleash tcpdump just like we did when trying to diagnose some trunking issues with a router. What about the Xenserver you mentioned in the title of this article? I thought it was Linux based. Good question. Very good question. I started this assuming it would be just Linux business as usual. You know what they say about assuming.

What I found out is that you cannot just use eth0.12 if you want to look for vlan 12 like you would do in KVM. In fact, it does not use /proc/net/vlan. It just ain't there

[root@thexen ~]# ls /proc/net/
anycast6      ip6_flowlabel        netfilter            route         tcp
arp           ip_conntrack         netlink              rpc           tcp6
dev           ip_conntrack_expect  netstat              rt6_stats     udp
dev_mcast     ip_mr_cache          nf_conntrack         rt_acct       udp6
dev_snmp6     ip_mr_vif            nf_conntrack_expect  rt_cache      udplite
fib_trie      ip_tables_matches    packet               snmp          udplite6
fib_triestat  ip_tables_names      protocols            snmp6         unix
icmp          ip_tables_targets    psched               sockstat
if_inet6      ipv6_route           ptype                sockstat6
igmp          mcfilter             raw                  softnet_stat
igmp6         mcfilter6            raw6                 stat
[root@thexen ~]#

You see, there is no eth0.12 defined here; by default xenserver will try to configure all available network cards (NICs for those craving for acronyms) in a managed (by xenserver) mode. Once they are added, it creates bridges, called xapiN, and then associates them with each network. And how do we find out which of those bridges is being used by our vlan? Er, it requires a few steps using the xen commands (xe something-or-another) which I have not found out how to automate yet.

  1. We begin by finding out which vlans are defined in this server. And that can be done using xe pif-list:
    root@thexen ~]# xe pif-list
    uuid ( RO)                  : 540f3b24-0606-6380-c10c-c2f8c2f4c2ce
                    device ( RO): eth1
        currently-attached ( RO): true
                      VLAN ( RO): 2
              network-uuid ( RO): a874cb50-1c87-0bde-390d-66d0a4e1576c
    
    
    uuid ( RO)                  : 8684e63f-3d1c-241b-8e75-3b2e37f8c859
                    device ( RO): eth0
        currently-attached ( RO): true
                      VLAN ( RO): -1
              network-uuid ( RO): ed2325c5-1f3b-7f25-6104-61902a13d3ac
    
    
    uuid ( RO)                  : 82b9dee1-52db-a6ae-cb42-11ae7f6d3d25
                    device ( RO): eth1
        currently-attached ( RO): true
                      VLAN ( RO): -1
              network-uuid ( RO): 993c9237-5961-9808-36cd-729827e005d8
    
    uid ( RO)                  : 592339bf-cc03-4048-9075-946f5bcc47fb
                    device ( RO): eth1
        currently-attached ( RO): true
                      VLAN ( RO): 12
              network-uuid ( RO): 0d28f847-3da6-11f3-3600-8a033435168c
    
    
    uuid ( RO)                  : 3d60399c-bb8d-5e5a-e01b-8986b8808f12
                    device ( RO): eth0
        currently-attached ( RO): true
                      VLAN ( RO): 3
              network-uuid ( RO): c8726e09-a0a5-b026-013e-2c5edd5062b3
    
    
    uuid ( RO)                  : 19f1fe37-16d1-6fcd-4bbd-4e566abc74c4
                    device ( RO): eth0
        currently-attached ( RO): true
                      VLAN ( RO): 8
              network-uuid ( RO): 2f94b1c8-be16-14d5-a149-90ae35528c22
    
    
    uuid ( RO)                  : 6df7b741-9cef-d34f-e487-fa2abe422068
                    device ( RO): eth1
        currently-attached ( RO): true
                      VLAN ( RO): 100
              network-uuid ( RO): 9ec62435-ec2a-2bfc-9f29-2ea5c9756971
    
    
    [root@thexen ~]#

    What can we gather from this output:

    • This machine has 2 physical interfaces, eth0 and eth1. And each of them have a few vlans groing through them. So, there are two 802.1q trunks. Deal with it.
    • We have two uuid entries per interface uuid (the one after "uuid ( RO) ") and a network-uuid.
    • If we only wanted to see the VLAN number, both the uuids, and the physical NIC/device each virtual interface is using, we could have instead said
      xe pif-list params=device,VLAN,network-uuid,uuid

      But if we wanted to know everything about each virtual interface,

      xe pif-list params=all
    • To get more info on a giver interface (or bridge) you need the uuid associated with uuid ( RO). So if you wanted to know everything about VLAN 100, you could say
      xe pif-list uuid=6df7b741-9cef-d34f-e487-fa2abe422068 params=all
    • The ones with VLAN ( RO): -1 are the untagged networks; we have one per interface even if we do not have it defined.
OK< smart guy, how do we go from this to this crazy xapiN interface? Oh, you mean what xenserver calls a bridge? We shall use the xe network-list command. If you run that, it will give back which xapiN is associated with which vlan. It will also show which bridge is being used for the console to this xenserver, which usually is an untagged vlan. There are ways to make that a tagged vlan but that will be for another episode. What is important is the uuid being shown is the network-uuid we got using xe pif-list. And, we can feed it to the network-list command if we just care about, say, VLAN 12:

[root@thexen ~]# xe network-list uuid=0d28f847-3da6-11f3-3600-8a033435168c params=bridge,name-label
name-label ( RW)    : vlan 12
        bridge ( RO): xapi4


[root@thexen ~]#

We finally found out that vlan 12 is attached to xapi4. Time for some tcpdumping:

[root@thexen ~]# tcpdump -i xapi4 -e
tcpdump: WARNING: xapi4: no IPv4 address assigned
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on xapi4, link-type EN10MB (Ethernet), capture size 65535 bytes
^C
0 packets captured
0 packets received by filter
0 packets dropped by kernel
[root@thexen ~]#

Crickets

What is going on here? I let it run for 10s; that should have been enough to fill the screen. Let's try again, letting it run for longer 94 minutes?) while we do, say, tracepath to the gateway.

[root@thexen ~]# tcpdump -i xapi4 -e -n
tcpdump: WARNING: xapi4: no IPv4 address assigned
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on xapi4, link-type EN10MB (Ethernet), capture size 65535 bytes
10:46:10.696176 c0:ff:ee:70:63:a4 > Broadcast, ethertype ARP (0x0806), length 42
: Request who-has 192.168.12.241 tell 192.168.12.242, length 28
10:46:11.698310 c0:ff:ee:70:63:a4 > Broadcast, ethertype ARP (0x0806), length 42
: Request who-has 192.168.12.241 tell 192.168.12.242, length 28
10:46:12.700355 c0:ff:ee:70:63:a4 > Broadcast, ethertype ARP (0x0806), length 42
: Request who-has 192.168.12.241 tell 192.168.12.242, length 28
10:46:13.705644 c0:ff:ee:70:63:a4 > Broadcast, ethertype ARP (0x0806), length 42
: Request who-has 192.168.12.241 tell 192.168.12.242, length 28
10:46:14.706364 c0:ff:ee:70:63:a4 > Broadcast, ethertype ARP (0x0806), length 42
: Request who-has 192.168.12.241 tell 192.168.12.242, length 28
10:46:15.708375 c0:ff:ee:70:63:a4 > Broadcast, ethertype ARP (0x0806), length 42
: Request who-has 192.168.12.241 tell 192.168.12.242, length 28
10:46:18.710913 c0:ff:ee:70:63:a4 > Broadcast, ethertype ARP (0x0806), length 42
: Request who-has 192.168.12.241 tell 192.168.12.242, length 28
[...]
: Request who-has 192.168.12.241 tell 192.168.12.242, length 28
10:46:30.724414 c0:ff:ee:70:63:a4 > Broadcast, ethertype ARP (0x0806), length 42
: Request who-has 192.168.12.241 tell 192.168.12.242, length 28

^C
15 packets captured
15 packets received by filter
0 packets dropped by kernel
[root@thexen ~]#

Fifteen packets in four minutes? I could have done that by hand! What is going on here?

But it really does not work as well as it should

Do I sound bitter? I am just being factual. I can't use tcpdump when this bridge thing is only giving me like 4 packets a minute. Even if there was no talkign between servers, just the ARP requests should have been more often. So, we need to rething this.

We did the proper thing so far. Now it's time to cheat.

We know the network associated with vlan 12 is 192.168.12.0/24, so why not tell tcpdump to look at eth1 for anything that matches that?

tcpdump -i eth1 -e -n | grep '192.168.12'

I will not bother to show the output of that but it will look much more like what we would have expected. Of course, it will only get traffic in that wire matching that pattern so if you have a host trying to reach out for a dhcp server in that network you will not detect that. Nor it would find IPv6 traffic (you would need to feed the proper pattern). But, it is better than using xapi4.

Thursday, October 01, 2015

Adding (local) storage in XenServer

Lets start by getting something straight: This is not something that is normally done in an environment that has a cluster of XenServer servers. In those, you are probably using some kind of external storage line a SAN which feeds LUNs to the servers. But, there are those who did not setup their clusters like that for whatever reason -- cost, space, resources -- and as a result built their xen servers with local storage for the vm clients. Or maybe they just have one single xen server. For those this might be a bit useful.

Note: As usual most of this to be done in command line; if you have read my previous articles you would expect nothing less from me. I am just not that original; just deal with it already.

For this example, let's say you bought a server with lots of drive bays (say, 15), a nice raid controller that is supported by XenServer. And you got it running by creating, say, a RAID1 array using two small drives to install the OS. And they happen to have enough free disk space to build a few test vm clients. This server shall henceforth be called vmhost3.

Note: If you had built a Linux box and then installed Xen on the top of it, like RedHat used to recommend before they switched to KVM, this is much easier because you can use the usual LVM commands. Since we are using XenServer things are conceptually the same but the implementation slightly different.

So you built a few test vm clients and verified all is nice and peachy. I mean, even your VLAN trunks work properly. So, now it is time to go into production.

  1. You used 2 drive bays to put the OS on; you still have 13 left to play. So, you grab, say, 6 SSDs and make a nice RAID6 out of it. I will not go in details here because it is out of scope of this discussion, but I can write another article showing how to create the new RAID from command line in xenserver. Let's just assume you did it and it works.
  2. Xenserver by default creates local storage for vm clients by using LVM: it allocates a logical volume (lv) as the drive(s) for those clients, which then format them to whatever filesystem they want. So, we need to grab the drive created by the RAID6 and then configure it to do some LVMing. Every journey starts with the first step, and in this case that is to take a quick look at the drive we created when we did the raid; I will save you some time and tell you it is called /dev/sdc:
    [root@vmhost3 ~]# fdisk -l /dev/sdc
    
    Disk /dev/sdc: 1999.8 GB, 1999844147200 bytes
    255 heads, 63 sectors/track, 243133 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    
    Disk /dev/sdc doesn't contain a valid partition table
    [root@vmhost3 ~]#

    Yes, our drive is not that large, but it will be good enough for this example.

  3. Before we start passing LVs out like farts we need a lvm physical volume(pv). We could create a single partition in sdc that is as big as the disk, or just make the entire drive as the pv. I will do the latter.

    Do you remember my warning about XenServer vs Linux+Xen? This is where things diverge a bit. In the latter we would do something like

    pvcreate /dev/sdc
    vgcreate data /dev/sdc

    To create the pv and a volume group (vg) called data, but since this is XenServer, we should use their command line thingie, xe:

    [root@vmhost3 ~]# xe sr-create name-label=data shared=false \
    device-config:device=/dev/sdc type=lvm
    f70d9ff8-3567-ef23-42c2-7c7997a4abc6
    [root@vmhost3 ~]#

    which does the same thing, but tells xenserver that it has a new local storage device:

  4. From here on, it is business as usual./

Tuesday, September 29, 2015

Installing Dell's OpenManage Server Administrator (OMSA) so we can find info about server

We have a Dell server we need to find some info about. We could just go to the server room with a flashlight and get its Chassis Service Tag (fancy name for serial number?), model number, and so on. But, this is a proper rackmount server; we should be able to do that remotely.

And we can. Normally that is done using the iDRAC interface, which is a glorified single board computer in a card stuck on the back of the server running a little webserver we can use to configure the server, install OS, and other common housekeeping. Problem is in this particular box we never bothered to run an ethernet cable to it. But, we can ssh into the server; can we do the same from there?

Actually we can, but we need to get some Dell packages first.

NOTE: This server happens to be running a release of xenserver. Other than it tying down package versions, we should not have any other problems. But, should is a funny word...

Getting OMSA

Dell offers two websites,

If we run the bootstrap.cgi, it should add the dell repo for us:

[root@xenbox ~]# wget -q -O - http://linux.dell.com/repo/hardware/latest/bootstrap.cgi | bash
Downloading GPG key: http://linux.dell.com/repo/hardware/latest/RPM-GPG-KEY-dell
    Importing key into RPM.
Downloading GPG key: http://linux.dell.com/repo/hardware/latest/RPM-GPG-KEY-libsmbios
    Importing key into RPM.
Write repository configuration
Downloading repository RPM
[root@xenbox ~]#

Let's check:

[root@xenbox ~]# ls /etc/yum.repos.d/
CentOS-Base.repo       CentOS-Media.repo  Citrix.repo
CentOS-Debuginfo.repo  CentOS-Vault.repo  dell-omsa-repository.repo
[root@xenbox ~]#
dell-omsa-repository.repo is the repo file added when we ran bootstrap.cgi ( Citrix.repo is the xenserver repo as it is owned by Citrix).

Let's install the required package:

[root@xenbox ~]# yum install dell_ft_install
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
citrix                                                   |  951 B     00:00
http://linux.dell.com/repo/hardware/latest/platform_independent/rh50_64/repodata/repomd.xml: [Errno 14] HTTP Error 404: Not Found
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: dell-omsa-indep. Please verify its path and try again
[root@xenbox ~]#
Er, it does not look very happy. What is wrong? And why does it say rh50_64? That makes me think it wants RedHat 5.0; that is pretty old. We are in 2015 after all. Don't know. In any case, http://linux.dell.com/repo/hardware/latest/platform_independent/rh50_64/ exists. But no repodata dir. The repo config file looks like this
[root@xenbox ~]# cat /etc/yum.repos.d/dell-omsa-repository.repo
[dell-omsa-indep]
name=Dell OMSA repository - Hardware independent
type=rpm-md
mirrorlist=http://linux.dell.com/repo/hardware/latest/mirrors.cgi?osname=el$releasever&basearch=$basearch&native=1&dellsysidpluginver=$dellsysidpluginver
gpgcheck=1
gpgkey=http://linux.dell.com/repo/hardware/latest/RPM-GPG-KEY-dell
    http://linux.dell.com/repo/hardware/latest/RPM-GPG-KEY-libsmbios
enabled=1
failover=priority
bootstrapurl=http://linux.dell.com/repo/hardware/latest/bootstrap.cgi


[dell-omsa-specific]
name=Dell OMSA repository - Hardware specific
type=rpm-md
mirrorlist=http://linux.dell.com/repo/hardware/latest/mirrors.cgi?osname=el$releasever&basearch=$basearch&native=1&sys_ven_id=$sys_ven_id&sys_dev_id=$sys_dev_id&dellsysidpluginver=$dellsysidpluginver
gpgcheck=1
gpgkey=http://linux.dell.com/repo/hardware/latest/RPM-GPG-KEY-dell
    http://linux.dell.com/repo/hardware/latest/RPM-GPG-KEY-libsmbios
enabled=1
failover=priority
bootstrapurl=http://linux.dell.com/repo/hardware/latest/bootstrap.cgi
[root@xenbox ~]#
It looks like any repo config file out there. How is it guessing the OS release is 5.0-something? When I look at the release file
[root@xenbox ~]# cat /etc/redhat-release
XenServer release 6.5.0-90233c (xenenterprise)
[root@xenbox ~]#
OK, notice it says XenServer and not CentOS. It just hit me: what is the centos release associated with the XenServer release 6.5.0-90233c? Let's cheat
[root@xenbox ~]# yum provides /etc/redhat-release
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
10:centos-release-5-10.el5.centos.x86_64 : CentOS release file
Repo        : installed
Matched from:
Other       : Provides-match: /etc/redhat-release

[root@xenbox ~]#
Yeah... xenserver is running on centos 5.10. Lovely. At least now we know the issue. Also, according to a thread in the Dell forum, we need to go back in time we version of the bootstrap.cgi script,
wget http://linux.dell.com/repo/hardware/Linux_Repository_14.12.00/bootstrap.cgi
and try again
yum --enablerepo=base install srvadmin-all
which this time will install properly. So, let's use it.

Using OMSA

Binaries as installed in /opt/dell/srvadmin/bin/, and we want to use /opt/dell/srvadmin/bin/omreport:

[root@xenbox ~]# /opt/dell/srvadmin/bin/omreport chassis fans
Error! No fan probes found on this system.

[root@xenbox ~]# /opt/dell/srvadmin/bin/omreport chassis temps
Error! No temperature probes found on this system.

[root@xenbox ~]# /opt/dell/srvadmin/bin/omreport chassis processors
Error! Hardware or feature not present.

[root@xenbox ~]# /opt/dell/srvadmin/bin/omreport chassis remoteaccess
Error! Hardware or feature not present.

[root@xenbox ~]#
Why is it not working? Let's cut this story short: we need to start the services associated with OMSA:
[root@xenbox ~]# /opt/dell/srvadmin/sbin/srvadmin-services.sh start
Starting Systems Management Device Drivers:
Starting dell_rbu:                                         [  OK  ]
Starting ipmi driver:                                      [  OK  ]
Starting snmpd:                                            [  OK  ]
Starting Systems Management Data Engine:
Starting dsm_sa_datamgrd:                                  [  OK  ]
Starting dsm_sa_eventmgrd:                                 [  OK  ]
Starting dsm_sa_snmpd:                                     [  OK  ]
Starting DSM SA Shared Services:                           [  OK  ]

Starting DSM SA Connection Service:                        [  OK  ]


[root@xenbox ~]#
And now, it works!
[root@xenbox ~]# /opt/dell/srvadmin/bin/omreport chassis info
Chassis Information

Index                                    : 0
Chassis Name                             : Main System Chassis
Host Name                                : xenbox
iDRAC7 Version                           : 1.57.57 (Build 4)
Lifecycle Controller 2 Version           : 1.4.2.12
Chassis Model                            : PowerEdge R320
Chassis Lock                             : Present
Chassis Service Tag                      : AD92C42
Express Service Code                     : 24612345426
Chassis Asset Tag                        : Unknown
Flash chassis identify LED state         : Off
Flash chassis identify LED timeout value : 300

[root@xenbox ~]#
Next step is using openmanage to create a raid; we will do that in another article.