You are not logged in.

#1 2016-10-19 19:30:47

megavolts
Member
Registered: 2010-01-27
Posts: 4

PC as router/access point: how to configure wired connection

Hi All,

For years I've been able to solve most of my problem by reading forums and answer from the amazing community of Arch. Until this past week when I am not able to figure out how to make it works. First a brief description of my setup (or my attended setup), and then a few config that I am currently using and then, I will pass the keyboard to you, fellow users. Thanks a lot for this past year, and thanks in advance to help me on my case.

Leaving out of town in Alaska I do not have internet. My media/backup center [Islay] is connected through the wired interface to my router (eth0). This media center isn't on all the time, and I am using often the function wake on lan to start it. I have 2 small weather stations outside of my house, that are connected to the wireless. They back up weather data when Islay is online. I do use my phone/tablet to control the xbmc media center running on islay via the wireless network. I often upload/download new version of my thesis on islay via sftp. Sometimes I share the thered connection of my phone to my laptop through the whole network to update the media center

I am currently trying to replace my dying router by an old minipc [Mull] which will act as (1) the old router and (2) run a small phant server to let me upload in continuous the data from my station and display a simple webpage with basic information about the sensor reading. The wireless interface (wlan0) of the minipc is set to a fix IP (192.168.0.1). I was able to configure the AP with hostapd/dnsmasq and connect to it with my phone/tablet. I was able to set up the phant server and connect my weather station to log data on it. I am able to ssh from the phone to minipc or laptop.

                                                     |-------|<(wlan0)---WIRELESS---(uki0*)> tablet
Islay <(eth0)---WIRED---(eth0)> | Mull |<(wlan0)---WIRELESS---(wlp3s0)> laptop
                                                     |-------|<(wlan0)---WIRELESS---(ra0)> weather station
                                                     (usb0)
                                                         |
                                                TETHERED
                                                         |
                                                      (uki0*)
                                                      phone
* uki:unknown interface name

Here are my issue:
(1) I do have a problem to set up the wired network between Islay/Mull, with shared internet when tethered. Wether or not the eth0 IP address of the Mull is fix or not, wired interface of islay isn't able to get an IP address. I tried to set fixed IP on both device with identical submask, without success. For the various configuration I tried to add.

interface=eth0

in the dnsmasq config.  Any help will be welcome. Below the configuration file I use for hostapd and dnsmasq.

hostapd.conf

ssid=RedTrim
interface=wlan0
hw_mode=g
channel=1
driver=nl80211
macaddr_acl=0
ignore_broadcast_ssid=0
auth_algs=1

dnsmasq.conf

interface=wlan0
interface=eth0
bind-dynamic
dhcp-range=192.168.1.2,192.168.1.10,255.255.255.0,12h
domain-needed
server=8.8.8.8
bogus-priv

I had this following line in the dhcpcd.conf

denyinterfaces wlan0

Both hostapd and dnsmasq service once networking is up on wlan0:

BindsTo=sys-subsystem-net-devices-wlan0.device
After=sys-subsystem-net-devices-wlan0.device

(2) I was successful in sharing the internet connection from my phone with the wireless network. Using

net.ipv4.ip_forward=1

in sysctl and a NAT by setting the correct iptables rules:

iptables -t nat -A POSTROUTING -o usb0 -j MASQUERADE
iptables -A FORWARD -i usb0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i wlan0 -o usb0 -j ACCEPT

Will it be as easy to share it with the wired connection using eth0 rather than wlan0 in the above line?

(3) Will someone explains to me the difference between bind-dynamic and bind-interfaces in dnsmasq. When using bind-interfaces the services failed to start during the startup when either one of the interface is not ready or not connected. But I am able to launch it manually when I am logged in the console.

Thanks in advance for your help.

Offline

#2 2016-10-20 08:07:53

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: PC as router/access point: how to configure wired connection

This is very similar to a thread from you I have binned before. I'm giving you the benefit of the doubt but if I or any other member of the moderation team finds out that you are being deceptive and Mull turns out to be a raspberry pi there will be no further warning or reminder about following the code of conduct before punitive action is taken.

Let me just quote your last post for you in case you have forgotten:

megavolts wrote:

Hi All,

For years I've been able to solve most of my problem by reading forums and answer from the amazing community of Arch. Until this past week when I am not able to figure out how to make it works. First a brief description of my setup (or my attended setup), and then a few config that I am currently using and then, I will pass the keyboard to you, fellow users. Thanks a lot for this past year, and thanks in advance to help me on my case.

Leaving out of town in Alaska I do not have internet. My media/backup center [islay] is connected through the wired interface to my router (eth0). This media center isn't on all the time, and I am using often the function wake on lan to start it. I have 2 small weather stations outside of my house, that are connected to the wireless. They back up weather data when the Islay is online. I do use my phone/tablet to control the xbmc media center running on islay via the wireless network. I often upload/download new version of my thesis on islay via sftp. Sometimes I share the thered connection of my phone to my laptop through the whole network to update the media center

