20 lines
297 B
Bash
20 lines
297 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
NS=$1
|
||
|
IF=$2
|
||
|
IP=$3
|
||
|
|
||
|
# Add interfaces to namespaces
|
||
|
ip link set "$IF" netns "$NS"
|
||
|
|
||
|
# Set IP Addresses
|
||
|
ip netns exec "$NS" ip addr add dev "$IF" "$IP"
|
||
|
|
||
|
# Turn on Links
|
||
|
ip netns exec "$NS" ip link set up "$IF"
|
||
|
|
||
|
# For Debugging
|
||
|
#
|
||
|
# # Show interface info
|
||
|
# ip netns exec "$NS" ip a s "$IF"
|