Wow, talk about a crappy post title, but I just got this working on my corporate network and was quite happy about it.
Reason for this post; Every time I start a new assignment at a (rather big) corporation, I need to follow these steps to be able to access the internet from my vm’s.
(and I keep forgetting the steps, I’m getting old..)
What we’ll use to get this working:
- Cygwin : https://www.cygwin.com/
- Vagrant : https://www.vagrantup.com/
- Virtualbox : https://www.virtualbox.org/
- Cntlm : http://cntlm.sourceforge.net/
I’m running CentOS vm’s inside Vagrant with Virtualbox provisioning on Cygwin on Windows 7. I’m running Cntlm to create a local proxy for all stuff what I’m doing through cygwin, because I don’t like putting clear text passwords in bashrc or in Win / Bash variables.
- Get your corporate proxy URL (Via Google Chrome)
- Configure Cntlm
- Configure Cygwin
- Configure Vagrant
- Use teh interwebs from your VM, practicing ninja turtle coding skillz and be instantly awesome!!1!
1. Get your corporate proxy URL (Via Google Chrome)
Most companies don’t let you see the proxy URL because of corporate reasons. (Yeah, that’s intentionally vague)
But we can find it anyway; Open chrome and enter this address:
That will show if you’re using a PAC script to configure your proxy. Copy the PAC URL and open it in Chrome. If this chrome page shows the Proxy URL already, skip to part 2.
Use your ninja pirate coding skillz to find your proxy in the file. Most companies add comments to this file, otherwise just copy the first proxy you can find.
Hint; They’re identified by the huge text “PROXY”.
2. Configure Cntlm
- Get the installer from http://cntlm.sourceforge.net/ and install.
- Open an administrator cygwin session (so that you can edit windows system files):
- Change directory to the Cntlm installation directory, default “/cygdrivec/c/Program Files (x86)/Cntlm”
- Run cntlm -H, enter your password and press enter:
Note; Cntlm -H does not connect to anything, it’ll just create the hashes which you can use in Cntlm.ini
- Copy the PassNTLMv2 line and edit cntlm.ini with nano or vi:
- Change your proxy URL
- Change the user
- Change the domain
- Add the PassNTLMv2
- Save the file
- Run “cntlm.exe -v” (verbose) and keep the bash session open
- if it is already running as a service; stop the service via “net stop cntlm”, we want the verbose output to make sure all is OK.
Cntlm Proxy is now running on your laptop on port 3128.
3. Configure Cygwin
- Open cygwin
- Add these two lines at the end of .bashrc:
export http_proxy="http://localhost:3128/" export https_proxy="http://localhost:3128/"
- Close cygwin and start it again
- Make sure it works by downloading the main google page:
- If all went well, you just saw some action in the Cntlm window and you downloaded the page:
This means that Cygwin is now configured to use the Cntlm proxy running locally
4. Configure Vagrant
- Install the proxy plugin in Vagrant (via Cygwin):
vagrant plugin install vagrant-proxyconf
- Add these lines to your Vagrantfile: (We’re using 10.0.2.2, that’s is the host IP!)
if Vagrant.has_plugin?("vagrant-proxyconf") config.proxy.http = "http://10.0.2.2:3128" config.proxy.https = "http://10.0.2.2:3128" config.proxy.no_proxy = "localhost,127.0.0.1" end
- Start your VM and ssh into it
- Do the same wget check to see if you have internet access:
Last step: Ninja Turtle coder!
Browse teh interwebs CLI style from your VM, practicing ninja turtle coding skillz and be instantly awesome!!1! Shredder be gone yo!
Being awesome should be easy with all this shizzle!