Source code pulled from OpenBSD for OpenNTPD. The place to contribute to this code is via the OpenBSD CVS tree.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 lines
3.9 KiB

28 years ago
28 years ago
  1. #!/bin/sh -
  2. #
  3. # $OpenBSD: netstart,v 1.11 1996/09/23 13:06:37 deraadt Exp $
  4. # set these to "NO" to turn them off. otherwise, they're used as flags
  5. routed_flags=-q
  6. mrouted_flags=NO # for 'normal' use: mrouted_flags=""
  7. rarpd_flags=NO # for 'normal' use: rarpd_flags="-a"
  8. bootparamd_flags=NO # for 'normal' use: bootparamd_flags=""
  9. rbootd_flags=NO # for 'normal' use: rbootd_flags=""
  10. sendmail_flags=NO # for 'normal' use: sendmail_flags="-bd -q30m"
  11. named_flags=NO # for 'normal' use: named_flags=""
  12. timed_flags=
  13. # set the following to "YES" to turn them on
  14. rwhod=NO
  15. nfs_server=NO
  16. nfs_client=NO
  17. gated=NO
  18. kerberos_server=NO
  19. amd=NO
  20. ipfilter=NO
  21. portmap=YES # almost always needed
  22. inetd=YES # almost always needed
  23. lpd=NO # printing daemons
  24. # miscellaneous other flags
  25. # only used if the appropriate server is marked YES above
  26. gated_flags=
  27. amd_dir=/amd # AMD's mount directory
  28. amd_master=/etc/amd/master # AMD 'master' map
  29. ipfilter_rules=/etc/ipf.rules # Rules for IP packet filtering
  30. ipmon_flags=-s # To disable logging, use ipmon_flags=NO
  31. rfc1323=YES # TCP RFC1323 extensions (disable if tcp is slow)
  32. # /etc/myname contains my symbolic name
  33. #
  34. hostname=`cat /etc/myname`
  35. hostname $hostname
  36. if [ -f /etc/defaultdomain ]; then
  37. domainname `cat /etc/defaultdomain`
  38. fi
  39. # Configure the IP filter before configuring network interfaces
  40. #
  41. if [ X"${ipfilter}" = X"YES" -a -f "${ipfilter_rules}" ]; then
  42. echo 'configuring IP filter'
  43. ipf -Fa -f ${ipfilter_rules} -E
  44. else
  45. ipfilter=NO
  46. fi
  47. # configure all of the interfaces which we know about.
  48. # do this by reading /etc/hostname.* files, where * is the name
  49. # of a given interface.
  50. #
  51. # these files are formatted like the following, but with no # at the
  52. # beginning of the line
  53. #
  54. # addr_family hostname netmask broadcast_addr options
  55. # dest dest_addr
  56. #
  57. # addr_family is the address family of the interface, generally inet
  58. # hostname is the host name that belongs to the interface, in /etc/hosts.
  59. # netmask is the network mask for the interface.
  60. # broadcast_addr is the broadcast address for the interface
  61. # options are misc. options to ifconfig for the interface.
  62. #
  63. # dest is simply the string "dest" (no quotes, though) if the interface
  64. # has a "destination" (i.e. it's a point-to-point link, like SLIP).
  65. # dest_addr is the hostname of the other end of the link, in /etc/hosts
  66. #
  67. # the only required contents of the file are the addr_family field
  68. # and the hostname.
  69. (
  70. tmp="$IFS"
  71. IFS="$IFS."
  72. set -- `echo /etc/hostname*`
  73. IFS=$tmp
  74. unset tmp
  75. while [ $# -ge 2 ] ; do
  76. shift # get rid of "hostname"
  77. (
  78. read af name mask bcaddr extras
  79. read dt dtaddr
  80. if [ ! -n "$name" ]; then
  81. echo "/etc/hostname.$1: invalid network configuration file"
  82. exit
  83. fi
  84. cmd="ifconfig $1 $af $name "
  85. if [ "${dt}" = "dest" ]; then cmd="$cmd $dtaddr"; fi
  86. if [ -n "$mask" ]; then cmd="$cmd netmask $mask"; fi
  87. if [ -n "$bcaddr" -a "X$bcaddr" != "XNONE" ]; then
  88. cmd="$cmd broadcast $bcaddr";
  89. fi
  90. cmd="$cmd $extras"
  91. $cmd
  92. ) < /etc/hostname.$1
  93. shift
  94. done
  95. )
  96. # set the address for the loopback interface
  97. ifconfig lo0 inet localhost
  98. # use loopback, not the wire
  99. route add $hostname localhost
  100. route add -net 127 127.0.0.1 -reject
  101. # default multicast route
  102. route add -net 224.0.0.0 -interface $hostname
  103. # /etc/mygate, if it exists, contains the name of my gateway host
  104. # that name must be in /etc/hosts.
  105. if [ -f /etc/mygate ]; then
  106. route add default `cat /etc/mygate`
  107. fi
  108. # /etc/ifaliases, if it exists, contains the names of additional IP
  109. # addresses for each interface. It is formatted as a series of lines
  110. # that contain
  111. # interface address netmask
  112. if [ -f /etc/ifaliases ]; then
  113. (
  114. # delete comments and blank lines
  115. set -- `sed -e 's/#.*$//' /etc/ifaliases | grep -v '^$'`
  116. while [ $# -ge 3 ] ; do
  117. ifconfig $1 inet alias $2 netmask $3
  118. route add $2 localhost
  119. shift 3
  120. done
  121. )
  122. fi