Skip to content

Instantly share code, notes, and snippets.

@pellaeon
Created October 30, 2015 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pellaeon/f5c588a3a0b9cd30d307 to your computer and use it in GitHub Desktop.
Save pellaeon/f5c588a3a0b9cd30d307 to your computer and use it in GitHub Desktop.
ip netns VPN
#!/bin/bash
#create bridge 'br0'
brctl addbr br0
#create network namespace 'ns0'
ip netns add ns0
#create virtual nic pair for hooking ns0
ip link add veth0 type veth peer name veth1
#adding veth1 into namespace 'ns0'
ip link set veth1 netns ns0
#bring ethernet NIC down for adding it to br0 later
ip link set dev enp0s25 down
#add ethernet NICs
brctl addif br0 enp0s25
brctl addif br0 veth0
#setting up NICs
ip link set dev enp0s25 up
ip link set veth0 up
ip netns exec ns0 ip link set veth1 up
ip link set dev br0 up
#requesting IP inside namespace
#ip link exec ns0 dhcpcd -4 veth1
#requesting IP outside namspace
#dhcpcd -4 br0
#starting OpenVPN
#sudo /usr/sbin/openvpn --remote [VPN_access] 1194 udp --comp-lzo --nobind --dev tun --auth-nocache --reneg-sec 0 --client --auth-user-pass --ca /etc/openvpn/ca.crt --user nm-openvpn --group nm-openvpn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment