Score:0

Communication between two interfaces on same machine

co flag
sbx

How can I achieve communication between 2 clients connected to 2 interfaces. E.g. Client A connected to eth0 and Client B connected to wlan0? Both will get DHCP IP. enter image description here

Score:0
id flag

Seems like you have 2 options:

Option 1: Route traffic between LAN & WLAN

This keeps the existing setup you have now pretty much and just routes traffic between LAN & WLAN as required.

First, enable IPv4 forwarding.

Second, configure iptables to permit traffic between the networks, which would look something like this:

sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
sudo iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT

The iptables change isn't persistent, but the link mentions a quick way to fix that. Alternatively you could just add these lines to your bashrc or something if you prefer.


Option 2: Bridge both interfaces together

Basically this would change the setup you have now from:

    eth0 --> LAN interface, 10.42.0.0/25 subnet
    wlan0 --> WLAN interface, 10.42.1.0/25 subnet

to something like this

    br0 --> LAN+WLAN interface, single subnet (can be 10.42.0.0/25 or 10.42.1.0/25)

To do this you would have to disable the DHCP server & remove the IP addresses associated with wlan0 and eth0 on the debian server, create a new bridge interface, and add them to it. You could do that with these commands:

#Install bridge utils
sudo apt-get install bridge-utils

#Create the bridge & add the interfaces
sudo brctl addbr br0
sudo brctl addif br0 eth0
sudo brctl addif br0 wlan0
sudo brctl show

#Set the IP on br0 (ex. 10.42.0.1/25) and turn up the link
sudo ip addr add 10.42.0.1/25 dev br0
sudo ip link set dev br0 up

Then, reactivate one of your DHCP servers (whichever is handling the subnet you decided to keep) on the br0 interface instead of what it was on before.

This would be similar to how most home Wi-Fi routers work. Keep in mind that this is bridge isn't persistent and will disappear after a reboot - you would need to create/edit the respective configuration files for netplan/network manager/whatever is handling networking on your server for it to survive a reboot. General instructions can be found here.

sbx avatar
co flag
sbx
Thank you @A. Trevelyan, can you check this setup please? I would like to go with Option 1, it's described in more detail there: https://serverfault.com/questions/1115223/debian-server-clients-cant-ping-between-interfaces-subnets?noredirect=1#comment1456640_1115223
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.