Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Usefull Networking commands for Unix 12

Status
Not open for further replies.

ponetguy2

MIS
Aug 28, 2002
442
0
0
US
How to add a NIC card on Sun:

ifconfig hmeX plumb
ifconfig hmeX inet xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx
ifconfig hmeX up

How to change a hostname on Sun:

Make sure to use notepad or vi to edit files in order to avoid hidden characters.

There are four files that must be modified in order to rename the hostname:

1) /etc/hosts
2) /etc/net/ticlts/hosts
3) /etc/net/ticolts/hosts
4) /etc/nodename
5) /etc/hostname.hmex
6) /etc/net/ticotsord/hosts

Another way to change the hostname is by using sys-unconfig command. This restores the system to an unconfigured
state and should only be used when you are not concerned about preserving the current setup of the system. I suggest
looking at the man pages for further information (man sys-unconfig) or edit the following files above.

Note: rename the directory under /var/crash to match your new hostname.

Sun Solaris Servers Network Configuration Guide (SPARC Platform Only)


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 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 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.

To monitor packets traveling in your NIC ports
Example:
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

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

I just want to contribute a little bit.

enjoy,
ponetguy2
carlo reyes
sun solaris/linux admin for two years
 
Good one!

- Hemant
NSIG,
Satyam Computer Services Ltd
 
ponetguy2

Why don't you put this in an FAQ? There is some great stuff in here. As long as you credit your source (or ask your source's permission), I would think there wouldn't be any problem.
 
Good stuff.
Thanx - MM
 
First of all.....THANKS!!!!!


This info was indeed helpful. This is one for the FAQ's if you ask me. Again, much thanks, you saved me a considerable amount of time.


v/r,

Charlie U.

 
This info is great!

Can someon tell me how to change Gateway and Subnet Mask as well?

I need ot change the IP address in which I can use the infomation provided, but we are also changing the gateway as well as subnet.

Thanks!
 
Is netmask the equivalent as subnet mask? What would be the equivalent for the gateway?

Sorry for the stupid newbie questions!

Thanks!
 
>> netmask the equivalent as subnet mask?
yes

>> equivalent for the gateway?
you have to edit the routingtable, which is generated/derived from the Interfacerouting and the gateway defined in /etc/defaultrouter; You can change the IP of the interfaces and defaultrouter and reboot the system or edit the interfaces by hand using eg:
ifconfig hme0 10.43.22.4 netmask 255.255.255.0 broadcast 10.43.22.255
and edit routingtable (man route; best practise: use serial interface for editing interface and routing, since you can lock you out if something's wrong with this)
route del ...
route add ...

Best Regards, Franz
--
Solaris System Manager from Munich, Germany
I used to work for Sun Microsystems Support (EMEA) for 5 years
 
Thanks daFranze!
 
On my interface I have netmask ff000000 instead of an IP

Does this seem right?
 
can I see the output of ifconfig -a (as root?)

Best Regards, Franz
--
Solaris System Manager from Munich, Germany
I used to work for Sun Microsystems Support (EMEA) for 5 years
 
I've updated my webpage w/ a better list of networking commands for Sun Solaris and Windows.


Carlo Reyes

Technology/Systems - Delivery
Networks and Infrastructure

Chicago Customer Technical Support
 
telcomwork (TechnicalUser) 25 Feb 05 9:03
On my interface I have netmask ff000000 instead of an IP

Does this seem right?

Ifconfig will usually display the netmask in HEX, if you convert that to decimal it should read 255.0.0.0 I believe.

FF|00|00|00
255|0|0|0
 
this is okay coffeysm. here is an output from one of my servers:

gateadm@beast> cd /usr/sbin
gateadm@beast> ifconfig -a
lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
eri0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 10.66.2.214 netmask ff000000 broadcast 10.255.255.255
eri1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3
inet 90.81.213.1 netmask ffffff00 broadcast 90.81.213.255


If you want to see your netmask, go to /etc/inet and do a more or cat netmask.


Carlo Reyes

Technology/Systems - Delivery
Networks and Infrastructure

Chicago Customer Technical Support
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top