Created
November 3, 2016 14:01
-
-
Save DistantThunder/8f0fae1d03f141f5c4a9bd1ec1dbf6b3 to your computer and use it in GitHub Desktop.
Little script originating from "http://unix.stackexchange.com/questions/149293/feed-all-traffic-through-openvpn-for-a-specific-network-namespace-only/196116#196116" creating network namespaces with the OpenVPN connection. IPv6 section is commented out, you can re-enable it yourself.
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
1 #!/bin/sh | |
2 | |
3 set -x | |
4 case $script_type in | |
5 up) | |
6 ip netns add vpn | |
7 ip netns exec vpn ip link set dev lo up | |
8 mkdir -p /etc/netns/vpn | |
9 ip link set dev "$1" up netns vpn mtu "$2" | |
10 ip netns exec vpn ip addr add dev "$1" \ | |
11 "$4/${ifconfig_netmask:-30}" \ | |
12 ${ifconfig_broadcast:+broadcast "$ifconfig_broadcast"} | |
13 #test -n "$ifconfig_ipv6_local" && \ | |
14 #ip netns exec vpn ip addr add dev "$1" \ | |
15 # "$ifconfig_ipv6_local"/112 | |
16 ;; | |
17 route-up) | |
18 ip netns exec vpn ip route add default via "$route_vpn_gateway" | |
19 #test -n "$ifconfig_ipv6_remote" && \ | |
20 #ip netns exec vpn ip route add default via \ | |
21 #"$ifconfig_ipv6_remote" | |
22 ;; | |
23 down) | |
24 ip netns delete vpn | |
25 ;; | |
26 esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment