Pmbootstrap: Default usb ethernet settings after install

Created on 11 Oct 2017  路  12Comments  路  Source: postmarketOS/pmbootstrap

@MartijnBraam I think you added the default ip 172.16.42.2 for usb ethernet. It would be a good idea to add the route too by default so people would not need to add it manually every boot:
sudo route add default gw 172.16.42.2
I would propose to add a default nameserver too. It should be the users device and not an external dns server but if the user wanted he could change it as now the user has to do it manually anyway:
echo nameserver 192.168.1.1 | sudo tee /etc/resolv.conf

question

All 12 comments

@montvid not sure it's a good idea, especially for those who uses the wifi on the device.
If it's possible to set the default gateway only for the usb ethernet, without affecting the gateway of the wifi interface, then it should be ok.
What you think? I am correct?

@drebrez wifi and usb nameservers are same. Wifi is still working fine with:
sudo route add default gw 172.16.42.2

adding the default gateway for usb by default isn't very neat, it can probably better be added to an initfs hook. The only reason wifi works for you is because the dhcp client overwrites the default gateway. In the future the usb networking will probably be reversed so your host can get internet through the phone.

Kk so no default gateway but maybe a default route? How can I fix this so I would not need to enable it on every boot?
sudo route add default gw 172.16.42.2

@montvid you can configure that interface just as you would configure any other interface in Alpine: https://wiki.alpinelinux.org/wiki/Configure_Networking#IPv4_Static_Address_Configuration

@montvid default route is the same thing as the default gateway. The way to make it persistent is to make a initfs hook that executes that line. Not 100% sure about how that currently works but its probably in the wiki.

Creating initramfs hooks work by creating a postmarketos-mkinitfs-hook-... package. Check the usb-shell hook as example. (The code gets executed as root then, so no need for sudo.)

@montvid I suggest just configuring this in pmOS (see the link to Alpine wiki I posted above) instead of in initramfs, since you probably want those settings to apply again if you had to restart the networking service, or bounced the interface.

@montvid: Is this still relevant? You've written down the USB Internet wiki
article, which explains well how to do it manually. (I use it all the time,
thanks for that!)

It is revelant in a sense that I havent't found the exact commands for "sudo route add default gw 172.16.42.2" to persist between reboots and the wiki should include that because doing it manualy every reboot is annoying. If someone knows how to do that please write it down because I don't have the hours to find it myself. I can update the wiki afterwards with the solution.

Untested, but this should work in theory:

echo 'route add default gw 172.16.42.2' > /etc/local.d/usb_internet.start
chmod +x /etc/local.d/usb_internet.start
rc-update add local

That's based on this information:

/etc/local.d # cat README
This directory should contain programs or scripts which are to be run
when the local service is started or stopped.

If a file in this directory is executable and it has a .start extension,
it will be run when the local service is started. If a file is
executable and it has a .stop extension, it will be run when the local
service is stopped.

All files are processed in lexical order.

Keep in mind that files in this directory are processed sequentially,
and the local service is not considered started or stopped until
everything is processed, so if you have a process which takes a long
time to run, it can delay your boot or shutdown processing.

Awesome! It works! I will update the wiki, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

schvabodka-man picture schvabodka-man  路  6Comments

fynngodau picture fynngodau  路  3Comments

MartijnBraam picture MartijnBraam  路  6Comments

cmdr2 picture cmdr2  路  7Comments

craftyguy picture craftyguy  路  7Comments