Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Added DNS support #51

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ binit_net_route=<addr/cidr>
Optional static on-link route(s) to add (can be given multiple times).
binit_net_gw=<addr>
Optional gateway config, if you want to connect via WAN. If ``binit_net_addr`` is set to ``dhcp``, it will be configured automatically.
binit_net_ns=<addr>
Optional dns servers. (can be given multiple times for multiple dns servers). If ``binit_net_addr`` is set to ``dhcp``, it will be configured automatically.
rw
Mount rootfs in read-write. Default: read-only.
mdev
Expand Down
1 change: 1 addition & 0 deletions sourceroot/bin/binit-udhcpc-script
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ case "$1" in
: > "${results}"
printf 'binit_net_addr=%s\n' "${ip}/${mask}" >>"${results}"
printf 'binit_net_gw=%s\n' "${router}" >>"${results}"
printf 'binit_net_nss=%s\n' "${dns}" >>"${results}"
;;
esac
14 changes: 14 additions & 0 deletions sourceroot/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ process_commandline_options() {
ro|rw)
root_rw_ro=$i
;;
binit_net_ns\=*)
# support multiple binit_net_ns=.
binit_net_nss="${binit_net_nss} ${i#*=}"
;;
binit_net_route\=*)
# support multiple binit_net_route=.
binit_net_routes="${binit_net_routes} ${i#*=}"
Expand Down Expand Up @@ -417,6 +421,16 @@ SetupNetwork() {
einfo "Setting default routing via '${binit_net_gw}' ..."
run ip route add default via "${binit_net_gw}" dev "${binit_net_if}"
fi

if [ -n "${binit_net_nss}" ]; then
einfo "Adding nameservers: ${binit_net_nss} ..."
set -f
for i in ${binit_net_nss}; do
printf 'nameserver %s\n' "${i}" >> /etc/resolv.conf
done
set +f
fi

}

setup_sshd() {
Expand Down