Skip to content

Instantly share code, notes, and snippets.

@njsmith
Last active April 1, 2022 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save njsmith/e9c0f8ef61df35839b992e617a0a6b77 to your computer and use it in GitHub Desktop.
Save njsmith/e9c0f8ef61df35839b992e617a0a6b77 to your computer and use it in GitHub Desktop.
# Create a new network namespace named 'bad', which will come with its own private loopback interface
sudo ip netns create bad
# Make the loopback interface slow, drop packets, etc.
sudo ip netns exec bad tc qdisc add dev lo root netem delay 200ms 40ms 25% # ... add more netem options here
# Turn on the loopback interface
sudo ip netns exec bad ip link set lo up
# Start a shell inside the new namespace
sudo ip netns exec bad sudo -u $USER /bin/bash
# Try running 'ping 127.0.0.1' to see how bad the network is
# Later, when you're done and want to clean up:
sudo ip netns delete bad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment