Skip to content

Instantly share code, notes, and snippets.

@ybubnov
Last active August 18, 2017 12:01
Show Gist options
  • Save ybubnov/c4901f143e55ed5b9bff20379b27be32 to your computer and use it in GitHub Desktop.
Save ybubnov/c4901f143e55ed5b9bff20379b27be32 to your computer and use it in GitHub Desktop.
#!/bin/sh
set -x
port=enp0s8
lladdr=$(ip link show $port | awk '/ether /{print $2}')
sysctl -w net.ipv4.ip_forward=1
ip link add h1-eth0 type veth peer name s1-eth0
ip netns add h1
ip link set h1-eth0 netns h1
ovs-vsctl \
-- --if-exists del-br s1 \
-- add-br s1 \
-- set bridge s1 \
other_config:datapath-id=0000000000000001 \
fail_mode=secure \
other-config:disable-in-band=true \
protocols=OpenFlow13 \
-- add-port s1 s1-eth0
ovs-ofctl add-flow s1 -O OpenFlow13 actions=flood
ip netns exec h1 ip addr add 10.0.8.1/24 dev h1-eth0
ip netns exec h1 ip link set h1-eth0 address ${lladdr}
ip netns exec h1 ip link set h1-eth0 up
ip netns exec h1 ip route add default dev h1-eth0
ip link set s1-eth0 up
#ifconfig ${port} 0.0.0.0
ovs-vsctl add-port s1 ${port}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment