Routing packages through other hosts in a wireless network

2

1

I have the following situation:

I have a wireless access point (192.168.42.1), with 3 hosts (access point and the hosts are running Linux, Debian distro) connected to it:

Host 1: 192.168.42.130

Host 2: 192.168.42.101

Host 3: 192.168.42.58

Is it possible to create a route between any pairs of nodes whose packets exchanged between them necessarily pass through Host 1? For example: if Host 2 and Host 3 exchange packets, the packets, in addition to passing through the access point, must pass through Host 1 as well. If so, how could I do this?

Best regards,

Higo.

HigoFelipe

Posted 2016-12-05T03:25:16.077

Reputation: 23

You are describing an ad-hoc Wi-Fi network, which connects two Wi-Fi hosts. It will not be the same network as your infrastructure network, where all frames must pass through a WAP. – Ron Maupin – 2016-12-05T03:31:15.813

Thanks for the response, @RonMaupin! I do not think it's an ad hoc wireless network, once I want to keep WAP. In addition to the packets traveling through WAP, my intent is for these packets to travel through another host on the network, in this case Host 1. – HigoFelipe – 2016-12-05T03:45:13.007

OK, you seem to be confusing layer-2 and layer-3. Frames on the same network (LAN) are delivered via layer-2 directly to the destination layer-2 address. Layer-2 doesn't care about layer-3 addresses. You couldn't do this on wired or wireless networks. ARP will give the source host the destination host's MAC address, and the layer-2 frame will be addressed with this as the destination address. The layer-2 bridge (switch or WAP) will deliver the frame directly to the destination host. – Ron Maupin – 2016-12-05T04:06:20.087

Do you need the packets to pass through Host 1 (so it can alter them), or is it enough if Host 1 can see all packets (as if it was on a LAN instead of WLAN)? In the latter case, sometimes you can configure your wireless access point to enable this (because by default on an encrypted WLAN connection, packets go directly between AP and client). In the former case, you must make sure your AP allows the hosts to see each other (verify with ping), and then you have to configure Host 1 as forwarding gateway for Host 2 and Host 3, and this is a bit of a headache to set up. – dirkt – 2016-12-06T07:49:22.833

@dirkt, I need the packets to pass through Host 1, so they can be captured by a sniffer. – HigoFelipe – 2016-12-20T21:12:23.993

Answers

-1

route del -net 192.168.42.0/24

Ipor Sircer

Posted 2016-12-05T03:25:16.077

Reputation: 3 578

Thanks, Ipor! Could you explain how this terminal command work? – HigoFelipe – 2016-12-05T03:38:51.750

Furthermore, in which host I run this command? – HigoFelipe – 2016-12-05T03:46:21.277

1You can't remove a route originated from a connected link. 192.168.42.0/24 is added automatically because its the network connected via wifi interface. – SuB – 2016-12-16T15:46:43.867

2

I suppose that you have configured your network with /24. In this case all hosts inside WiFi network are in the same Broadcast Domain. This means that you should use a L2 solution. The best way is manipulating ARP Cache. Suppose these are MAC address of wireless interface of your host:

Host 1 MAC Address = 11:11:11:11:11:11

Host 2 MAC Address = 22:22:22:22:22:22

Host 3 MAC Address = 33:33:33:33:33:33

Run following command on Host 2:

sudo arp -s 192.168.42.58 11:11:11:11:11:11

Run following command on Host 3:

sudo arp -s 192.168.42.101 11:11:11:11:11:11

Enable IP Forwarding on Host 1 by issuing following command:

sudo sysctl -w net.ipv4.ip_forward=1

Camle

Posted 2016-12-05T03:25:16.077

Reputation: 21

2Host1 will not forward packets. You need to enable IP Forwarding on the kernel. – Jim – 2016-12-16T15:51:39.257