32

I have two desktop PCs I use frequently, both running Ubuntu 12.04. One is connected to the internet via wireless, and the other has no wireless card. Is there any way I can share my internet connection across the ethernet ports?

0

2 Answers 2

39

Sharing internet connection via ethernet is one step more than doing it wirelessly. Here are the steps:

PC Sharing Connection

PC that will share connection

  1. Open your Network Manager via the Network Icon on the Unity Panel:

    enter image description here

  2. Go all the way down to the Edit Connections option and click on it.

    enter image description here

  3. You will appear on the Wired Tab. Each Wired connection is by default related to each Ethernet Wired NIC card you have. For example if you have 2 Wired NICs you will see 2 options here. In the image below you see one since this is a Laptop and they normally have one. Select the Wired connection you wish to edit and double click on it or select the EDIT button.

    enter image description here

  4. You will appear on the Wired Tab (Again). This time, go to the IPv4 Settings if you are using IPv4 or IPv6 if you are using that one. On the Method option select Share to Other Computers. Now SAVE. You are done.

enter image description here

This will do all the stuff that was normally done 6 or 7 years ago with all the terminal commands and iptable stuff.

Now just connect the 2 computers and you are done.

NOTE: If both computers have a Wired Gigabit Ethernet NIC then you can actually connect them directly since most 1000BASE-T have automatic MDI/MDI-X. If not just connect them to your switch, router, hub, whatever and that is all.

Client PC

PC That will receive Shared Internet Connection (Depends on Network Setup)

  1. Open your Network Manager via the Network Icon on the Unity Panel:

    enter image description here

  2. Go all the way down to the Edit Connections option and click on it.

    enter image description here

  3. You will appear on the Wired Tab. Each Wired connection is by default related to each Ethernet Wired NIC card you have. For example if you have 2 Wired NICs you will see 2 options here. In the image below you see one since this is a Laptop and they normally have one. Select the Wired connection you wish to edit and double click on it or select the EDIT button.

    enter image description here

  4. You will appear on the Wired Tab (Again). This time, go to the IPv4 Settings if you are using IPv4 or IPv6 if you are using that one. On the Method option select Manual. The options in Addresses will be editable now. Add the IP you want, the Mask you need and the IP of the PC that is sharing the connection. In this case I said that the IP of the Client PC will be 192.168.0.2, the Mask is 255.255.255.0 to imply that is a Class C (LAN) network and 192.168.0.1 to mention that the computer sharing the connection has the IP 192.168.0.1 with it. Additionally add the same IP of the computer sharing the connection to the DNS Servers (As shown in the image).

    enter image description here

You can also (Depending on the network setup) select instead of Manual, select Automatic and just put the IP of the computer sharing the Internet in the DNS Servers section.

enter image description here

Note that this depends on the network setup. For example if you have both PCs connected to a switch or router, the switch/router will take care of the Client, so you only need to setup the PC Sharing Internet and just connect both to the switch/router. If by chance you are connecting the PCs directly together then it is better to do the additional setup of the Client.

In most cases, you will not need to setup the client, just connect to the network and done. Ubuntu will take care of everything. I just added the Client part for specific cases where problems might arise.

This should cover all the possible scenarios in a home LAN when one wants to share the internet connection over Wired cable.

6
  • Thanks much as I would have not thought to look here in the settings and thought I was going to have to get into some gnarly routing rules, this is way easier!
    – xamox
    May 20, 2015 at 14:52
  • 1
    what if your device to share to has a fixed ip configured in its /etc/network/interfaces ?How do you set the ip domain of the host computer to be the same as the other device?
    – Mehdi
    Jun 12, 2019 at 12:47
  • How to configure the DNS for this from the "server" side? I am trying to share the internet to a computer that does not allow manual DNS changes, but the server never sends option 6 (name server) in its DHCP message
    – Ferrybig
    Jul 23, 2021 at 10:46
  • You could check here @ferrybig askubuntu.com/questions/13993/… Jul 24, 2021 at 12:31
  • I have exactly the same problem with @Mehdi My client is a android phone connected to the host via USB RNDIS. During a p2p connection the client uses 192.168.103.51 and the host assigns itself to 192.168.103.127. But if I changed the host side to "share" then the host becomes 10.42.0.1 and I have no way to change the client side ifconfig to match that (no root permission). Jul 18, 2023 at 5:33
22

Yes, it's actually quite easy.

  1. Open the Network Menu on your panel and select "Edit connections"
  2. Select the wired connection and click Properties.
  3. In this dialog, open the IPv4 tab.
  4. In the "Method" combo, select "Shared with other computers".

Now, whatever is connected to the wired network port will get access to whatever internet connection you use.

2
  • 8
    From the terminal please
    – chx101
    Jan 1, 2017 at 17:58
  • This approach will not work with static ip network
    – Bilal
    Mar 31, 2022 at 8:34

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