Category: Ubuntu

  • MAAS 2.0 and DNS

    Hello everyone! Been a while since I wrote a blog entry. I updated my network topology last night to accommodate for guest access and to separate my personal network from my work network to keep my video game consoles and my cell phones off of my external facing network and firewall them up better for more security. I decided during this time as well to revisit my DNS and Virtual Host machines.

    I was running ESXi 6 on one of my hosts that ran Ubuntu VM’s for this site, and my email server, and a couple other servers that I use to do my job. It became a hassle to keep it up and running on older hardware so I upgraded it to KVM and Ubuntu 16.04 and I decided that I would also upgrade my VM’s from 14.04 LTS to 16.04 LTS since I had the downtime.

    Anyways, I decided that I was going to use MAAS, or Canonical’s Metal-As-A-Service to provision my KVM’s and also get rid of my aging DHCP/DNS server that was running 12.04 and just move everything to MAAS. Sounds easy enough? Not so much.

    Building the KVM host was easy. I installed Ubuntu 16.04, selected OpenSSH server and Virtual Machine Host from the TaskSel and then after it was installed, ran sudo apt update && sudo apt upgrade, rebooted, and then ran sudo apt install ovmf qemu and modified my /etc/libvirt/qemu.conf to point to where ovmf was (basically just removed the comments from the file for those settings) and than ran systemctl restart libvirt-bin and was ready to go. I also modified my NIC interfaces to bridges.

    Now I was ready to build my MAAS server. I build a KVM with 2GB of RAM and 2 processors and 60GB of storage and added 2 NIC’s, one for each of my networks, one for my servers and external network, and one for my internal guest network. I installed a clean 16.04 LTS server, added OpenSSH and configured the interfaces for static addresses and ran update/upgrade and now was ready to install MAAS. I ran sudo apt install maas and was off and running. After it was complete, I ran sudo maas createadmin to create the admin account. I then logged in to maas by opening Firefox and browsing to my maas servers IP address and logging in. I click on my account in the upper right corner and went to Account, and copied my API key to a file called maas.key in my home directory on MAAS so that when I need to use the CLI, I can just cat maas.key instead of having to type the whole damn thing in. I then copied all my SSH keys to my account so that I can access my new nodes with my SSH key, and I then went to the Images tab to make sure it was downloading the 16.04 image, and did some minor settings to make sure it seen all my networks and put in my DNS forwarders.

    Next, it was time to setup DHCP. I clicked on the Network tab and clicked on the subnet I wanted to have DHCP. I set a dynamic reservation for my internal network starting at .50 and going to .200. I then clicked my other subnet and did the same thing there. I then went back to the Network tab and clicked the VLAN for each of my fabrics. Under the Take Action button, I configured DHCP for this network and was ready to go.

    I built my webserver as a KVM, and told it to PXE boot and attach it to the server network bridge on my KVM host. I powered it up and boom! MAAS found it, and enlisted the node. I changed its name, but realized it was not using my DNS name, but instead the MAAS default of “maas.” According to Canonical’s documentation on MAAS, you can change this from the WebUI. That would be helpful to tell a user how, but I’m not going to go there. In 1.9, it was as easy as clicking the domain name on the Nodes tab, but in 2.0, not so much. I ended up changing it from the MAAS CLI by ssh’ing into my MAAS server and running the following command to login:

    maas login maas http://maas/MAAS `cat ~/maas.key`

    I then ran maas maas domain update name=lucaswilliams.net and verified that it was updated with maas maas domains read and in the MAAS WebUI, it updated it as well.

    I then clicked on my new node, and commissioned it. After 10 minutes, it was commissioned and ready for deployment. I deployed, which I have to say, is a huge improvement over 1.9. In the node tab, under Interfaces, I could statically set my IP address, which I did, and then I clicked deploy, and from the pull down said 16.04 and it was off. About 20 minutes go by, and it’s done. Now, I ssh into my new server and I can login with my SSH keys from my various workstations and it works. I then go through the process of installing LAMP on the server and getting WordPress configured and recovering my site from my backup. Then I notice that I don’t have my CNAME records to access my server via www or wordpress. I go into research mode. How do I add CNAME’s to MAAS 2.0 DNS? Great news, according to Canonical’s maas.io site, you can do this, but once again, they don’t tell you how. After spending hours doing Google-Fu and on freenode asking around, to no avail, I decided “Whats the worse that can happen?” I start poking through the MAAS source on the dnsresource flags and relize that there is an option in the MAAS CLI for dnsresource-records. I look into that and low and behold, it tells you there I can create A, AAA, CNAME, MX, SRV, NS and TXT records. So, through about 2 hours of trial and error, I finally figured it out:

    maas maas dnsresource-records create fqdn=www.lucaswilliams.net rrtype=cname rrdata=webserver

    It shown the record in the DNS tab in MAAS as well. I was able to ping the new CNAME and it responded properly. You are able to see this page as a result of it working as well.

    I did the exact same above steps for my mail server as well, however, I had to create a MX record for it since it was failing its install step doing an MX record lookup. Great, how do I do that? Luckily, after only an hour of trial and error, I figured it out:

    maas maas dnsresource-records create fqdn=lucaswilliams.net rrtype=mx rrdata='10 mail.lucaswilliams.net'

    It updated in the DNS tab in MAAS and I could see all of these with the MAAS CLI. I was also able to add static servers that were not commissioned by MAAS into DNS via the CLI with the following command:

    maas maas dnsresources create fqdn=hostname.lucaswilliams.net ip_addresses=ip.add.re.ss

    Anything that is DHCP assigned will populate DNS automagically.

    And there you have it, a way to add MX and CNAME records so that you don’t have to do the research, or if you Google search it, hopefully you fall here.

    Let me know in the comments if this helps you or not, and let me know what else you want to know about.

     

  • My replacement phone is here, so why do I miss my Ubuntu phone?

    Hello everyone! I had my iPhone stolen at a baseball game I went to on July 3rd. Because it was a Sunday, and the next day was a holiday in the United States, I was told I would get my replacement on Tuesday the 5th. I couldn’t wait that long to be incommunicado, so I went to Best Buy with my gorgeous girlfriend and she bought me a $IMG_1044 240 T-Mobile SIM card for my Ubuntu Phone. I plugged the SIM in and after going online to activate it, I had a working phone with unlimited text, calling and data. First thing I did, transfer all my contacts over to the Ubuntu Phone. Took a while since they were not in Google, so I had to convert the contacts from iPhone to Google, and then boom. I had them all.

    I also had to get used to the swipe motions. And I needed to update the phone. It was running OTA 9, which is what it updated to the last time I used this phone which was when I was in Spain for the Network Developers Conference back in February. So my phone updated to OTA 11, and, GPS broke. After reading online how to fix it, I had to flash my phone to another build. I did that, and now I had working GPS. Life is great again… sort of.

    So, I had to setup my email again, I used the Dekko Mail App that came on the phone to do that, which was quite easy to setup, in fact, it was easier on it than what I remembered on my iPhone mail app. Also, GMail was installed by default, so getting my work email was a snap, other than, I had no 2 factor authenticator for work. Luckily, Ubuntu has an app for that. In to my rescue came Authenticator, which all I had to do was work with our IS team to get me a temporary key, login and take a picture of my QR code on my screen with the app, and I was able to use it as my 2-factor device. So now I can use my phone for work and play and everything is all unicorns and cinnamon toast. Not quite. I needed an IRC app, which unfortunately, we don’t have Quassel as a client in our store. We have many other great options, which most I have used, but I have my own Quassel Core server and I just wanted to connect to that instead of connecting directly to our IRC servers. Plus I like looking back in the history to see what I may have missed of if my questions got answered by someone in another time zone while I was asleep.

    I figured, I would try to make it into an app and if it worked, upload it to the Ubuntu Store. So, after work yesterday, I downloaded the Ubuntu SDK IDE, took a crash course in CMake, and started working on porting just the Quassel Client to the Ubuntu phone. Needless to say, 6 hours later, and many beers, I had the code compiled for ARM, and it worked on ARM versions of Ubuntu, but I never could figure out how to make it into a Click package that the phone uses. I would have hacked on it some more, but then, today at 9:58am, my replacement iPhone came! So, I’m going to put this little side project on hold.

    So, I take my phone out, call Verizon using my Ubuntu Phone, which btw, works like a champ for everything else. Navigation, searching, Facebook, calls, texting, and best yet, you plug the phone into a monitor via the microUSB cable and connect a bluetooth keyboard and mouse to it, you have a desktop computer running Ubuntu Touch. BAD M$%^&ER F#@!%ING ASS!! That was by far, the coolest feature I had on this little Nexus 4 phone. My computer was in my pocket! I digress however, back on to my new iPhone. I get it, plug it in to my Mac, and it starts restoring my phone. 2 hours go by, it is finally done restoring, and updating everything and it is working like I never lost it. However, just in the 4 days I was using my Ubuntu Phone, I forgot how to use an iPhone! I got so used to swiping left to switch between running apps, to kill thIMG_4410em, swipe them up (which, in my opinion, I think Apple stole from Ubuntu since they did it first… just sayin’), and then I could get to my Dock by swiping right and all my favorite apps are there, messaging, email, navigation, phone, calendar, the App Store, Scopes, which is what the main screen is on the Ubuntu phone. All my m
    edia, movies, interests, what is going on around me, all on my home screen for meto scroll through.

    So, what am I getting at? Well, I IMG_2839have to say, and not because I’m paid to, I actually am going to miss the Ubuntu Phone. I will still have it, and use it for testing and when I go over seas on trips since it works better then having to get a new SIM for my iPhone and having to have it unlocked for it to work, but I may actually flip for a new Ubuntu Phone when my contract with Verizon on my iPhone expires. It worked great as an emergency phone so that people could get a hold of me, and so I could keep in contact with friends and family. I’m hoping that by 2018, the Ubuntu phone matures, and hopefully will be available in the United States by a major carrier, but if not, I’ll definitely buy the phone, put a SIM in the phone and if the app doesn’t exist for it yet, I’ll build it.

    Lates all, I’m going to put my Ubuntu Phone back in its case until it comes to my rescue again.

  • SwitchDev in Ubuntu-Core? Yes Please!

    Hello fellow Snappy and Networking enthusiasts. Welcome to my next blog post. This post is mostly to go over building SwitchDev into the Snappy Kernel using the latest kernel. It’s fairly straight forward if you have read my blog entry on how to build a custom kernel snap. I will touch on that a little here as well as go into some things I ran into during the initial build of this.

    First things first, make sure you are running on Ubuntu 16.04 with the latest updates and snapcraft (sudo apt install snapcraft -y), and do the necessary updates:

    sudo apt update && sudo apt upgrade -y

    One thing I did differently that I did in my previous kernel snap post (Success in building a Kernel Snap in snapcraft 2.8.4) is instead of downloading the kernel source from Ubuntu, I got the latest and greatest kernel from Kernel.org, (4.7.0-RC5) but I also had snapcraft download it via git and build. I also didn’t create a kconfigfile like last time, but instead, used the kbuild mechanism to run make defconfig and make oldconfig for me so that it was up to date. I’ll explain how I did this.

    The first thing I did was create a directory to work in called switchdev. mkdir ~/switchdev. I then copied my kernel config from my workstation, and name it 44.config. cp /boot/config-`uname -r` ~/switchdev/44.config

    I then changed my directory to cd ~/switchdev and ran snapcraft init to build the initial snapcraft.yaml file. I then modified the snapcraft.yaml file so it looked like the following:

    name: switchdev-kernel
    version: 4.7.0-RC5
    summary: SwitchDev Custom Kernel
    description: Custom Kernel for Snappy including SwitchDev
    type: kernel
    confinement: strict
    parts:
      kernel:
        plugin: kernel
        source: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        source-type: git
        kdefconfig: [defconfig, 44.config]
        kconfigs:
          - CONFIG_LOCALVERSION=-snappy"
          - CONFIG_DEBUG_INFO=n
          - CONFIG_SQUASHFS=m
          - CONFIG_NET_SWITCHDEV=y
        kernel-initrd-modules:
          - squashfs
          - ahci

    I then ran snapcraft pull . I ran pull because I have to put my 44.config in the kernel/configs directory so that make oldconfig has something to go against, and I have all the required drivers and modules for a stock Ubuntu kernel.

    By putting my 44.config and using defconfig, the kdefconfig parameter and the kconfigs parameter will be run to create an initial .config. Then the kernel plugin runs "yes" "" | make oldconfig to have an updated .config for building the kernel. So by pulling in all the files, I can then copy 44.config to the correct location:

    cp 44.config parts/kernel/src/kernel/configs/

    I then run snapcraft and grab something to snack on since it will take about an hour to build the kernel snap.

    Once completed, I have a kernel snap named switchdev-kernel_4.7.0-RC5_amd64.snap. I then run this kernel snap through the ubuntu-device-flash application to create a Ubuntu-Core image that I can then install onto a switch. You have to use the ubuntu-device-flash from people.canonical.com/~mvo/all-snaps/ubuntu-device-flash and make it executable (chmod +x ubuntu-device-flash)so that you can run this. You also need kpartx installed (sudo apt install kpartx) on your machine since it uses that to build the image. Once you have all of this, simply run:

    sudo ./ubuntu-device-flash core 16 --channel=edge --os=ubuntu-core --gadget=canonical-pc --kernel=switchdev-kernel_4.7.0-RC5_amd64.snap -o switchdev.img

    After that completes, burn your image onto your switch by either running it through your ONIE installer package creation tool, or by using dd or whatever other method for getting an Operating System on your whitebox switch.

    One thing I noticed once the system came up, was that none of the ports lined up with what the devices were called. Some were called eth0 to eth35, with some missing in between. Some were called renamed7-14, and one was named sw1_phys_port_namex. To fix this so that I could program the switch properly, I had to create a udev rules file. First thing I had to do was get the switchid. To do this, I ran

    ip link show eth8 | grep switchid

    and the value after switchid was what I needed. I then created /etc/udev/rules.d/10_custom.rules and put the following in:

    SUBSYSTEM=="net", ACTION=="add", ATTR{phys_switch_id}=="switchid", ATTR{phys_port_name}!="", NAME="sw1$attr{phys_port_name}"

    I saved the file and then rebooted the switch and when it came up, all the front panel ports were named sw1p1-sw1p32. I could then use the ip command to manage the ports on the switch and even set static routes and move packets around.

    Let me know how it goes for you and leave a comment if you need help!

    Thanks!

    [ayssocial_buttons id=”2″]