Sample Header Ad - 728x90

How to configure 2 network interfaces which make use of the same physical ethernet port?

-1 votes
1 answer
1928 views
I currently have a linux system with only one physical ethernet port. This physical port has the eth0 network interface attached to it. I want to create another ethernet interface which also makes use of this single physical port. How could I achieve this using the /etc/network/interfaces file? My ultimate goal is to be able to access two different networks using a single ethernet port. For example, if I have the following interfaces file:
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
        address 192.168.1.11
        netmask 255.255.255.0
        gateway 192.168.1.1

auto eth1
iface eth1 inet static
        address 192.168.16.100
        netmask 255.255.255.0
        gateway 192.168.16.1
I would expect to be able to ping both networks, but so far I can only ping eth0 even if I am pinging eth1 from the right network (192.168.16.0/24). I am sure I am missing some sort of configuration since it would seem too easy to simply add a new entry in the interfaces file and hope that it magically works. I am aware that I can add multiple IPs to a single ethernet interface using the command ip addr add 192.168.16.100/24 dev eth0 but I would very much prefer to have two separate interfaces. Thanks!
Asked by Kevin Serrano (1 rep)
Nov 16, 2020, 03:23 PM
Last activity: Jun 27, 2025, 04:07 AM