Internet connection sharing without Network Manager on Ubuntu Linux

RJ45 connectorsI've given up on Network Manager a while ago. Why? Because most of the time I use 3G modem to connect to Internet and Network Managers 3G support varies from release to release. Earlier I wrote about managing GSM mobile broadband connections without Network Manager on Red Hat Linux, CentOS, Fedora based Linux distributions and on Ubuntu, Linux Mint, Debian based Linux distributions. In this article I will explain easiest way to configure Internet Connection Sharing on Ubuntu Linux based operating system.

In this article I assume you are working on a computer without Network Manager. This is because if you have Network Manager and if Network Manager works for your network configuration you can configure Internet Connection Sharing easily from Network Manager GUI. Also you must configure two interfaces, first with Internet access and second with access to your local network. Interface to your local network must have static IP address. In this tutorial I will use my mobile broadband interface ppp0 configured using instructions from my article Manage GSM mobile broadband connections without Network Manager (Ubuntu, Linux Mint, Debian) and my eth0 local network interface.

Internet Connection Sharing server static IP address configuration

Here's how to configure your local network interface with static IP address without Network Manager. First open your interfaces configuration file as administrative user using your favorite text editor, for example if you use nano editor:

sudo nano /etc/network/interfaces

If your local network interface is eth0 you will place something like this inside this file:

auto eth0
iface eth0 inet static

This way my local network interface will have IP address and it will be brought up automatically on every boot (due to auto eth0 line). If I want to bring this interface manually I will remove that line and use following commands to bring eth0 interface manually up and down:

sudo ifup eth0
sudo ifdown eth0

You can also use following command to view all active network interfaces:

sudo ifconfig

Internet Connection Sharing server ufw configuration

ufw is CLI frontend to Linux kernel built in firewall called iptables. ufw purpose is to give you some abstraction to make iptables configuration simpler. Internet Connection Sharing is usually configured using iptables but since most Ubuntu desktops and servers run UFW and since UFW has this feature we will use it to configure Internet Connection Sharing in this article. To install and enable ufw on Ubuntu based Linux PC you can use following commands:

sudo apt-get install ufw
sudo ufw enable

My first step is to allow all incoming traffic from my trusted home network like this:

sudo ufw allow from

Now to configure ufw for Internet Connection Sharing we must first open /etc/default/ufw like this:

sudo nano /etc/default/ufw

Then we need to change following:


into following:


Second thing we must do is to open /etc/ufw/sysctl.conf like this:

sudo nano /etc/ufw/sysctl.conf

We need to change following:


into following:


Notice that we've removed # from the beginning of each line. The last file we need to change is /etc/ufw/before.rules by opening it like this:

sudo nano /etc/ufw/before.rules

In this article I'm sharing ppp0 network interface Internet connection to clients accessible over eth0 network interface on subnet so I will add following right after the header comments:

# Add rules for nat table
# Forward traffic from eth0 through ppp0
# Commit preceding nat table rules

To make our new ufw configuration active we must restart ufw service like this:

sudo service ufw restart

Internet Connection Sharing client configuration

Please keep in mind that your client network address must fall into subnet if your Internet Connection Sharing server has IP address. This means that your client must have address withing IP range. To keep things simple I will set up static IP address for my test client but you could also configure DHCP server of your choice to lease IP addresse from allowed IP range. For static IP address for your client PC you can use procedure from preceding article except this time you will use IP address. Also two client machines shouldn't use same IP address. Again you edit /etc/network/interfaces file by placing following inside, this time on your client PC:

auto eth0
iface eth0 inet static

Also you can use Network Manager on your client machines to configure static IP address.

That's it. After bringing your servers ppp0 and your server and client eth0 interface up you should be able to access Internet from your client PC. If something doesn't work as expected try pinging google or client from server or server from client, that might give you some clues. You can also post here and someone will respond (probably me). Good luck!


A quality focused Magento specialized web development agency. Get in touch!

3 thoughts on “Internet connection sharing without Network Manager on Ubuntu Linux

  1. ted

    isn’t it easier to just execute this:
    iptables -t nat -A POSTROUTING -s -o ppp0 -j MASQUERADE
    instead of using ufw?


Leave a Reply

Your email address will not be published. Required fields are marked *