Score:0

Routing packets between two nics on the same system

tc flag

I have a small network setup with a ubuntu router that has two nics. enp2s0 is used to set up a network with vlans, enp3s0 connects to a different local network.

enp3s0 ip 192.168.53.203/26
enp2s0 ip 192.168.8.1/24 

i have a switch set up at 192.168.8.239/24

How do i get to estabish a connection between my two nics so i can access the switch's web interface from the other local network.

us flag
Do you have appropriate routes set on the computers of the "other local network"? They need to have a route entry to `192.168.8.0/24` network.
Greg avatar
tc flag
Do i need it? its directly connected to enp3s0
us flag
Yes, the other computers in `192.168.53.203/26` network need to know how to reach the `192.168.8.0/24` network. Those computers are not directly connected to `enp3s0`.
Score:0
cn flag

To enable routing with Linux, "IP forward" has to be (permanently) enabled. IP forwarding is, in simple words, the ability to accept incoming network packets on one interface, recognize that it is not meant for the system itself, and forward it accordingly.

Edit /etc/sysctl.conf and search for the following lines:

#net.ipv4.ip_forward=1

Uncomment net.ipv4.ip_forward=1

Or do it with your terminal in one line:

sudo sysctl -w net.ipv4.ip_forward=1

Just make sure that your router has (working) interfaces in all your networks.

Greg avatar
tc flag
Sorry i forgot to mention that i have it enabled.
bjoster avatar
cn flag
The you are done. User your router as gateway or `route` destination, as long as the machine does have interfaces in the destination networks (and your targets know the route back to them) `ip_forward` will take care of everything.
Greg avatar
tc flag
Well i cant seem to get a ping from enp2s to enp3s nor reach it from outside the router...
bjoster avatar
cn flag
When an interface isn't responding to ping (on the same network), something other than ip_forward is going wrong.
Greg avatar
tc flag
I get a "Destination Host Unreachable" message. And i can see both interfaces sending out echo requests but thats about it.
bjoster avatar
cn flag
*Where* do you see "Destination Unreachable" and *where* do you see outgoing echo requests? If those are on the target network, triple check your route back.
Greg avatar
tc flag
PING 192.168.8.1 (192.168.8.1) from 192.168.53.203 enp3s0: 56(84) bytes of data. From 192.168.53.203 icmp_seq=1 Destination Host Unreachable Correction, they are ARP Requests
bjoster avatar
cn flag
Wen ARP is not successful, solve the cause, You will most likely have a layer 2 problem.
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.