Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Sharing openvpn connection

Options
  • 05-01-2016 12:31pm
    #1
    Closed Accounts Posts: 16


    Hi
    I have an openvpn connection on my raspberry pi.

    Is there any way to allow other machines on my local LAN to use the same vpn connection?

    I can do this on my pc because the vpn software I use has an option for that (i.e. it's done for me). But in linux I don't know how to do it.
    I have downloaded the certificate and I can open the vpn connection fine, but I have no idea how to share the connection out.
    I would like to allow another computer to get its data through the raspberry pi and also use the pi for dns.
    Thanks!


Comments

  • Registered Users Posts: 1,193 ✭✭✭liamo


    Hi

    We have an OpenVPN connection in work for various destinations.

    Here is the iptables config that takes care of the sharing (assumes eth0):
    # Flush rules
    iptables -F
    iptables -t nat -F
    iptables -t mangle -F
    
    # Delete chains
    iptables -X
    iptables -t nat -X
    iptables -t mangle -X
    
    # Masquerade on eth0
    iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    


    Turn on IP forwarding:
    echo "1" > /proc/sys/net/ipv4/ip_forward
    

    Ensure that IP forwarding survives a reboot by modifying /etc/sysctl.conf to change "net.ipv4.ip_forward=0" to "net.ipv4.ip_forward=1"

    You will need to point your internal devices at the device on which OpenVPN is running either by specifying the OpenVPN device as the default gateway or setting up specific routes.

    If you want to use the device running OpenVPN as a DNS server then you will need to install a DNS server on the device and configure your client devices accordingly.

    If you are running a DHCP server then the DNS and gateway settings can be done centrally.

    Hope this helps

    Liam


  • Closed Accounts Posts: 16 bobdillon


    Thanks I'll have a go at setting up a dns server and updating the iptables and forwarding tonight.
    With any luck it will work :)


Advertisement