You are not logged in.

#1 2015-09-12 19:59:21

luancristian
Member
Registered: 2015-09-12
Posts: 7

[Solved] Internet forwarding not working (WiFi -> Ethernet)

Hello! I have a home server set up running Arch and unfortunately for now I'm stuck using Wireless on all my devices, including the server, so I would at least like to have an ethernet cable going from the server to my desktop to achieve 1Gb speeds between the two, and I'd like to forward the server's internet via ethernet.

I've followed the wiki page on Internet Sharing: https://wiki.archlinux.org/index.php/Internet_sharing

I'm using netctl-auto to connect automatically to my WiFi profile. After veryfing that I have no other IPTables rules active I execute the following commands:

ip link set enp3s0 up
ip addr add 192.168.25.10/24 dev enp3s0
sysctl net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -o wlp3s20u1 -j MASQUERADE
iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i enp3s0 -o wlp3s20u1 -j ACCEPT

And, on the desktop (which runs Arch too) I set the static IP: 192.168.25.10/24, Gateway 192.168.25.1 via XFCE's NetworkManager applet, yet I can't connect to the network/internet. Trying to ping the server (192.168.25.2) results in:

From 192.168.25.10 icmp_seq=1 Destination Host Unreachable

I tested with two different ethernet cables and just now tried it on my laptop and the same results on both devices.

I should mention that I'd prefer to not use any GUI tool on the server. Any help will be appreciated, thank you!

Last edited by luancristian (2015-09-14 08:00:44)

Offline

#2 2015-09-12 21:08:04

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [Solved] Internet forwarding not working (WiFi -> Ethernet)

You're giving *two* PCs the *same* address 192.168.25.10? They need to have unique IP addresses.

Offline

#3 2015-09-12 21:09:26

Webbeh
Member
Registered: 2012-07-08
Posts: 49

Re: [Solved] Internet forwarding not working (WiFi -> Ethernet)

EDIT: outspeed.

Last edited by Webbeh (2015-09-12 21:09:48)

Offline

#4 2015-09-12 21:40:21

luancristian
Member
Registered: 2015-09-12
Posts: 7

Re: [Solved] Internet forwarding not working (WiFi -> Ethernet)

brebs wrote:

You're giving *two* PCs the *same* address 192.168.25.10? They need to have unique IP addresses.

Yes, I was under the impression that the server and desktop's ethernet ports should be set to the same IP address, like so:
server-wlan 192.168.25.2
server-eth 192.168.25.10
desktop-eth 192.168.25.10

Thinking about it, it makes no sense, thank you. I changed the server's ethernet address to 192.168.25.3 and after executing the following:

# ip addr add 192.168.25.10/24 dev enp3s0
# ip link set up dev enp3s0
# ip route add default via 192.168.25.3 dev enp3s0 

on the desktop, I am now able to ssh into the server via my desktop but there is still no internet connection.

Edit: I also can't access the router/ping my laptop from the desktop.
Edit 2: As soon as I set the ethernet port up and define a static ip for it on the server, I can no longer connect to it from other devices on the network (it stops using the wifi adapter?)

Last edited by luancristian (2015-09-12 22:21:03)

Offline

#5 2015-09-13 09:12:31

Webbeh
Member
Registered: 2012-07-08
Posts: 49

Re: [Solved] Internet forwarding not working (WiFi -> Ethernet)

You should have different subnets for the wireless and ethernet cards on the server.

Example :
192.168.20.1 for server's wlan
192.168.25.1 for server's eth
192.168.25.10 for desktop's eth

Offline

#6 2015-09-14 02:49:57

luancristian
Member
Registered: 2015-09-12
Posts: 7

Re: [Solved] Internet forwarding not working (WiFi -> Ethernet)

I tried everything but can't make it work.

On the server:

  • NetForwarding is enabled.

  • Wireless conected to the internet, with IP address 192.168.25.2/24.

  • Ethernet port UP and set to 192.168.1.3/24.

iptables settings:

iptables -t nat -A POSTROUTING -o wlp3s20u1 -j MASQUERADE
iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i enp3s0 -o wlp3s20u1 -j ACCEPT

On the desktop

  • Disabled and stopped NetworkManager, no DHCP services running, just to make sure.

  • Ethernet port UP and set to 192.168.1.10/24.

Then:

# ip route add default via 192.168.1.3 dev enp3s0

Tested with two different cables. I can ssh into the server with 192.168.1.3 and 192.168.25.2 (wlan) but I can't ping the router (192.168.25.1) or my laptop (192.168.25.20).

Offline

#7 2015-09-14 05:53:35

Tomtix
Member
Registered: 2015-03-03
Posts: 5

Re: [Solved] Internet forwarding not working (WiFi -> Ethernet)

Maybe you have the exact same problem I have now that your configuration seems to be correct.
( I have made another topic just yesterday)
Try to find out (with tcpdump or wireshark) if forwarding and Masquerading works on the server (WIFI interface) when you ping a machine on the 192.168.20.x network from your client.

(#tcpdump -i wlp3s20u1    and look from PING REQUEST with the wlp3s20u1 interface's IP address, but which were originally sent by the client)

Last edited by Tomtix (2015-09-14 06:23:21)

Offline

#8 2015-09-14 07:23:25

Zeddi
Member
From: Germany near Bremen
Registered: 2009-08-30
Posts: 30

Re: [Solved] Internet forwarding not working (WiFi -> Ethernet)

To be sure - what is the IP of the Router?

Did you do "ip route add default via 192.168.1.3 dev enp3s0" on the desktop?

The router is wired to the desktop and the server, or wirelessly to the server?


I'm not very used to write English since i've left School, so please be patient!

Offline

#9 2015-09-14 08:00:22

luancristian
Member
Registered: 2015-09-12
Posts: 7

Re: [Solved] Internet forwarding not working (WiFi -> Ethernet)

Zeddi wrote:

To be sure - what is the IP of the Router?

Did you do "ip route add default via 192.168.1.3 dev enp3s0" on the desktop?

The router is wired to the desktop and the server, or wirelessly to the server?

The IP of the router is 192.168.25.1.
Yes.
Wirelessly to ther server.

Thanks for all your help, it is now working. I'm not exactly sure what made it work, but I changed three things on my server:

  • The wireless adapter is USB 2.0, it was connected to a USB 3.0 port, I connected it to a different port (2.0);

  • I created udev rules for naming the network devices: eth and wlan;

  • I disabled systemd.neworkd service.

I didn't change a thing at all on my desktop's configuration. I guess what could explain this was wrong device names on my script (before creating rules for them) but I had checked it and I'm pretty sure they were correct.
I find it hard to believe that using a USB 3.0 port would cause problems. Just switched the adapter again, working on the USB 3.0 port.
Could systemd.networkd have caused it?

Here is the script I add to my startup routine on the server:

#!/bin/sh
ip link set up dev eth
ip addr add 192.168.1.3/24 dev eth
iptables -t nat -A POSTROUTING -o wlan -j MASQUERADE
iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth0 -o wlan -j ACCEPT

Everything is working fine, thank you!

Offline

Board footer

Powered by FluxBB