Discussion:
[9pi] standardize \ normalize setting dns in termrc.local through cmdline.txt
(too old to reply)
c***@rmqkr.net
2013-03-28 10:06:38 UTC
Permalink
In 9pi, the cmdline.txt allows defining an env var that is evaluated and used by /bin/termrc.local as line arguments for ip/ipconfig. e.g.

term% dossrv -f/dev/sdM0/dos
term% mount -c /srv/dos /mnt
term% cat /mnt/cmdline.txt
readparts=1 nobootprompt=local user=glenda ipconfig='-g 10.0.0.138 ether /net/ether0 10.0.0.13 255.255.255.0'
term%

This however is only sufficient in establishing an ip. For dns resolution it's necessary to add a dns ip to the ndb. e.g.

term% ehco ' dns=8.8.8.8'>>/net/ndb

What I'd like to ask is for termrc.local to have a dns option so something like dns='8.8.8.8 8.8.4.4' will add the entries properly.

R.K.

p.s. Manually adding "ehco ' dns=8.8.8.8'>>/net/ndb" works but I'd like a more "official" solution...
Jacob Todd
2013-03-28 12:02:22 UTC
Permalink
Then why don't you add it to termrc.local? That's what it is for.
Richard Miller
2013-03-28 12:41:42 UTC
Permalink
For a machine not receiving net configuration via DHCP, the normal
place to define dns= would be in /lib/ndb/local - 'man 6 ndb' for
information.
c***@rmqkr.net
2013-04-03 10:39:26 UTC
Permalink
Post by Richard Miller
For a machine not receiving net configuration via DHCP, the normal
place to define dns= would be in /lib/ndb/local - 'man 6 ndb' for
information.
Yes. I've already figured out that much:

term% cat /lib/ndb/local

database=
file=/lib/ndb/local
file=/lib/ndb/common

auth=sources.cd.bell-labs.com authdom=outside.plan9.bell-labs.com

ip=127.0.0.1 sys=localhost dom=localhost

ipnet=Home ip=10.0.0.0 ipmask=255.255.255.0
ipgw=10.0.0.138
dns=1.2.3.4 # (my isp's dns)
dns=8.8.8.8 # (googleA)
dns=8.8.4.4 # (googleB)
dns=10.0.0.138 # (my router for when the net is down but I still want local quarries getting through and local dom - .Home - requests)
auth=9pi
cpu=9pi

ip=10.0.0.13 sys=9pi

The thing is, the way I understand and implement it, you have your basic networking split in at least two places: The /lib/ndb/local file and the ip/ipconfig command arguments (being called from termrc.local...). Now, if there's a DHCP then you can forgo /lib/ndb/local and just specify an empty "ipconfig=". However, on a static ip you're only allowed to do everything except feeding it a dns.

My idea is to have a line or two added to termrc.local that will parse a single dns var from the cmdline.txt file. This way you can get the same convenience you'd get with DHCP in a static setup.

I'm not sure it's a possible needless un +\-foreseen complication, lack of interest, an oversight, a security concern or whatever... But it seems to me that it could simplify things a little.

Just a thought really ;)
c***@rmqkr.net
2013-04-03 10:39:35 UTC
Permalink
Post by Richard Miller
For a machine not receiving net configuration via DHCP, the normal
place to define dns= would be in /lib/ndb/local - 'man 6 ndb' for
information.
Yes. I've already figured out that much:

term% cat /lib/ndb/local

database=
file=/lib/ndb/local
file=/lib/ndb/common

auth=sources.cd.bell-labs.com authdom=outside.plan9.bell-labs.com

ip=127.0.0.1 sys=localhost dom=localhost

ipnet=Home ip=10.0.0.0 ipmask=255.255.255.0
ipgw=10.0.0.138
dns=1.2.3.4 # (my isp's dns)
dns=8.8.8.8 # (googleA)
dns=8.8.4.4 # (googleB)
dns=10.0.0.138 # (my router for when the net is down but I still want local quarries getting through and local dom - .Home - requests)
auth=9pi
cpu=9pi

ip=10.0.0.13 sys=9pi

The thing is, the way I understand and implement it, you have your basic networking split in at least two places: The /lib/ndb/local file and the ip/ipconfig command arguments (being called from termrc.local...). Now, if there's a DHCP then you can forgo /lib/ndb/local and just specify an empty "ipconfig=". However, on a static ip you're only allowed to do everything except feeding it a dns.

My idea is to have a line or two added to termrc.local that will parse a single dns var from the cmdline.txt file. This way you can get the same convenience you'd get with DHCP in a static setup.

I'm not sure it's a possible needless un +\-foreseen complication, lack of interest, an oversight, a security concern or whatever... But it seems to me that it could simplify things a little.

Just a thought really.
c***@rmqkr.net
2013-04-03 10:39:45 UTC
Permalink
Post by Richard Miller
For a machine not receiving net configuration via DHCP, the normal
place to define dns= would be in /lib/ndb/local - 'man 6 ndb' for
information.
Yes. I've already figured out that much:

term% cat /lib/ndb/local

database=
file=/lib/ndb/local
file=/lib/ndb/common

auth=sources.cd.bell-labs.com authdom=outside.plan9.bell-labs.com

ip=127.0.0.1 sys=localhost dom=localhost

ipnet=Home ip=10.0.0.0 ipmask=255.255.255.0
ipgw=10.0.0.138
dns=1.2.3.4 # (my isp's dns)
dns=8.8.8.8 # (googleA)
dns=8.8.4.4 # (googleB)
dns=10.0.0.138 # (my router for when the net is down but I still want
local quarries getting through and local dom - .Home - requests)
auth=9pi
cpu=9pi

ip=10.0.0.13 sys=9pi

The thing is, the way I understand and implement it, you have your
basic networking split in at least two places: The /lib/ndb/local file
and the ip/ipconfig command arguments (being called from
termrc.local...). Now, if there's a DHCP then you can forgo /lib/ndb/
local and just specify an empty "ipconfig=". However, on a static ip
you're only allowed to do everything except feeding it a dns.

My idea is to have a line or two added to termrc.local that will parse
a single dns var from the cmdline.txt file. This way you can get the
same convenience you'd get with DHCP in a static setup.

I'm not sure it's a possible needless un +\-foreseen complication,
lack of interest, an oversight, a security concern or whatever... But
it seems to me that it could simplify things a little.

Just a thought really.

p.s. This is my third or fourth attempt at a reply. The first two were
on the new groups interface. This attempt is on the old one. hopefully
those aren't coming out somewhere as double\triple\quadruple posts...
Richard Miller
2013-04-03 10:51:25 UTC
Permalink
Post by c***@rmqkr.net
My idea is to have a line or two added to termrc.local that will parse
a single dns var from the cmdline.txt file.
Go ahead. It's called termrc.'local' because it's your own local
configuration to play with as you like. There's no "standard". The
one on sources is an empty template, and the one on the raspberry pi
image is just an initial suggestion.
c***@rmqkr.net
2013-04-04 08:49:34 UTC
Permalink
Post by Richard Miller
Go ahead. It's called termrc.'local' because it's your own local
configuration to play with as you like. There's no "standard". The
one on sources is an empty template, and the one on the raspberry pi
image is just an initial suggestion.
Oh, I see. I'm just used to trying to separate code from data so much I thought a default that keeps the users from editing scripts is the norm and would get "upstreamed". In practice my concern was that I'll replica\pull over it by mistake... I suppose you can tell I'm a linux user :P
Post by Richard Miller
what does ndb/query sys $sysname say?
ip=10.0.0.13 sys=9pi ether=xxxxx... dom=9pi.Home
Ops. Good call. It returned the ip as the sysname. :)
All better now. Here's some breadcrumbs for any brave adventurers lucky enough to google this discussion:

term% cat /lib/ndb/local

#
# files comprising the database, use as many as you like, see ndb(6)
#
database=
file=/lib/ndb/local
file=/lib/ndb/common

auth=sources.cs.bell-labs.com authdom=outside.plan9.bell-labs.com

#
# because the public demands the name localsource
#
ip=127.0.0.1 sys=localhost dom=localhost

ipnet=HOME
ip=10.0.0.0
ipmask=255.255.255.0
ipsubmask=255.255.255.0
ipgw=10.0.0.138
auth=9pi
cpu=9pi
fs=9pi
dns=1.2.3.4
dns=8.8.8.8
dns=8.8.4.4
dns=10.0.0.138
dnsdomain=HOME

ip=10.0.0.13 sys=9pi dom=9pi.HOME proto=il

auth=10.0.0.13 authdom=9pi.HOME

term% ndb/query sys $sysname
ip=10.0.0.13 sys=9pi dom=9pi.HOME proto=il

Thanks !
Bence Fábián
2013-04-04 09:24:04 UTC
Permalink
Post by c***@rmqkr.net
term% cat /lib/ndb/local
#
# files comprising the database, use as many as you like, see ndb(6)
#
database=
file=/lib/ndb/local
file=/lib/ndb/common
auth=sources.cs.bell-labs.com authdom=outside.plan9.bell-labs.com
#
# because the public demands the name localsource
#
ip=127.0.0.1 sys=localhost dom=localhost
ipnet=HOME
ip=10.0.0.0
ipmask=255.255.255.0
ipsubmask=255.255.255.0
ipgw=10.0.0.138
auth=9pi
cpu=9pi
fs=9pi
dns=1.2.3.4
dns=8.8.8.8
dns=8.8.4.4
dns=10.0.0.138
dnsdomain=HOME
ip=10.0.0.13 sys=9pi dom=9pi.HOME proto=il
auth=10.0.0.13 authdom=9pi.HOME
term% ndb/query sys $sysname
ip=10.0.0.13 sys=9pi dom=9pi.HOME proto=il
Thanks !
Suppose you have

ip=10.0.0.13 sys=9pi1 dom=9pi.HOME proto=il

ip=10.0.0.14 sys=9pi4 dom=9pi.HOME proto=il

which one is this machine?
add the 'ether='

excerpt from my /lib/ndb/local:

ipnet=9front ip=10.0.2.0 ipmask=255.255.255.0
ipgw=10.0.2.2
dns=10.150.128.15

sys=thor ether=525400123456 dom=thor.9front
ip=10.0.2.15


and the output on my qemu terminal looks like this:

term% ndb/query sys $sysname
ip=10.0.2.15 ipmask=/120 ipgw=10.0.2.2 sys=thor dns=10.150.128.15
sys=thor ether=525400123456 dom=thor.9front ip=10.0.2.15
term%
erik quanstrom
2013-04-04 12:40:35 UTC
Permalink
Post by Bence Fábián
ipnet=9front ip=10.0.2.0 ipmask=255.255.255.0
ipgw=10.0.2.2
dns=10.150.128.15
5: r
Post by Bence Fábián
sys=thor ether=525400123456 dom=thor.9front
ip=10.0.2.15
term% ndb/query sys $sysname
ip=10.0.2.15 ipmask=/120 ipgw=10.0.2.2 sys=thor dns=10.150.128.15
sys=thor ether=525400123456 dom=thor.9front ip=10.0.2.15
term%
that doesn't look right. using the ndb excerpt posed,
i get this

; ndb/query -f /tmp/test.ndb sys thor
sys=thor ether=525400123456 dom=thor.9front

were some bits left out of your example?

- erik
Bence Fábián
2013-04-04 13:20:23 UTC
Permalink
I tried with a dummy file and I get the same results as you.
My guess (haven't checked anything) that it gets the other
information from /net/ndb.

However I'm in no way an ndb expert. Maybe someone
knowledgable can weigh in on this.
Post by Bence Fábián
ipnet=9front ip=10.0.2.0 ipmask=255.255.255.0
ipgw=10.0.2.2
dns=10.150.128.15
5: r
!/bin/upas/marshal -s 'Re: [9fans] [9pi] standardize \ normalize setting
Post by Bence Fábián
sys=thor ether=525400123456 dom=thor.9front
ip=10.0.2.15
term% ndb/query sys $sysname
ip=10.0.2.15 ipmask=/120 ipgw=10.0.2.2 sys=thor dns=10.150.128.15
sys=thor ether=525400123456 dom=thor.9front ip=10.0.2.15
term%
that doesn't look right. using the ndb excerpt posed,
i get this
; ndb/query -f /tmp/test.ndb sys thor
sys=thor ether=525400123456 dom=thor.9front
were some bits left out of your example?
- erik
erik quanstrom
2013-04-04 14:23:07 UTC
Permalink
Post by Bence Fábián
I tried with a dummy file and I get the same results as you.
My guess (haven't checked anything) that it gets the other
information from /net/ndb.
However I'm in no way an ndb expert. Maybe someone
knowledgable can weigh in on this.
it's possible to get some funny results if the file format
isn't just as ndb would like. ndb has some funny rules.
i wrote a little program ndb/vrfy (ndbvrfy(10);
http://9atom.org/magic/man2html/10/ndbvrfy
to help identify syntax errors in the file that can lead to
bad translations.

- erik

Richard Miller
2013-04-04 11:15:25 UTC
Permalink
Post by c***@rmqkr.net
my concern was that I'll replica\pull over it by mistake
pull will not update anything you have locally modified, unless
you explicitly tell it to with a '-s file-or-directory-name' parameter.
You get an error message instead.
Bence Fábián
2013-04-03 10:54:45 UTC
Permalink
what does ndb/query sys $sysname say?

try to add ether and dom like this:

ip=10.0.0.13 sys=9pi ether=xxxxx... dom=9pi.Home
Post by c***@rmqkr.net
Post by Richard Miller
For a machine not receiving net configuration via DHCP, the normal
place to define dns= would be in /lib/ndb/local - 'man 6 ndb' for
information.
term% cat /lib/ndb/local
database=
file=/lib/ndb/local
file=/lib/ndb/common
auth=sources.cd.bell-labs.com authdom=outside.plan9.bell-labs.com
ip=127.0.0.1 sys=localhost dom=localhost
ipnet=Home ip=10.0.0.0 ipmask=255.255.255.0
ipgw=10.0.0.138
dns=1.2.3.4 # (my isp's dns)
dns=8.8.8.8 # (googleA)
dns=8.8.4.4 # (googleB)
dns=10.0.0.138 # (my router for when the net is down but I still want
local quarries getting through and local dom - .Home - requests)
auth=9pi
cpu=9pi
ip=10.0.0.13 sys=9pi
The thing is, the way I understand and implement it, you have your
basic networking split in at least two places: The /lib/ndb/local file
and the ip/ipconfig command arguments (being called from
termrc.local...). Now, if there's a DHCP then you can forgo /lib/ndb/
local and just specify an empty "ipconfig=". However, on a static ip
you're only allowed to do everything except feeding it a dns.
My idea is to have a line or two added to termrc.local that will parse
a single dns var from the cmdline.txt file. This way you can get the
same convenience you'd get with DHCP in a static setup.
I'm not sure it's a possible needless un +\-foreseen complication,
lack of interest, an oversight, a security concern or whatever... But
it seems to me that it could simplify things a little.
Just a thought really.
p.s. This is my third or fourth attempt at a reply. The first two were
on the new groups interface. This attempt is on the old one. hopefully
those aren't coming out somewhere as double\triple\quadruple posts...
Loading...