0

Host_A
eth0: 192.168.1.3
wlan0: 192.168.43.84

Both interfaces have internet access. eth0 through DSL router 192.168.1.1 and wlan0 through android access point, 192.168.43.1. The default gateway is 192.168.1.1, but I can easily switch it to the other one using the following commands as root:

ip route delete default
ip route add default via 192.168.43.1

Afterwards, Host_A uses the android access point to the internet successfully.

Host_B
eth0: 192.168.1.14

This goes to the internet through the DSL router 192.168.1.1. I want it go out through the wireless access point, which essentially means it should go through 192.168.1.3. To this end I did the following

ip route delete default
ip route add default via 192.168.1.3

Also I have enabled packet forwading in Host_A using:

sysctl -w net.ipv4.ip_forward=1

Afterwards, cat /proc/sys/net/ipv4/ip_forward returns 1

The thing is, Host_B cannot got to the internet. I would like to have Host_B to have internet connectivity through Host_A wlan0 interface. Firewalls are disabled on both hosts and my conviction is that I should not have to mess with iptables to achieve this. Both hosts are Debian. Host_A and Host_B are on the same physical network using the DSL Router switching interface.

If anyone has any idea what could be wrong, I would be obliged.

Before Desired after

1

You should enable NAT in Host_A, telling it to route packets throutgh wlan0, this should do the trick:

iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
  • It did work, and I couldn't be happier it was so simple. Many thanks! Still I am kind at loss why NAT was required. Both DSL Router and the Android AP perform NAT. Since my hosts are in internal networks why is NAT on host_A required? I could not ask for such an answer here of course. A link to study something online if available would be great! @Fredi, many thanks again. – yannisf Dec 10 '16 at 18:18
  • 1
    Glad it worked. As on why, i found this question / answer that seems well explained: superuser.com/questions/994647/… – Fredi Dec 10 '16 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.