Sun Solaris Servers Network Configuration Guide (SPARC Platform Only)
to change ip address, you can modify /etc/hosts, for default gateway, modify /etc/defaultrouter, /etc/netmasks and
reboot the box. However, if you need the changes temprorily use ifconfig.
To bind an IP address to a Network Interface Card
#ifconfig -a --- to check the configuration
#ifconfig qfe0 plumb --- to enable the first Network Interface Card
#ifconfig qfe0 <ip address> netmask <subnet> up --- to bind IP address, subnet, and enable the configuration
Create a file on /etc directory - hostname.qfe0 with hostname entry
Add entry on /etc/netmasks if IP address is on different subnet
Add entry on /etc/inet/hosts file with IP address and hostname
Example:
#ifconfig -a
hme0: flags=863<UP,BROADCAST,NOTRAILERS,RUNNING,MULTICAST> mtu 1500
inet 202.40.231.2 netmask ffffff00 broadcast 202.40.231.255
ether 8:0:20:9f:51:fe
#ifconfig qfe0 plumb
#ifconfig qfe0 202.40.231.3 netmask 255.255.255.0 up
#ifconfig -a
hme0: flags=863<UP,BROADCAST,NOTRAILERS,RUNNING,MULTICAST> mtu 1500
inet 202.40.231.2 netmask ffffff00 broadcast 202.40.231.255
ether 8:0:20:9f:51:fe
qfe0: flags=863<UP,BROADCAST,NOTRAILERS,RUNNING,MULTICAST> mtu 1500
inet 202.40.231.3 netmask ffffff00 broadcast 202.40.231.255
To change IP Address
#ifconfig qfe0 down --- to disable the first Network Interface Card
To remove Network Interface Card
#ifconfig qfe0 unplumb --- to remove the first Network Interface Card
To bind a virtual IP address to Network Interface Card
#ifconfig qfe0:1 plumb --- in some cases this is not needed if qfe0 has been plumb
#ifconfig qfe0:1 202.40.231.4 netmask 255.255.255.0 up
Create a file on /etc directory - hostname.qfe0:1 with hostname entry
Add entry on /etc/netmasks if IP address is on different subnet
Add entry on /etc/inet/hosts file with IP address and hostname
NOTE:
-If adding a quad
Network Interface Card, the naming convention will be qfe0, qfe1, qfe2, qfe3.
-If adding a single port Network Interface Card, the naming convention will be hme1, hme2, hme3.
-The onboard Network Interface Card is hme0
-If adding a virtual IP address, the naming convention will be hme0:1, hme0:2, up to hme0:3 only for hme0,
or qfe0:1, qfe0:2, up to qfe0:3 only for qfe0, depending on the number of hme and qfe port used.
To add or remove a static route
Example:
You want to add a static route to network 192.168.16.0 to your default gateway of 10.236.74.1
#route add -net 192.168.16.0 10.236.74.1
then create a script, so that when the system rebooted the route will automatically added
#cd /etc/rc2.d
#vi S168staticroute
Add the following line
route add -net 192.168.16.0 10.236.74.1
You want to add a static route to host 192.168.64.4 to your default gateway of 10.236.74.1
#route add 192.168.64.4 10.236.74.1
then create a script, so that when the system rebooted the route will automatically added
#cd /etc/rc2.d
#vi S168staticroute
Add the following line
route add 192.168.64.4 10.236.74.1
You want to delete the static route to network 192.168.16.0 to your default gateway of 10.236.74.1
#route delete -net 192.168.16.0 10.236.74.1
You want to delete the static route to host 192.168.64.4 to your default gateway of 10.236.74.1
#route delete 192.168.64.4 10.236.74.1
How to manually manipulate the Routing Table....
(18 December 2001)
The route command allows manual manipulation of the routing table. Its command format is:
route [-fn] add|delete [host|net] destination [gateway [metric]]
Here are some samples of how to use the route command:
Add a route
# route add net 10.10.20.0 kirk 1
Add a route using a network name
# route add net ufp enterprise-r 1
Add a default route
# route add default enterprise 1
Delete a route
# route delete net 10.10.20.0 enterprise-r
Get routing reports
# route monitor
Lookup & Display the route for a destination
# route get 10.10.20.0
Flush the routing table
# route flush
Add the multcast path for 224.0.0.0
# route add 224.0.0.0 `uname -n` 0
The metric between two machines increases by one each time a new router (gateway) is encountered in the path. RIP
automatically chooses the path with the lowest metric.
Checking routing table
-----------------------
netstat -rn - only works if logged in as root.
traceroute - doesn't work on a SUN machine up to version 2.7. Have to get it off the internet.
May have a version shipping with version 8.0. FIND OUT WHAT ELSE CAN BE USED FOR THIS!!!!!!
===========================================================================================================================================
TCP/IP SETTINGS
/etc/defaultrouter
#(default gateway) file should contain the text "defaultrouter", which is referenced in the hosts file.
/etc/hosts
#contains IP, hostname, DNS name of local machine, default gateway e.g.
10.20.3.193 beebfw1 beebfw1.icl.net
10.20.3.122 default router
/etc/netmasks
#contains local IP, any other interfaces and subnet masks e.g.
10.20.3.192 255.255.255.128
10.20.3.193
/etc/hostname.interface
#contains name that should be aliased in the hosts file. (bob.hme0).
Should have a hostname.interface entry for each interface defined.
If not, interface will not be defined if a server is rebooted (nasty)
/etc/resolv.conf
#contains name server information in the following format
domain icl.net
nameserver 192.168.45.3
/etc/nsswitch.conf
# remember, if using DNS to add "dns", for example - "hosts files dns"
===========================================================================
How do I find the speed my network card is at?
a. /usr/sbin/ndd -set /dev/hme instance 0
1. instance 0 - hme0
2. instance 1 - hme1
b. /usr/sbin/ndd -get /dev/hme transciever_inuse
1. 0 - onboard
2. 1 - offboard card (mii)
c. /usr/sbin/ndd -get /dev/hme link_status
1. 0 - down
2. 1 - up
d. /usr/sbin/ndd -get /dev/hme link_speed
1. 0 - 10Mb
2. 1 - 100Mb
e. /usr/sbin/ndd -get /dev/hme link_mode
1. 0 - half duplex
2. 1 - full duplex
===========================================================================
SNOOPING TIPS
snoop -d <interface_name> -o ./<filename> &
#writes snoop information from a particular interface to a specified file. (remember to kill the job when finished)
(-d means device, -o means save packets to a file)
snoop -d <interface _name> | grep <IP_address>
#displays snoop information for a specific IP address.
snoop -i <file_name> | more
#pipe filename created by snoop to more (-i means display previously captured packets)
How to monitor packets traveling in your NIC ports:
You want to monitor your hme0 port of packets coming from IP address 202.40.224.14
#snoop -d hme0 | grep 202.40.224.14
You want to monitor your qfe1 port of packets coming from host server1
#snoop -d qfe1 | grep server1
You want to monitor your hme1 ports of all packets
#snoop -d hme1
The default mode of snoop is summary, if you add the -V switch it logs in verbose summary.
The -v switch logs in verbose mode and is the most detailed. The -c n switch allows you to specify how many packets to capture.
===============================================================================
Cool Scripts!!!
#!/usr/bin/ksh
#
# Checks the speed and settings of Sun HME and QFE interfaces.
#
#
#
for i in `ifconfig -a | egrep "^hme|^qfe" | awk '/^[a-z]*[0-9]*: / {print $1}' | sed s/://`
do
device=`echo $i | sed s/[0-9]*$//`
instance=`echo $i | sed s/^[a-z]*//`
ndd -set /dev/$device instance $instance
duplex=`ndd -get /dev/$device link_mode`
speed=`ndd -get /dev/$device link_speed`
autoneg=`ndd -get /dev/$device adv_autoneg_cap`
case "$speed" in
"0") echo "$i is at 10 mbit \c";;
"1") echo "$i is at 100 mbit \c";;
*) echo "$i is at ??? mbit \c";;
esac
case "$duplex" in
"0") echo "half duplex \c";;
"1") echo "full duplex \c";;
*) echo "??? duplex \c";;
esac
case "$autoneg" in
"0") echo "with auto negotiation";;
"1") echo "without auto negotiation";;
*) echo "??? auto negotiation";;
esac
#!/usr/bin/ksh
#The following commands forces the speed to 100MBit/sec and switches autonegotiation off:
#
#
ndd -set /dev/hme instance 0
ndd -set /dev/hme adv_100fdx_cap 1
ndd -set /dev/hme adv_100hdx_cap 0
ndd -set /dev/hme adv_10fdx_cap 0
ndd -set /dev/hme adv_10hdx_cap 0
ndd -set /dev/hme adv_autoneg_cap 1
#The settings -script is finds out which speed is currently used. It also checks for
autonegotiation.
To hardcode the speed of the Network Interface Card
Example:
You want to hardcode 100Full Duplex for hme0
#ndd -set /dev/hme instance 0
#ndd -set /dev/hme adv_100fdx_cap 1
#ndd -set /dev/hme adv_100hdx_cap 0
#ndd -set /dev/hme adv_10fdx_cap 0
#ndd -set /dev/hme adv_10hdx_cap 0
#ndd -set /dev/hme adv_autoneg_cap 0
Create an input on the file /etc/system so that when your system is rebooted it will run the NIC in 100Full Duplex
automatically.
set hme:hme_adv_100fdx_cap=1
set hme:hme_adv_100hdx_cap=0
set hme:hme_adv_10fdx_cap=0
set hme:hme_adv_10hdx_cap=0
set hme:hme_adv_autoneg_cap=0
To check the status
#ndd /dev/hme \? --- displays all command options for ndd
#ndd /dev/hme link_status --- displays the hme0 link status
The above configurations should be followed in order.
1 = Capable/Enable
0 = Disable
hme1 = instance 1
hme2 = instance 2
hme3 = instance 3
The system on the other end of network cable should be hardcode to 100Full Duplex also. If the other end is a
switch, check your vendor manuals on how to do it.
===============================================================================
This is my personal note to myself when I'm working with Sun Solaris Systems. Use at your own risk.
Enjoy!!!!
Carlo Reyes