Skip to content

Instantly share code, notes, and snippets.

@clementnuss
Last active March 26, 2021 16:12
Show Gist options
  • Save clementnuss/8f1903eb7e4086fc37adae74a1c3bb3b to your computer and use it in GitHub Desktop.
Save clementnuss/8f1903eb7e4086fc37adae74a1c3bb3b to your computer and use it in GitHub Desktop.
# given $netns the the network namespace id. e.g. netns=46165437
# 1st: we create a virtual interface
ip link add name toto_if type ipip local 10.20.30.46 remote 10.30.30.1
# 2nd, we put this interface in the network namespace of our pod
ip link set dev toto_if netns $netns
# 3rd, we can for example change the ip address or routing parameters:
nsenter -t $netns --network ip addr add 1.2.3.4/30 dev toto_if
nsenter -t $netns --network ip route add default via 1.2.3.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment