Netns different outgoing source ip address

7 07 2017

Using three network interfaces, assign each one a different address as source ip address for outgoing traffic:

#!/bin/bash
ip netns add blue
ip link set eth1 netns blue
ip netns add green
ip link set eth2 netns green
ip netns exec blue dhclient eth1
ip netns exec green dhclient eth2
echo "IP eth0: "
curl ipinfo.io/ip
echo "IP eth1: "
ip netns exec blue curl ipinfo.io/ip
echo "IP eth2: "
ip netns exec green curl ipinfo.io/ip

Advertisements