Internet Connection Sharing in Ubuntu
The following setup is valid and tested under Ubuntu 16.04
For this setup you'll need 2 physical network cards installed on your server - one connected to your Internet provider, and the second connected to a hub or second computer.
1. Go to the upper right corner of the desktop and right click on Edit connections. Then rename your both connections using the Edit button as 'incoming' (Internet provider) and 'localnet' (home network). If you don't know which one(eth0, eth1 etc.) is which just unplug cables one by one to check. This step will save you lots of trouble down the process.
2.Choose to Edit the 'localnet' connection, click on tab: IPv4 Settings and for method choose: 'Shared to other computers'. Repeat the same procedure for the 'incoming' connection, but this time choose DHCP.
(if you are using PPPOE)
Click on DSL - Edit and type your username and password given by the Internet provider.
3. Next you'll have to enable the two logical connections followed by the DSL connection(if you use one) by just clicking on them. During the process notice if 'wired media is connected' message appears. If the media gets connected and quickly disconnects you can try to disable the IPv6 Settings on the 'localnet' by setting their method to 'ignore'.
Also, it's necessary not to let the NetworkManager setup the default gateway for the 'localnet' connection, so just do:
# sudo nano /etc/NetworkManager/NetworkManager.confand set its managed parameter = 'false'.
Same can be achieved if you click on 'localnet' connection Routes button and check the 'Use this connection only for resources on its network'. This way its default gateway won't get overwritten by the NetworkManager.
Finally turn on the internal firewall with the command invoked in terminal:
# sudo ufw enableThis way your server setup is OK, now for the computers that want to use Internet click on Edit connections and just give them the 'localnet' configured IP address as gateway.