Use dbab under Ubuntu 14.04 Trusty

Documenting the steps I use to install/configure dbab under Ubuntu 14.04 Trusty. All in all, nothing unusual as before, as long as you don’t touch the new feature in the /etc/network/interfaces and ignore the /etc/network/interfaces.d directory. I only notice the new feature now (until Ubuntu 14.04), and was curious to give it a try. But it turns out to be a dead-end detour. Details at Setup static IP under Ubuntu 14.04 Trusty.

Now back to the steps I use…


Switch from dynamic IP to static IP

Static IP settings

From the interfaces man page, what should be set:

   The static Method
       This method may be used to define Ethernet interfaces  with  statically
       allocated IPv4 addresses.

       Options

              address address
                     Address (dotted quad/netmask) required

              netmask mask
                     Netmask (dotted quad or CIDR)

              broadcast broadcast_address
                     Broadcast  address  (dotted quad, + or -). Default value:
                     "+"

              metric metric
                     Routing metric for default gateway (integer)

              gateway address
                     Default gateway (dotted quad)

Configure the static IP

Configure the static interface, using the exiting info:

ifconfig | awk -F':' '/^eth/{ ethdev=$1; sub(/ .*/, "", ethdev); getline; addr=$2; sub(/ .*/, "", addr); printf "\nauto %s\niface %s inet static\n\taddress %s\n\tnetmask %s\n", ethdev, ethdev, addr, $4 }' | tee -a /etc/network/interfaces

route | awk ' $1 == "default" { print "\tgateway " $2 }'  | tee -a /etc/network/interfaces

$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto eth0
        iface eth0 inet static
        address 192.168.2.102
        netmask 255.255.255.0
        gateway 192.168.2.1

This setting has proved to be working, so we can conclude that network & broadcast are indeed no longer necessary any more. Some people also set dns-nameservers there, but I don’t think it even works because it is not even listed in the interfaces man page.


Add a second static IP address

Add a second static IP address for the Pixel server, the ad blocking server.

% cat <<EOF >> /etc/network/interfaces
        # add a 2nd ip address
        post-up ip addr add dev eth0 192.168.2.101/24
        pre-down ip addr del dev eth0 192.168.2.101/24
EOF

% cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto eth0
iface eth0 inet static
        address 192.168.2.100
        netmask 255.255.255.0
        gateway 192.168.2.1
        # add a 2nd ip address
        post-up ip addr add dev eth0 192.168.2.101/24
        pre-down ip addr del dev eth0 192.168.2.101/24

Install dbab

Installing dbab, nothing unusual as before:

% apt-get update

% apt-get install dbab
The following extra packages will be installed:
  curl dnsmasq
Suggested packages:
  resolvconf
The following NEW packages will be installed:
  curl dbab dnsmasq
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 145 kB of archives.
After this operation, 482 kB of additional disk space will be used.
Do you want to continue? [Y/n] ...

For the rest, e.g., configuring dbab etc, it’s the same as before as well.

Advertisements

7 thoughts on “Use dbab under Ubuntu 14.04 Trusty

  1. Pingback: The Secret Behind the Auto Proxy Setting | SF-Xpt's Blog

  2. Pingback: Use new dbab to set proxy automatically | SF-Xpt's Blog

  3. Pingback: How-to: Setup static IP under Ubuntu 14.04 Trusty #fix #solution #dev | StackCopy

  4. ….tee -a /etc/network/interfaces
    Permission denied. Even when full command is ran under sudo
    If I leave off the tee then it will echo to the display properly. Can I instead tee to another file name then copy/paste to /etc/network/interfaces ?

    • No, tee to another file defeat the purpose. Do sudo su - first then try again within the sudo.

  5. The use of source and source-directory in interfaces(5) are new, and not patched into many tools, like NetworkManger. Will be soon enough, when they correctly uses ifquery(8) command instead of parsing the interfaces(5) file directly.

    Yes, dns-nameservers directive work, if package resolvconf is installed, and it should usually be installed.
    And dns-nameservers are used by the package resolvconf and not ifupdown. So yes, you will not find dns-nameservers in man page interfaces(5), but in man page resolvconf(8).

    Yes, you only need one gateway directive active in any stanza for IPv4 (and one for IPv6). If you add another, it will replace the previous default router with this new one (by the way, use ipcalc(1) or sipcalc(1) when one do calculations with netmasks etc).

    Directives network and broadcast in a stanza was never needed, as Linux make the calculation much better than what we humans usually do. :-)

    You can set up another address with one more stanza for the same device, if you don’t want the directives up and down with ip(8) commands to set and remove a static address. But I do prefers the use of up and down it the stanza as you do. It put all configuration in one place.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s