Score:0

Share network from eth0 to device plugged into eth1?

gd flag

ip addr information

I have a ubuntu 20.04 server that has two ethernet ports. I am trying to set it up so eth0 is connected to my lan/internet and I have a second ethernet port (eth1) that i want to be able to plug in another device and have it get its dhcp information from the router connected in eth0, and i also want it to have internet connection.

cat /etc/network/interfaces

# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp
DynamicBits avatar
in flag
Can you add the output of `networkctl` to your question?
Score:0
in flag

Since you haven't provided the output of networkctl, I'm going to assume this is a new install and wasn't upgraded from 17.04 or older.

You are looking to bridge eth0 and eth1. Netplan became the new default configuration utility in Ubuntu 17.10. Since you are using ubuntu-server, the renderer is systemd-networkd. For ubuntu-desktop the renderer is NetworkManager, which requires a GUI (but does have CLI binaries available).

The default config file is located in /etc/netplan/, and should have one of the following names:

  • 00-installer-config.yaml
  • 01-netcfg.yaml
  • 01-network-manager-all.yaml
  • 50-cloud-init.yaml

Make a backup so you can easily undo any changes, and then update your yaml file to look like this:

network:
    version: 2
    renderer: networkd
    ethernets:
        eth0:
            dhcp4: no
            dhcp6: no
        eth1:
            dhcp4: no
            dhcp6: no
    bridges:
        br0:
            dhcp4: yes
            dhcp6: yes
            interfaces: [eth0,eth1]

To apply changes, run sudo netplan apply and check the status with networkctl.

With this specific configuration, don't connect both ethernet ports into the same switch.

If you're more of a visual person, check out this YouTube video which shows pretty much what you're asking about but with more interfaces and a static IP instead of DHCP.

The bridge-utils package might need to be installed (sudo apt install bridge-utils).

Score:0
tj flag

From what you have described here, if both interfaces are going to the same router, and they are both dhcp enabled interfaces, you will be able get different IP addresses for each that are routable to the internet. Are you looking to build a share binded to just one interface?

darnleyc avatar
tj flag
If eth0 and eth1 are plugged into the same router and there is no vlan tagging involved, they will be on the same network span so enabling network sharing from eth0 will be the same as sharing from eth1.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.