Created
October 30, 2015 11:35
-
-
Save pellaeon/f5c588a3a0b9cd30d307 to your computer and use it in GitHub Desktop.
ip netns VPN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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