Throttling Ethernet connection on Linux

Often for testing purposes it is necessary to restrict the speed of a network connection.

This can be achieved using the netem module to tc.

For example, to restrict the bandwidth on eth0 to classic dial-up speeds use the command:

tc qdisc add dev eth0 root netem rate 56kbit

This can be cleared with:

tc qdisc del dev eth0 root netem rate 56kbit

Alternatively, this rule can be executed on an Ethernet Bridge so that it is independent of the device being tested.

ISC-DHCP-Server – disable dhcpv6 (Debian 9)

The isc-dhcp-server included in Debian 9 will attempt to start a DHCPv6 instance on servers which have a dual-stack (IPv4 & IPv6) config.

If DHCPv6 is unconfigured because for example, Router Advertisements are used for configuring IPv6 hosts, then the service will fail to start. The DHCP(v4) is running but Systemd reports the service as failed.

One work-around is to force isc-dhcp-server to only start the v4 instance, add the following line to /etc/default/isc-dhcp-server:

INTERFACESv4=eth0

where eth0 is the interface on which DHCP requests should be serviced.

After restarting the service, the DHCP server shall now only run on v4 and as long as the v4 config is correct, Systemd will report the service as successfully started.

Mounting Android phone over USB on Debian

Debian Stretch

Using the following steps an Android phone can be mounted over USB by a Debian Linux system.

  • apt-get install jmtpfs
  • connect phone and select data transfer over USB
  • jmtpfs /mnt/phone

At this point, my phone prompts me whether or not to allow this connection. I select allow, but it is too late for the computer and any attempts to browse the directory /mnt/phone result in i/o errors. Unmounting and remounting without changing anything on the phone and leaving it connected, is a work-around for this issue.

  • umount /mnt/phone
  • jmtpfs /mnt/phone

Do work.

  • umount /mnt/phone

Vim – disable mouse mode

Newer versions of vi/vim included with Debian Stretch and later have the mouse mode enabled, which prevents traditional copy and paste from being used – the ability to highlight text and then middle-click to paste.

To re-enable this behaviour so that the middle-click can be used, enter the following line into your ~/.vimrc file:

set mouse=r

Iperf – multicast IPv4

Using Iperf version 2.0.9 on Debian (Stretch) it’s possible to test networks using a multicast connection.

On the receiving end execute the command:
iperf -s -u -B 239.1.1.10 -i 1

On the sending end execute the command:
iperf -c 239.1.1.10 -u -T 3 -t 10 -i 1 -b 100M

This will run a bandwidth test using UDP traffic at 100Mbps.

Note, if your system is multi-homed you must make sure your multicast traffic is routed out of the correct interface. For example:
ip route add 224.0.0.0/4 dev eth0