1

I use Ubuntu 14. I have two interfaces (eth0 and usb0) and two connections with manual settings. I want to use network manager. Eth0 is WAN. How can I create shared connection to other computers? If I create new connection (third one) and use eth0 as interface then it doesn't work. If I open existing connection (eth0) and change method from Manual to Shared to other computers then all my settings disappear.

1

To do it through network manager using gui

dnsmasq-base has to be installed:

sudo apt-get install dnsmasq-base

Remove dnsmasq because it conflicts with NetworkManager:

sudo apt-get remove dnsmasq

NetworkManager version 0.7, shipped with Ubuntu 8.10 and later, contains a redesigned user interface for managing network connections.

Among the new features and UI is an option to make a connection “Shared to other computers”. This is basically a dead-simple NAT (Network Address Translation), or Internet connection sharing, built right in to NetworkManager.

To enable this, you must follow three steps:

Install dnsmasq on your computer. (On Ubuntu, you will want to install the dnsmasq-base package. (apt-get install dnsmasq-base is the easiest way)

Make sure your WAN connection (i.e. Internet-connected connection) is all configured (e.g. with DHCP or a static address) and working. Basically, make sure you can pull up web pages.

For your LAN interface (which might be a second network card or a wireless card), select “Shared to other computers” in the IPv4 Settings tab.

Courtesy of Citation 1

If everything works right, NetworkManager should have auto-configured a subnet and DHCP server on your LAN interface, and is ready for sharing your Internet connection.

To do it through terminal

It's very simple to masquerade (internet connection sharing in Windows language ) on Linux with a few lines of iptables and ip_forward commands. First of all you have to flush and delete existing firewall rules. So flush rules by typing in terminal:

iptables -F
iptables -t nat -F
iptables -t mangle -F

Now delete these chains:

iptables -X
iptables -t nat -X
iptables -t mangle -X

Now it's time to save the iptables rules so type:

service iptables save
service iptables restart

Now all rules and chains have been cleared! Check it in /etc/sysconfig/iptables which has all default rules set to accept. Now open /etc/rc.d/rc.local and insert the line:

echo "1" > /proc/sys/net/ipv4/ip_forward

And then save and close the file. Now asuming that your internet interface is eth0, type:

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
service iptables save
service iptables restart

Note: check if iptables is set to start during boot up. Or check the status of your iptables service:

chkconfig –list iptables

If level 5 is on then it's ok othewise start the service at level 5 or level 2345.

Citation:

https://jeremy.visser.name/2009/03/simple-internet-connection-sharing-with-networkmanager/

https://www.howtoforge.com/internet-connection-sharing-masquerading-on-linux

  • Thank you. I know all that but I want to do it using Network Manager as it is simpler. – Pavel Nov 4 '15 at 8:46
  • @JimJim2000 updated my answer to reflect your exact wishes. – DeeJayh Nov 4 '15 at 19:47
  • Please, read carefully my question. I have manual settings for the interface over which I want to share internet. – Pavel Nov 5 '15 at 4:41
  • Updated answer. Make sure you do not have dnsmasq installed, but that the base package is installed. – DeeJayh Nov 5 '15 at 4:51
  • 3
    I guess, the problem here is that if you use Network Manager for "Shared to other computers", you cannot really choose what IP address will the shared interface have (nor what IP addresses will it assign to other devices connected to that network). For instance, when I try that, NetworkManager/Ubuntu assigns 10.42.0.1 to the shared interface, and then it assigns to other devices on a switch adresses from 10.42.0.255/24 range; if I want instead this connection to be 192.168.0.177 and assign addresses in 192.168.0.255/24 range, there is no way to do it in Network Manager. – sdbbs Jan 16 '17 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.