Skip to content

Rage Against the Shell

Linux tips and other things…

  • Home
  • Contact
  • Privacy Policy

Month: May 2016

GeoIP Location in Varnish

Posted on May 23, 2016 - July 2, 2017 by Mr. Reboot

Tested on Ubuntu 14 / Varnish 4

First install packages and libraries needed, you must use the varnish official repositories:

~ $ sudo apt-get install varnish varnish-dev git-core libgeoip-dev apt-transport-https libtool python-docutils automake make

Then download geoip vmod and compile it:

~ $ cd /usr/src/
~ $ git clone https://github.com/varnish/libvmod-geoip
~ $ cd libvmod-geoip
~ $ ./autogen.sh
~ $ ./configure
~ $ make
~ $ make install

Vmod will be installed in /usr/lib/varnish/vmods/.

TIP: The geoip database from repositories is a little bit outdated, so you can download the MaxMind free database to get better results:

~ $ cd /usr/share/GeoIP/
~ $ mv GeoIP.dat GeoIP.dat.old
~ $ wget -O GeoIP.dat.gz http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
~ $ gunzip GeoIP.dat.gz

Now in order to use its functions, first import the module in default.vcl file:

import geoip;

Then configure vmod geoip in varnish for blocking by country, for example if you want block China and Russia, in vcl_recv add first:

set req.http.X-Country-Code = geoip.country_code("" + client.ip);

to set the country code, and then to ban the country(s):

if (req.http.X-Country-Code ~ "(CN|RU)" ) {
        return (synth(403, "Forbidden"));
}

Now in vcl_synth, add something like this:

if (resp.status == 403) {
        synthetic( {"<!DOCTYPE html>
        <html>
        <head>
        <title>Forbidden</title> 
        </head>
        <body>
        <h1>Forbidden</h1>
        </body>
        </html>
        "} ) 
};

Finally reload varnish:

~ $ /etc/init.d/varnish reload
Posted in Varnish7 Comments

Rename network interfaces in Ubuntu

Posted on May 19, 2016 - September 25, 2016 by Mr. Reboot

Tested on Ubuntu 16

From Ubuntu 15, network interfaces names are generated by systemd/udev using predictable names based in several policies and schemes like firmware, BIOS, interface’s MAC address, geographical location and others. Names like enp2s0 for example.

However it’s possible change the name, if you want retro-compatibility with old software or for scripting, to do it add net.ifnames=0 to the /etc/default/grub file:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash net.ifnames=0"

Now make an update-grub:

~ $ sudo update-grub

And reboot:

~ $ sudo reboot

Interfaces now be called eth0, wlan0, eth1 etc…

Posted in DistrosLeave a comment

Tuning ubuntu on Asus X series

Posted on May 19, 2016 - September 18, 2016 by Mr. Reboot

It’s probably you’ll have to tuning several things in Ubuntu 15/16 if you are an owner of a laptop ASUS X series.

If yo get this error on syslog and/or by stderr (a lot of records by second):

printk messages dropped pcieport 0000:1c.5 Receiver Error
pcieport 0000:00:1c.5 PCIe Bus Error: severity=Corrected, type=Physical Layer, id=00e5(Receiver ID)

add pci=nomsi to the /etc/default/grub file:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash pci=nomsi"

Also you’ll want control brightness via system keys, if don’t work, try adding acpi_osi=, acpi_backlight=native and intel_idle.max_cstate=1 to the /etc/default/grub file too:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash pci=nomsi acpi_osi= acpi_backlight=native intel_idle.max_cstate=1"

Now make an update-grub:

~ $ sudo update-grub

At last, if you experiment disconnections on wireless mode check if your wlan driver is rtl8723be:

~ $ lspci | grep -i wireless
03:00.0 Network controller: Realtek Semiconductor Co., Ltd. RTL8723BE PCIe Wireless Network Adapter

If yes create a configuration file en /etc/modprobe.d:

~ $ sudo touch /etc/modprobe.d/rtl8723be.conf

And add this:

~ $ sudo echo 'options rtl8723be fwlps=0' > /etc/modprobe.d/rtl8723be.conf

Finally reboot:

~ $ sudo reboot
Posted in Distros2 Comments

Search

Calendar

May 2016
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  
« Apr   Jun »

Categories

  • Apache
  • Cisco
  • Command line
  • Distros
  • Dovecot
  • File systems
  • Gadgets
  • GlusterFS
  • MySQL
  • Nginx
  • NTP
  • Opendkim
  • Pacemaker + Corosync
  • Postfix
  • Raspberrypi
  • SSH
  • SSL
  • Varnish

RSS RSS

  • Using qrencode January 16, 2022
  • Compile varnish module vmod_vsthrottle April 22, 2020
  • SSH vpn with sshuttle April 9, 2020
  • Disable swap in systemd December 16, 2019
  • Getting the parent process pid October 12, 2018
Proudly powered by WordPress | Theme: micro, developed by DevriX.