share two network interfaces on linux

cn flag

I have a Linux PC (ubuntu 22.04) with a network layout as below:

Internet <-> Router <-> PC <-> edge device <-> Switch <-> APs <-> devices

And with two Lan interfaces as below:

  • eno1: Connected to the internet (directly connected to the router), gets IP: from the router (DHCP)
  • enx3c: connected to an edge device and that edge device is connected to a switch, also so many devices are connected to that switch.

I want clients connected to enx3c to have access to the internet on eno1. And also I need to be able to directly communicate with devices under the enx3c interface.

I have followed suggestions in here and so many other tutorials and questions to see how to forward traffic from one interface to another using iptables as follows:

echo 1 > /proc/sys/net/ipv4/ip_forward 
sudo vim /etc/sysctl.conf 
sudo sysctl -p 

iptables -A FORWARD -i eno1 -o enx3c -j ACCEPT 
iptables -A FORWARD -i enx3c -o eno1 -m state –state ESTABLISHED,RELATED -j ACCEPT 
iptables -t nat -A POSTROUTING -o eno1 -j MASQUERADE

After doing so, the edge device didn't get any IP, so I set up a DHCP server on the PC with the below steps:

sudo apt install isc-dhcp-server
sudo vim /etc/dhcp/dhcpd.conf 
    subnet netmask { 
    default-lease-time 600; 
    max-lease-time 7200; 
    option routers; 
    option domain-name-servers,; 

sudo vim  /etc/default/isc-dhcp-server 
#so the DHCP server produces Ips for clients connected to the second interface

sudo systemctl start isc-dhcp-server

And the eno1 interface is set to DHCP to get dynamic IP from the router and enx3c is set to manual to get static IP (

After starting the DHCP server, the edge device gets an IP in the range, and nmap shows it among live hosts, But there is no access to it! I cannot ping it or ssh into it. And the edge device doesn't have any internet access.

I looked everywhere and it seems that this method must work but I don't know what I am doing wrong. I appreciate any suggestions.

Update: It's worth mentioning that using the answer in here, I used the share to other networks option in the network manager in Ubuntu on the second interface, and after that, it gets IP in a different range,, and also the edge device gets a new IP in this range,, But again, I cannot ping or ssh into this device.

Here is the output for routing tables:

route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    100    0        0 eno1   U     101    0        0 enx3c     U     1000   0        0 eno1   U     100    0        0 eno1
cn flag
Linux is a misery when you're trying to work in the GUI and in the shell at the same time. Also, what you're basically doing here is setting up your PC *as* a router, so having the router and the edge device in the mix is adding a lot of complexity. Try tweaking the NAT rule to explicity list the subnet to be NAT'd e.g: iptables -t nat -s -A POSTROUTING -j MASQUERADE That's the thing that leaps out at me.
ru flag

I have used a similar approach but for direct computer to computer.

My /etc/dhcp/dhcpd.conf is like this (substituting your in IPs):

subnet netmask { 
    default-lease-time 600;
    max-lease-time 7200;

#optional; so enx3c can be set to use DHCP but still having static a ip
host someHostname {
 hardware ethernet mac-address-of-enx3c;

My main method of routing is through ufw, like so ( being the server, local DHCP address):

ufw route allow from app WWW to app WWW

External ip ( isn't accessible via NIC (eno1), so I use a route fix:

route add -host dev eno1
I sit in a Tesla and translated this thread with Ai:


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.