Instructions:

You need to do everything below as root.

1. Add an entry to /etc/name_to_sysnum for the sethostid system call.
For instance, I use the following line.
sethostid       177

Do not put any leading whitespace on the line in /etc/name_to_sysnum.

The important thing is to pick an unused syscall number. There
is also a limit on the number you can pick, which is determined
by the size of the sysent table. To find out what the limit is
you can use adb (only for Solaris 2.3 - just be reasonable if you
are using 2.4). For solaris 2.5 you can look at the NSYSCALL define
in /usr/include/sys/systm.h

adb -k /dev/ksyms /dev/mem
sysentsize/D
^D        #  i.e. control-D

You should be able to pick any unused syscall number between 1 and the
number output by adb above minus 1. Alternatively just use an unused
number which is less than the largest number which occurs in
/etc/name_to_sysnum

Now reboot your system.

2. Look at the makefile and check that the location of the C compiler is
right for your system. You do NOT want to get /usr/ucb/cc. gcc should
be OK.

If you are running Solaris 2.3 or 2.4 you MUST uncomment the define
-DPRE_SOLARIS_2_5 in the makefile. The results of not doing so are
unpredictable.

3. Type
make load

This should load the sethostid call. 

4. Type 
make sid

This makes the program that allows you to modify the hostid for
a particular group.

e.g. Now you can modify the hostid and hostname for group 900 to be 
23000000 and joe.test.com respectively by typing
./sid 0 23000000 joe.test.com

You'll probably want to make sure that joe.test.com is in whatever
name->ip address resolution scheme you use. (DNS,NIS, files)


6. If you like you can install sid and sethostid by typing
make install

If you do this, when you reboot, the sethostid module will be
automatically loaded when sethostid is called (i.e. when you run sid).

If you also need to "spoof" IP addresses, proceed as follows. Otherwise
you can stop here.

7. To make the system think it has additional IP addresses (say the one
   corresponding to joe.test.com) you can use ifconfig

   /usr/sbin/ifconfig lo0:1 joe.test.com up       # joe.test.com
   /usr/sbin/ifconfig lo0:2 192.1.1.1 up          # also be 192.1.1.1

   (you can also use le0:1 and le1:1 here as appropriate in which case
    you may not need to play with the routes below)

8. add a route to joe.test.com
    /usr/sbin/route add joe.test.com ratatosk 0
    (where ratatosk is the real name of the local host)

9. compile and link run (in ../run) if you haven't already done this.

10. If you are running YP/NIS you need to do the following
    run 0 /usr/sbin/rpcbind
    run 0 /usr/lib/netsvc/yp/ypbind -broadcast
there will be some console messages from rpcbind, but you will have
two copies of rpcbind.

You may also need to start up rpcbind as above for other applications.

11. If you want another host, say squirrel to be able to reach joe.test.com
    login to squirrel and execute
    route add joe.test.com ratatosk 1
    (where ratatosk is the real name of the local host)

    then from squirrel when you "telnet joe.test.com" you'll get to 
    ratatosk.


You can unload the system call as follows.

Type
/usr/sbin/modinfo

 You'll get output which includes a line which looks something like
76 fc42d000   621 177   1  sethostid (kern_hostid v1.0)

To remove the module type
/usr/sbin/modunload -i 76
Replace 76 by the first number in the line output by modinfo.


---
consider the following example with Viman
add host foobar to name database (NIS, NIS+, DNS, files) with IP address 
  120.120.120.120
make spoof-solaris2 and run

# sid 0 20202020 foobar
# ^D          # don't need to be root anymore
$ echoid
 
LicenseServ 3.3 Copyright (c) Viman Software Inc. 
    Host identification information utility
    Copyright (c) Viman Software Inc. 1992-94 
 
Host name       : bayt
Hostid          : 0x5720e31f
IP address(es)  : 192.168.9.4  
$ run 0 echoid
 
LicenseServ 3.3 Copyright (c) Viman Software Inc. 
    Host identification information utility
    Copyright (c) Viman Software Inc. 1992-94 
 
Host name       : foobar
Hostid          : 0x20202020
IP address(es)  : 120.120.120.120  
 

