Do, or do not. There is no ‘try’ |

Archive for August 10th, 2007

Aug/07

10

Solaris Networking Commands

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 netmask 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 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 mtu 1500
inet 202.40.231.2 netmask ffffff00 broadcast 202.40.231.255
ether 8:0:20:9f:51:fe
qfe0: flags=863 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 three years

No tags

Basics of IP networking

A Debian host may have several interfaces each with a different Internet Protocol (IP) address. Interfaces may be of several different types, including:

* Loopback: lo
* Ethernet: eth0, eth1
* Wi-Fi: wlan0, wlan1, wifi0,
* Token Ring: tr0, tr1
* PPP: ppp0, ppp1

There is a wide range of other network devices available, including SLIP, PLIP (serial and parallel line IP), “shaper” devices for controlling the traffic on certain interfaces, frame relay, AX.25, X.25, ARCnet, and LocalTalk.

Every network interface connected directly to the Internet (or to any IP-based network) is identified by a unique 32 bit IP address. The IP address can be divided into the part that addresses the network and the part that addresses the host. If you take an IP address, set to 1 the bits that are part of the network address and set to 0 the bits that are part of the host address then you get the so-called netmask of the network.

Traditionally, IP networks were grouped into classes whose net address parts were 8, 16 or 24 bits in length. This system was inflexible and wasted many IP addresses, so today IPv4 networks are allocated with network address parts of varying length.

IP addresses net mask length

Class A 1.0.0.0 – 126.255.255.255 255.0.0.0 = /8

Class B 128.0.0.0 – 191.255.255.255 255.255.0.0 = /16

Class C 192.0.0.0 – 223.255.255.255 255.255.255.0 = /24

IP addresses not in these ranges are used for special purposes.

There are address ranges in each class reserved for use on local area networks (LANs). These addresses are guaranteed not to conflict with any addresses on the Internet proper. (By the same token, if one of these addresses is assigned to a host then that host must not access the Internet directly but must access it through a gateway that acts as a proxy for individual services or else does Network Address Translation.) These address ranges are given in the following table along with the number of ranges in each class.

network addresses length how many

Class A 10.x.x.x /8 1

Class B 172.16.x.x – 172.31.x.x /16 16

Class C 192.168.0.x – 192.168.255.x /24 256

The first address in an IP network is the address of the network itself. The last address is the broadcast address for the network. All other addresses may be allocated to hosts on the network. Of these, the first or the last address is usually allocated to the Internet gateway for the network.

The routing table contains the kernel’s information on how to send IP packets to their destinations. Here is a sample routing table printout for a Debian host on a local area network (LAN) with IP address 192.168.50.x/24. Host 192.168.50.1 (also on the LAN) is a router for the corporate network 172.20.x.x/16 and host 192.168.50.254 (also on the LAN) is a router for the Internet at large.

# route

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

127.0.0.0 * 255.0.0.0 U 0 0 2 lo

192.168.50.0 * 255.255.255.0 U 0 0 137 eth0

172.20.0.0 192.168.50.1 255.255.0.0 UG 1 0 7 eth0

default 192.168.50.254 0.0.0.0 UG 1 0 36 eth0

* The first line after the heading says that traffic destined for network 127.x.x.x will be routed through lo, the loopback interface.
* The second line says that traffic destined for hosts on the LAN will be routed through eth0.
* The third line says that traffic destined for the corporate network will be routed toward gateway 192.168.50.1 also through eth0.
* The fourth line says that traffic destined for the Internet at large will be routed toward gateway 192.168.50.254 also through eth0.

IP addresses in the table may also appear as names that are obtained by looking up addresses in /etc/networks or by using the C Library resolver.

In addition to routing, the kernel can perform network address translation, traffic shaping and filtering.

This article can be found here

Setting your hostname

Setting up your hostname upon a Debian installation is very straightforward. You can directly query, or set, the hostname with the hostname command.

As an user you can see your current hostname with:

$ /bin/hostname

Example

