1

I shared my internet over Wire with others devices by Clicking on the network icon > Edit connections > Share to other computer . However, The problem is when I share my VPN connection and that VPN connection drops down/failed for any reasons; Ubuntu keeps shearing my internet which is wireless connection with others!

How do I let Ubuntu stick with vpn interface, once is dropped, the other devices get no internet?

2 Answers 2

1

I'm thinking about one way to do what you desired using Network-Manager by having 2 profiles for your wired connection:

  1. Profile wire_shared
  2. Profile wire_not_shared

And then run some trigger that switches your connection between the two profiles depending on the VPN state. You can use cron job and simple script like this

But more detailed answer need more detailed input from your side:).

2
  • Great idea, but still it is possible to others devices get connected with wireless even for seconds :)
    – Alex9766
    Nov 5, 2016 at 10:30
  • Depends on your VPN... is it OpenVPN, PPTP or ? You can start it outside of Network manager via command and add some pre-up post-down triggers... But clear solution using only Network manager won't work. It is just a simple unified Interface with nice GUI to time more sophisticated protocols... Nov 5, 2016 at 23:50
0

I just found it:

  1. Don't share your internet, instead of that set the Wired connection getting manual IP.

  2. Give Wired connection local IPs such as "10.42.0.1/255.255.255.0"

  3. Apply these iptables rules in Terminal:

    sudo apt-get install linux-image-$(uname -r)

    sudo bash -c 'echo 1 > /proc/sys/net/ipv4/ip_forward

    sudo iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT

    sudo iptables -A FORWARD -i eth1 -o eth0 -m state --state ESTABLISHED,RELATED \

    -j ACCEPT

    sudo iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE

  4. At other device side, set manual iPs as well such as "10.42.0.15/255.255.255.0/10.42.0.1"

Done. Once eth1 (or whatever your target interface) get disconnected, all others devices get no internet.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .