Browsed by
Tag: Linux

Setting up VPN on ubuntu 19.10 and getting DNS to work correctly

Setting up VPN on ubuntu 19.10 and getting DNS to work correctly

A bit late to post this? May be. But it is still relevant, so here goes. We shall see how to setup openvpn client on Ubuntu versions greater than 18.10 (or was it 18.04?) It certainly matters for 19.10 though!

A few things changed back then that caused issues in openvpn connection and DNS resolution. There was a fix found, and package released bundling the scripts so that normal users like us can install and enable those scripts. This solved the CLI problem. But I personally, do not like the idea of having to run a sudo command every time I need to use VPN and keep a terminal running. I like the flexibility Network Manager gives and also the fact that it nicely indicates with an icon if I am connected to VPN or not.

But to achieve this setup, a few steps are required:

  • Download your ovpn config file. This might require you to login to your OpenVpn server and download the ‘autologin’ config file.
  • Run this command: apt install openvpn-systemd-resolved. This will install the packages / scripts required to handle DNS resolution on VPN.
  • modify your ovpn file, add these lines before ca certs and after setenv:
    script-security 2
    up /etc/openvpn/update-systemd-resolved
    down /etc/openvpn/update-systemd-resolved
    down-pre
  • At the end of the file, after all certs and everything, add: dhcp-option DOMAIN-ROUTE .
    (note the “dot” in the command above.)
  • Connect to vpn using command: sudo openvpn --config <path to modified config file>

We have now achieved the basic setup, you can stop here. Just open terminal when you need to connect to VPN and run the above command; press Ctrl+C to disconnect from VPN. To integrate with Network Manager, follow through next steps:

  • We now need to import this file into Network Manager and use Network Manager UI to connect/disconnect from VPN.
  • Install sudo apt install network-manager-openvpn-gnome. Even if you are running KDE, the same command works.
  • Next, run this command to import the config file: sudo nmcli connection import type openvpn <modified config file>
  • This should bring a new network in your Network Manager Settings UI, under VPN header. The name of the connection will be same as the name of the file.
  • If this is a work VPN, which means you will need to use this VPN for connecting to work machines only, and rest of the traffic should go outside of VPN. To enable this, go to IPV4 settings, and select ‘Use this VPN for resources on this network only’. On most work VPNs, if you do not enable this, you will lose ability to use anything other than vpn servers, even google wont work.
  • Now the next, tricky part. This sets us up for most of the things, but in my experience DNS servers still do not resolve properly. To enable DNS resolution via Network Manager, in IPV4 settings of the VPN network add “~.” (without quotes) as search domain. In my experience, without the ~. as search domains, the DNS resolution did not work.

This is it. The benefit is a built in, native, visual representation of VPN connectivity right on your System Tray!

Mute Mic With Keyboard Shortcut On Ubuntu Or Linux Mint

Mute Mic With Keyboard Shortcut On Ubuntu Or Linux Mint

Here is a quick tip for all the automation buffs like me. Turn your mic on and off with just a keyboard combo.

I do all my work remotely. Which is also to say I have a lot of conference calls. And like you, I hate it when people do not mute their phones / mic on laptops when not speaking! (cue in the obligatory meme about not putting your phone on mute during a call!)

I always wished for a hotkey of some sort to mute / un-mute myself during a call. So here is a way to do it.

  1. Use a Linux machine. (This in itself is a great tip! 😉 ) These steps in particular are for an Ubuntu / Linux Mint machine.
  2. Put the following snippet in a bash script file and add it to path. You can also define it as a bash alias and load it from your custom bash profile, but then assigning it a shortcut may not be that easy.
  3. Set a keyboard shortcut to trigger this script. I use Meta+M for this.

Here are the two variants of the script for that:

This script toggles mic state, shows a nice (transient) notification of the changed state, with an intuitive icon! It should also replace previous notification quickly, but somehow it does not seem to work yet.

(cue in the meme about speaking on mute! ;))

Update for fellow KDE users

KDE, the amazing DE that has some of the best customizations already have a configurable action to mute mic, it just does not have a default shortcut.

Just go to System Settings –> Shortcuts –> Global Shortcuts –> Audio Volume. Choose option “Mute Microphone” and set the “Global Alternate” to your shortcut of choice! Done! No script needed!

Cinnamon Crashed, would you like to restart?

Cinnamon Crashed, would you like to restart?

I have been a fan of the Cinnamon DE for years. I like the way it looks and stays out of my way when I am not admiring it and actually doing something useful! But it is somewhat buggy.

This is a quick post about the cinnamon crashes, basically a new reason for it to crash. I was faced with a common issue of cinnamon crashes, suggesting me to restart cinnamon, which when clicked yes resulted in another crash and popup.