To set the hostname directly you can become root and run:

/bin/hostname newname

When your system boots it will automatically read the hostname from the file /etc/hostname

Setting up DNS

When it comes to DNS setup Debian doesn’t differ from other distributions. You can add hostname and IP addresses to the file /etc/hosts for static lokups.

To cause your machine to consult with a particular server for name lookups you simply add their addresses to /etc/resolv.conf.

For example a machine which should perform lookups from the DNS server at IP address 192.168.1.1 would have a resolv.conf file looking like this:

search test.com

nameserver 192.168.3.2

Setting up IP address.

The IP addresses associated with any network cards you might have are read from the file /etc/network/interfaces.

A sample entry for a machine with a static address would look something like this:

# The loopback network interface

auto lo

iface lo inet loopback

# The primary network interface

auto eth0

iface eth0 inet static

address 192.168.3.90

gateway 192.168.3.1

netmask 255.255.255.0

network 192.168.3.0

broadcast 192.168.3.255

Here we’ve setup the IP addresss (192.168.3.90), the default gateway (192.168.3.1), and the netmask.

For a machine running DHCP the setup would look much simpler:

# The loopback network interface

auto lo

iface lo inet loopback

# The primary network interface – use DHCP to find our address

auto eth0

iface eth0 inet dhcp

(If you’re using a DHCP based setup you must have a DHCP client package installed – usually one of pump,dhcpcd or dhcp3-client.)If you make changes to this file you can cause them to take effect by running:

/etc/init.d/networking restart

Setting up Second IP address or Virtual IP address in Debian

If you are a server system administrator or normal user some time you need to assign a second ipaddress to your debian machine.For this you need to edit the /etc/network/interfaces file and you need to add the following syntax.Below one is the only example you need to chnage according to your ip address settings

auto eth0:1

iface eth0:1 inet static

address 192.168.1.60

netmask 255.255.255.0

network x.x.x.x

broadcast x.x.x.x

gateway x.x.x.x

You need to enter all the details like address,netmask,network,broadcast and gateways values after

entering all the values save this file and you need to restart networking services in debian using

the following command to take effect of our new ipaddress.

#/etc/init.d/networking restart

If you want to check your new ip is assigned or not use the following command

#/sbin/ifconfig

Setting your default gateway.

If you read the previous section then you’ll see that the default route for a hos with a static IP address can be set in /etc/network/interfaces.If you wish to view your current default route/gateway then you can run:

# netstat -nr

Kernel IP routing table

Destination Gateway Genmask Flags MSS Window irtt Iface

192.168.3.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0

0.0.0.0 192.168.3.1 0.0.0.0 UG 0 0 0 eth0

Alternatively you can use the route command:

# /sbin/route

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

192.168.3.0 * 255.255.255.0 U 0 0 0 eth0

default router 0.0.0.0 UG 0 0 0 eth0

(Here the see the hostname router instead of the IP address 192.168.3.1 – to avoid that run “/sbin/route -n”).

To change your default route you must first remove the current one:

/sbin/route del default gw 192.168.3.1

Once this has done you’ll have no gateway and be unable to talk to non-local hosts.Add the new route with :

/sbin/route add default gw 192.168.3.100

Network testing basics

Install netkit-ping, traceroute, dnsutils, ipchains (for 2.2 kernel), iptables (for 2.4 kernel), and net-tools packages and:

$ ping google.com # check Internet connection

$ traceroute google.com # trace IP packets

$ ifconfig # check host config

$ route -n # check routing config

$ dig [@dns-server.com] host.dom [{a|mx|any}] |less # check host.dom DNS records by dns-server.com

# for a {a|mx|any} record

$ ipchains -L -n |less # check packet filter (2.2 kernel)

$ iptables -L -n |less # check packet filter (2.4 kernel)

$ netstat -a # find all open ports

$ netstat -l –inet # find listening ports

$ netstat -ln –tcp # find listening TCP ports (numeric)

No tags

Designed by devolux