Showing posts with label solaris. Show all posts
Showing posts with label solaris. Show all posts

Tuesday, 20 August 2013

Solaris: Which NIC is which MAC address?

So, you've got a server with several NICs in it and some are plumbed and some are not. How do you tell the mac address of each interface so you can marry it up to the output from ifconfig.

prtdiag & prtpicl are your friends

Here's an example

Well here's what's plumb'ed
# ifconfig -a
ipge2: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 10.185.32.152 netmask ffffffc0 broadcast 10.185.32.191
        ether 0:14:4f:48:5a:a0
ipge3: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3
        inet 192.168.0.1 netmask ffffff00 broadcast 192.168.0.255
        ether 0:14:4f:48:5a:a1
ipge4: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 4
        inet 10.185.32.56 netmask fffffff0 broadcast 10.185.32.63
        ether 0:15:17:e:a9:56


But here's what's plugged in
# dladm show-dev
ipge0           link: unknown   speed: 0     Mbps       duplex: unknown
ipge1           link: unknown   speed: 0     Mbps       duplex: unknown
ipge2           link: unknown   speed: 1000  Mbps       duplex: full
ipge3           link: unknown   speed: 1000  Mbps       duplex: full
ipge4           link: unknown   speed: 1000  Mbps       duplex: full
ipge5           link: unknown   speed: 0     Mbps       duplex: unknown
ipge6           link: unknown   speed: 1000  Mbps       duplex: full
ipge7           link: unknown   speed: 0     Mbps       duplex: unknown


So let's probe the server and see what NICs we have
# prtdiag|grep network
IOBD/NET0    PCIE IOBD                /pci@780/pci@0/pci@1/network@0    network-pciex8086,105e     
IOBD/NET1    PCIE IOBD              /pci@780/pci@0/pci@1/network@0,1    network-pciex8086,105e     
IOBD/NET2    PCIE IOBD                /pci@7c0/pci@0/pci@2/network@0    network-pciex8086,105e     
IOBD/NET3    PCIE IOBD              /pci@7c0/pci@0/pci@2/network@0,1    network-pciex8086,105e     
IOBD/PCIE1   PCIE    1                /pci@7c0/pci@0/pci@8/network@0    network-pciex8086,105e SUNW,pcie+
IOBD/PCIE1   PCIE    1              /pci@7c0/pci@0/pci@8/network@0,1    network-pciex8086,105e SUNW,pcie+
IOBD/PCIE2   PCIE    2                /pci@7c0/pci@0/pci@9/network@0    network-pciex8086,105e SUNW,pcie+
IOBD/PCIE2   PCIE    2              /pci@7c0/pci@0/pci@9/network@0,1    network-pciex8086,105e SUNW,pcie+


This is a T2000 so we've got 4 onboards, net0/net1/net2/net3
But we've also got 2 dual nic PCI-e cards by the look of it, PCIE1/2

So which ipge interfaces are bound to which NIC?

# prtpicl -v | egrep 'local-mac|devfs-path'
<snip>

 :devfs-path    /pci@7c0/pci@0/pci@2
                      :local-mac-address         00  14  4f  48  5a  a0
                      :devfs-path        /pci@7c0/pci@0/pci@2/network@0

                      :local-mac-address         00  14  4f  48  5a  a1
                      :devfs-path        /pci@7c0/pci@0/pci@2/network@0,1
                  :devfs-path    /pci@7c0/pci@0/pci@8
                      :local-mac-address         00  15  17  0e  a9  56
                      :devfs-path        /pci@7c0/pci@0/pci@8/network@0
                      :local-mac-address         00  15  17  0e  a9  57
                      :devfs-path        /pci@7c0/pci@0/pci@8/network@0,1

<snip>


Search the output looking for mac-address lines followed by a devfs-path line and marry that up with the prtdiag. So looking at my red highlighted example here we see.....
  • mac ending 5a:a0 is connected to onboard net2 and assigned ipge2
  • mac ending a9:57 is connected to PCI-e slot 1 (2nd interface to be precise) and assigned to ipge4

Simple when you know how.

Wednesday, 25 July 2012

The joys of SSH tunnels

We all now how to use a simple SSH tunnel to be able to remote desktop to a machine hidden behind a firewall.

For example create a tunnel to server1 to be able to RDP onto server2. In this example we'll use port 6000 so make sure nothing is running on that port on server1 first:
  • Use putty to ssh onto server1
  • Within putty create a local tunnel with a source port of 6000 and a destination port of server2:3389
  • Now point your rdp client to localhost:6000 and your connection to server2 magically opens

Now let's extend that to 2 tunnels. In this example we can't directly reach server2 that can reach our windows box called server3. We'll create a tunnel to server1, then another tunnel from server1 to server2 and finally server2 will create the connection to server3. Again we'll use port 6000 so check it's not being used on either server1 or server2.
  • Use putty to ssh onto server1
  • Within putty create a local tunnel with a source port of 6000 and a destination port of localhost:6000
  • Now connect to server2 from server1 like this:
ssh -L 6000:server3:3389 server2
  • Once your ssh session opens fire up remote desktop and point to localhost:6000 and your connection to server3 appears before your eyes.
SSH tunnels are truely wonderful.

Wednesday, 23 May 2012

How To Clear /var/adm/wtmpx

On Solaris if /var/adm/wtmpx has got so big as to break the last command or fill up all your disk space, here's how to fix it:

This will create a new wtmpx file with only the last 100 entries in it.
# /usr/lib/acct/fwtmp < /var/adm/wtmpx | tail -100 > /tmp/wtmpx.ascii
# /usr/lib/acct/fwtmp -ic < /tmp/wtmpx.ascii > /var/adm/wtmpx
# rm /tmp/wtmpx.ascii
fwtmp parses the wtpmx file and dumps out the last 100 entries in ascii to a file.
Rerun fwtmp with the -ic params will read this file and create an equivalent binary wtmpx file to replace yours.

Note: If fwtmp is not available on your system you'll need to install the system accounting packages SUNWaccu & SUNWaccr.