Created
April 3, 2019 04:12
-
-
Save croepha/d30a4fa64900387dd8c8b6299375838d to your computer and use it in GitHub Desktop.
notes on Linux network emulation for local processes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo ip netns add client_ns | |
sudo ip link add veth0 type veth peer name veth1 | |
sudo ip link set veth1 netns client_ns | |
sudo ip link set dev veth0 up | |
sudo ip addr add 192.168.250.10/24 dev veth0 | |
sudo tc qdisc add dev veth0 root netem delay 1000ms | |
sudo ip -n client_ns link set dev veth1 up | |
sudo ip -n client_ns addr add 192.168.250.11/24 dev veth1 | |
sudo tc -n client_ns qdisc add dev veth1 root netem delay 1000ms | |
socat tcp-l:1234,fork,reuseaddr,bind=192.168.250.10 exec:date | |
# in another terminal do: | |
# this gets you a shell in the client_ns | |
sudo ip netns exec client_ns su user | |
# then do this from su shell: | |
date; socat stdio tcp:192.168.250.10:1234 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment