1 TITLE: IANA /etc/{protocols,services}
3 AUTHOR: Seth W. Klein <sk@sethwklein.net>
6 How to get the protocols and services assigned numbers lists from
7 the IANA and install them in /etc.
13 This hint documents using the IANA[1] lists for /etc/services and
16 This is useful this because the samples from netkit-base[2] are rather
17 incomplete and GNU inetutils[3] doesn't include any. Also, the services
18 list is updated frequently.
23 Revision 1.7 - 2003-FEB-26
24 Information about what happens if an entry is missing
25 and how to find missing entries, support for aliases,
26 and the whois alias. This is a recommended upgrade.
27 Revision 1.6 - 2003-JAN-07
28 More robust services filter. This is a recommended upgrade.
29 It fixes a bug reported by Fire Dragon <fdragon@saturn.fdragon.org>.
30 Revision 1.5 - 2002-DEC-23
31 Improved filtering code. No significant functional changes.
32 Revision 1.2 - 2002-SEP-25
33 First complete version.
38 These instructions may need to be adapted to run on older LFS versions
39 which used mawk instead of gawk.
41 A HTTP client is also required. The instructins assume wget[4] but can
42 effortlessly be adapted for any web browser or URL fetching software.
47 Few aliases are included in /etc/services. For now, at least, i prefer
48 to start with the minimum and add bloat as it proves necessary.
50 If ever an entry or alias is missing you may be treated to the error:
51 getaddrinfo: Servname not supported for ai_socktype
53 If you find out what is missing _please_ report it to the maintainer listed
54 above. You may have to strace[5] the problem command to find out what it's
55 looking for. The various RFCs and such usually list the correct numbers
56 but it's probably faster to just check something like the NetBSD services
57 file which is available from their CVSWeb interface at
58 <http://cvsweb.netbsd.org/bsdweb.cgi/src/etc/services>.
60 I know of no other bugs in these instructions, but if you find one or have
61 a suggestion, please do email me at the adress listed above.
67 wget http://www.iana.org/assignments/protocol-numbers
68 cp /etc/protocols protocols.orig
69 echo "# See protocols(5) for more information." > /etc/protocols
70 cat protocol-numbers | tr -d '\r' | awk --re-interval '
71 match($0, /^[[:blank:]]+([[:digit:]]+)[[:blank:]]{1,5}([^[:blank:]]+)(.*)/, \
73 sub(/^[[:blank:]]*/, "", field[3])
74 printf "%-16s%-5s%-16s# %s\n", \
75 tolower(field[2]), field[1], field[2], field[3]
81 wget http://www.iana.org/assignments/port-numbers
82 cp /etc/services services.orig
83 echo "# See services(5) for more information." > /etc/services
84 cat port-numbers | tr -d '\r' | awk '
86 aliases["nicname"] = "whois"
89 /(^[^[:blank:]]+)([[:blank:]]+[[:digit:]]+\/[^[:blank:]]+)(.*)/,
91 sub(/^[[:blank:]]+/, "&# ", field[3])
92 printf "\"%s\"\n", field[1] > "/dev/stderr"
93 printf "%s%s%s%s\n", field[1], field[2],
94 (field[1] in aliases) ? " " aliases[field[1]] : "", field[3]
97 !/^#/ { if (!sub(/^ /, "#")) { sub(/^/, "# ") } }
104 [1] IANA: Internet Assigned Numbers Authority, http://www.iana.org/
105 [2] netkit-base: ftp://ftp.uk.linux.org/pub/linux/Networking/netkit/
106 [3] GNU inetutils: http://www.gnu.org/software/inetutils/inetutils.html
107 [4] wget: http://beyond.linuxfromscratch.org/view/cvs/basicnet/wget.html
108 [5] strace: http://www.wi.leidenuniv.nl/~wichert/strace/