You are not logged in.
I have spent several hours now, trying to script the sharing of my Internet connection for tethering my rpi2 from my X1C3. http://s.natalian.org/2015-04-08/share- … ection.txt I do realise there is the mess of https://wiki.archlinux.org/index.php/Internet_sharing but I am trying to develop a script. Perhaps you can please offer suggestions to improve it?
tether=enp0s25
#inet=wlp4s0
inet=enp0s20u1c4i2
First off, the interface names are fugly. Nothing new there. But is there an easier way to know which interface (wlp4s0 or enp0s20u1c4i2) is actually on the internet? I wish `networkctl status` showed the interface.
Btw I switch between tethering via wifi (when there is an wifi connection) and ipeth (enp0s20u1c4i2), my iPhone's 4G hotspot, when there is no wifi.
#ip addr add 192.168.0.1/24 broadcast 192.168.0.255 dev $tether
ip link set up dev $tether
ip addr add 192.168.0.1/24 dev $tether
# run twice and you get the fugly RTNETLINK answers: File exists
I much prefer ifconfig. It was simpler and idempotent. If I run this command twice I get RTNETLINK answers: File exists. There also seems to be several non-trivial ways to bring up the interface with `ip`. ARGH.
# configured in /etc/dhcpd.conf http://s.natalian.org/2015-04-08/dhcpd.conf
systemctl start dhcpd4@${tether}.service
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o $inet -j MASQUERADE
Next issue is that I need to run dhcpd4 on the tether interface or all hell can break loose. So I need the service file from https://wiki.archlinux.org/index.php/Dhcpd#Service_file PITA.
Next is iptables. This works until you switch from say 4G to wifi interface. Then clearing the iptables... omfg... I still have not figured out how to do this. Yes, I've tried `iptables -t nat -F`. Why is resetting iptables SO HARD? Please tell me it's going to be replaced by something not insane! My current workaround is to reboot. Seriously.
Ideally one can run these commands from memory when one does not have an internet connection. To the engineers behind the unusable interface of `ip` and `iptables`... you have made this incredibly difficult. I guess my sad hope if that systemd will replace this monstrosity with doing the right thing.
Last edited by hendry (2015-04-09 01:08:39)
Offline
I... trying to script the sharing of my Internet connection for my rpi2.
You'll have to ask on the archlinuxarm forums, these forums are for (i686 / x86_64) arch linux support only.
EDIT: Reopened upon request as this is sharing with an rpi from a regular archlinux system if I understand correctly. Sorry about that. But perhaps you could clarify, there was mention of tethering to a cell phone, and another connection, so it seemed the RPi was the system in question.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Perhaps take a look at this post:
https://bbs.archlinux.org/viewtopic.php?id=195795
I just managed to share an internet connection with a Raspberrypi from my laptop.
You'll need to ensure dhcp is installed...
Offline
I'm not using dhcp, I'm using systemd-networkd on my host and on my rpi2 (the client). I don't think you actually need the FORWARD iptables rules btw.
That aside, any tips to avoid RTNETLINK answers: File exists when re-running the script?
Offline