I am currently trying to replace my dying router by a small raspberry pi [RPi] which will act as (1) the old router and (2) run a small phant server to let me upload in continuous the data from my station and display a simple webpage with basic information about the sensor reading. The wireless interface (wlan0) of the RPi is set to a fix IP (192.168.0.1). I was able to configure the AP with hostapd/dnsmasq and connect to it with my phone/tablet. I was able to set up the phant server and connect my weather station to log data on it. I am able to ssh from the phone to RPi or laptop.

                                                     |------|<(wlan0)---WIRELESS---(?0)> tablet
Islay <(eth0)---WIRED---(eth0)> | RPi |<(wlan0)---WIRELESS---(wlp3s0)> laptop
                                                     |------|<(usb0)---TETHERED---(?0)> phone

Here are my issue:
(1) I do have a problem to set up the wired network between Islay/Pi. Wether or not the eth0 IP address of the RPi is fix or not, wired interface of islay isn't able to get an IP address. I tried to set fixed IP on both device with identical submask, without success. For the various configuration I tried to add

interface=eth0

in the dnsmasq config.  Any help will be welcome. Below the configuration file I use for hostapd and dnsmasq.

hostapd.conf

ssid=RedTrim
interface=wlan0
hw_mode=g
channel=1
driver=nl80211
macaddr_acl=0
ignore_broadcast_ssid=0
auth_algs=1

dnsmasq.conf

interface=wlan0
bind-interfaces
dhcp-range=192.168.1.2,192.168.1.10,255.255.255.0,12h
domain-needed
server=8.8.8.8
bogus-priv

I had this following line in the dhcpcd.conf

 denyinterfaces wlan0 

.

Both hostapd and dnsmasq service once networking is up on wlan0:

 BindsTo=sys-subsystem-net-devices-wlan0.device
After=sys-subsystem-net-devices-wlan0.device 

(1) I was successful in sharing the internet connection from my phone with the wireless network. Using

net.ipv4.ip_forward=1

in sysctl and a NAT by setting the correct iptables rules:

iptables -t nat -A POSTROUTING -o usb0 -j MASQUERADE
iptables -A FORWARD -i usb0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i wlan0 -o usb0 -j ACCEPT

Will it be as easy to share it with the wired connection using eth0 rather than wlan0 in the above line?

Thanks for reading so far.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#3 2016-10-20 16:14:48

megavolts
Member
Registered: 2010-01-27
Posts: 4

Re: PC as router/access point: how to configure wired connection

After one more night of fiddling around, and having a friend telling me to look towards bridge connection, I ended up to solve the problem. For the record, here is a little summary

(a) Configure interface on the router:
For eth0, modify /etc/systemd/network/eth0.network

[Match]
Name=eth0
[Network]
Bridge=br0

For wlan0, modify /etc/systemd/network/wlan0.network

[Match]
Name=wlan0
[Network]
Bridge=Br0

For br0, modify /etc/systemd/network/br0.network. Replace 192.168.1.1 by the address you want for your router

[Match]
Name=br0
[Address]
Address=192.168.1.1

And, modify /etc/systemd/network/br0.netdev

Name=br0
Kind=bridge

Then reboot.

(2) dnsmasq config in /etc/dnsmasq

interface=br0
dhcp-range=192.168.1.0,192.168.1.39,72h
domain-needed
server=8.8.8.8
bogus-priv

(3) For hostapd config in /etc/hostapd/hostapd.conf

ssid=RedTrim
interface=wlan0
hw_mode=g
channel=1
driver=nl80211
macaddr_acl=0
ignore_broadcast_ssid=0
auth_algs=1
bridge=br0

(4) to enable internet sharing between the bridge and usb0, add to iptables. Don't forget to enable iptables in systemd

iptables -A FORWARD -i br0 -s 192.168.1.0/255.255.255.0 -j ACCEPT
iptables -A FORWARD -i usb0 -d 192.168.1.0/255.255.255.0 -j ACCEPT
iptables -t nat -A POSTROUTING -o usb0 -j MASQUERADE

Save the modification with

iptables-save > /etc/iptables.conf
iptables-restore < /etc/iptables.conf

(5) Enable IP forwarding in nano /etc/sysctl.conf

net.ipv4.ip_forward=1

Yes, indeed. And I do remember posting it and to reply to Rookie's suspicion, the Raspberry Pi nickname is Kiska. Mull is another computer I have at home, running ArchLinux on a x86 architecture. To follow diligently the rules of this forum - which do not support Arch Linux ARM - , I decided to turn Mull into my router to be able to get some help. So no need of punitive action. Since, I've been able to solve my problem for x86 Architecture, I may try later this month to configure another piece of equipment which require consumes less energy to act as a router. ;-)

Last edited by megavolts (2016-10-20 16:17:09)

Offline

Board footer

Powered by FluxBB