Google searches resulted in many solutions, starting with updating cinnamon, resetting the config by deleting the .cinnamon and .local/share/cinnamon directories and verifying if the correct video driver is in use. There was nothing obvious in the syslog, or xsession errors. Nothing helped.

Tired, I reinstalled mint but issue persisted. This was rather peculiar. I mount my home separately, and that of course survives the installs and OSes. This was the first hint at the problem, issue was configuration of something, not necessarily of cinnamon. So I created a new user and tried to login with the user, and voila, cinnamon worked without a crash. So certainly the issue was config for my regular user.

I decided to go about removing related config folders, and the first ones I chose was the gtk-3.0, gtk-2.0 and cinnamon-session directory inside .config directory. And to my luck, cinnamon is working just fine since then.

Probably, I should spend some time to check what exactly from these config was the issue. But at least I now know one more reason why this error might occur and one more way to fix it. And now, you too..!

Creating a Local Version Control System

Creating a Local Version Control System

Now this is a post that is going to be updated time and again.. The very post that made me abandon my previous blog to move on to a Google site..

Requirement:
Need to setup a local repository.. a version control system.. Given that I use VSS (I know, please dont make faces..!) at my work place, I am used to the ‘ease’.. However it may be, it sure is simple to use…! I need the repository to be platform independent, as I dual boot into Windows 7 and Ubuntu, secondly need it to be local.. Now thats the background, next is a journal…
Which one to use?
Tried:
CVS: on Ubuntu 11.4 and on windows 7.. dint find it so impressive..
TortoiseCVS: Dont know why but the options in the context menu never appeared…! :S
Mercurial: confused about its use.. yet to be tried..
Trying out git.. many friends suggest this.. seems interesting.. simple to learn, they say.. lets see!
Git setup
Alright, what helped me understand it whole was two great articles, one form tiredblogger and another from a harvard site.
Do go through them both… (And you don’t have to read this page any further! 🙂 )
Rest is for my reference, for my own understanding..
It was simple to setup..
Download and install git from the ubuntu download center… Download and install git for windows from Google code project.. Done.. Both OS set.
In windows, left almost all settings unchanged during installation..
All I need to do is to create a bare repository to start with, its better they say.. so
in a new folder:

git init --bare

Then clone it into a new repo.. That’s the working folder I guess…
so..

git clone <prev folder> <new folder name>

Done..
Then create and add new file to this new folder.. Thats the first source file..
Then, add it to repo..

git add .

Commit the repo..

git commit -a -m "a message"

Push the updates to the main repo, which would otherwise have been a remote repository, the original one from which the working was cloned.

git push origin master

Cool enough.. Lets try new things..

Working on multiple OS
The local repository cant be directly used from both the OS.. so What I am gonna have to try is to work as if I am 2 different persons contributing to a project.. haven’t very well understood it all yet! lets see…!

Change only the origin url!

Alright.. Now, all I need to do is change only the path / url in the git config file for the head origin! Once done, the push was fine…! 🙂 so…
Is there a way to avoid this manual work???
like having 2 origins? remotes I mean..
In manual it is said that the remote path can also be passed from a file in $GIT_DIR/remotes
But does that create new branches? If so, that’ll clutter the repository unnecessarily…
lets see…

This post will be updated as and when I learn new things..!

Eclipse: Same Workspace in windows and linux

Eclipse: Same Workspace in windows and linux

I believe almost all dual booters wish for something like this.. The eclipse workspace should be independent of the operating system they are logged in..! well.. I have found a way to do it..

Issue:
    The problem with using the same workspace is that ‘it doesn’t work!’ 😀 well.. the configuration of a workspace is stored in .metadata folder inside the working directory.. it has all the paths.. Most importantly, the path to JRE/JDK..! If a workspace from Windows is opened in Linux/ubuntu the java projects wont compile cause of the build path issues.. If you set it right in ubuntu, it wont work in windows..

Solution:
Well..One of the solutions that works or at least worked for me is:
    Having 2 ws with all projects pointing to an external folder..!

There may be other solutions, but this is how it is done:
    Say you have a workspace under windows, now you need it to work under ubuntu..
Well.. leave alone the original workspace.. Create a new one and ‘import’ the projects from the original one.. What needs to be taken care of is: dont copy them to their default locations, that is the new workspace… You can also choose to copy the layout and other settings as well.. That way the projects will still be in the original workspace, pointed to from your new one, with all your operating specific data stored in the new workspace..! Works! You can do this for the Windows as well, keeping the ‘projects folder’ completely independent..

Problems with the approach:
The problem with this approach is that when you create a new project you need to be careful to create it in the original workspace i.e. where all other projects are.. Thats not all that difficult.. And even if you forget once, you can copy this project to the central projects location! Simple…?

What did I try it with:
Windows 7 & Ubuntu 10.10 & 11.4.
Eclipse 3.6.2 Helios

Thats it.. And you have the OS independent Workspace!! 🙂