Your Ad Here

IBM AIX/UNIX system storage administration ksh/perl scripting

Showing posts with label routing. Show all posts
Showing posts with label routing. Show all posts

Friday, March 20, 2009

Using netstat and rmsock to Identify Processes Using the Default Gateway

Question

Is there a way to use netstat to find processes that are heavily using the default gateway?

Answer

You can use netstat and rmsock in combination to help find processes that are actively using the default gateway.

If path MTU discover is not enabled then temporarily enable it so you can get more information when using netstat. These are commands to enable the path MTU discover:

no -o tcp_pmtu_discover=1
no -o udp_pmtu_discover=1

The next step involves running netstat -rn and looking for the highest use count on the cloned route entries (those with a W flag - reference example 1).

Example 1

$ netstat -rn | grep -E "Use|UGHW"
Destination Gateway Flags Refs Use If PMTU Exp
Groups
9.0.7.1 9.41.166.1 UGHW 1 7 en2 - -
9.12.136.110 9.41.166.1 UGHW 2 123 en2 - -
9.17.183.166 9.41.166.1 UGHW 1 5 en2 1500 -
9.41.167.106 9.41.166.1 UGHW 1 3 en2 - -
9.41.167.182 9.41.166.1 UGHW 1 3373 en2 1500 -

In example 1 above, the destination address 9.41.167.182 has the highest use count (3373).

Next, check for any active sockets related to IP address 9.41.167.182 using the netstat -Aan command (see example 2):

Example 2

$ netstat -Aan | grep 9.41.167.182
705b21e4 tcp4 0 0 9.41.166.74.139 9.41.167.182.1039 ESTABLISHED

Use the process control block address (705b21e4) from the netstat -Aan output in example 2 with the rmsock command to find a process ID associated with the socket.

Example 3

# rmsock 705b21e4 tcpcb
The socket 0x705b2000 is being held by proccess 9394 (smbd).

With the help of netstat and rmsock in the preceding three examples, you were able to find a specific smbd process that had the most activity relative to sending data over the default gateway.

Monday, March 16, 2009

AIX using chdev to add/change/remove routing

# route delete default <IP>
# lsattr -El inet0 -a route
# chdev -l inet0 -a delroute="net,,0,<IP that is listed above>"
# chdev -l inet0 -a route="net,,0,<IP that it should be>"
# lsattr -El inet0 -a route
# netstat -nr


After updating the routing, you need to use mkdev to refresh it.


# mkdev -l inet0

Why you should NOT put two interfaces in same subnet

There are couple of reasons as an AIX system administrator you should NOT configure IP addresses that are in the same subnet in different interfaces.


1.Having two interfaces on the same network is a violation of TCP/IP
architecture.
.
In TCP/IP architecture, a host machine with two network adapters is
defined as an IP router. Differentnetwork adapters must be attached
to different physical networks. In the case of token-ring, TCP/IP
addresses multiple rings bridged together as a single logical ring
(as if it were a single physical ring).

2.Having two interfaces on the same network can cause broadcast storms.

Whenever an IP host sees traffic for a network whose IP address is diffe
rent from its own network, it generates an Internet Control Message
Protocol (ICMP) packet announcing this conflict. Since every host
on the network sees the traffic that is misaddressed, every host
generates ICMP Packets. If the amount of misaddressed traffic is signif
the ICMP traffic can grow to the point that network performance degrades



3 Having two interfaces on the same network can cause routing confusion.

If system has two interfaces on same subnet, inbound traffic will
from either interface, but for outbound traffic you need to set up
specific routes to use both otherwiese system will use one of them.

Tuesday, April 29, 2008

Routing issue on HACMP

Implement a set of preferences for the placement of service labels on IPAT via IP aliasing networks.
Options include:

1) Anti-collocation - this is the default - all labels are distributed across all boot labels using a least loaded selection process.
2) Collocation - all labels will be mapped to the same interface.
3) Anti-Collocation with persistent - Service labels will be mapped across all interfaces NOT holding the persistent label
4) Collocation with persistent - Service labels will be mapped to the same interface as the persistent label..
Note that these preferences will not affect availability - if there are not adequate interfaces to satisfy the preference, service and persistent labels will still be mapped to an active interface. if "Collocation with persistent" is selected, then the persistent address will always be the source IP address. . With "Anticollocation" or "Anti-Collocation with persistent" aliases my be distributed over several interfaces. There are multiple routing entries which are used in Round-Robin Mode by AIX. So the Source IP Address will not always be the same. . In a Single Adapter Network this APAR (with setting: "Collocation with persistent") is not necessary. In a Single Adapter Network the persistent IP Address should always be the source IP address. . The service IP Address will only be used as source IP, if there is no persistent address or if persistent address and service address are on diffrent interfaces....

If that is not an option, the only possibility is, that the application gets modified to bind to a specific IP as described by :

It seems to be the reason the questions are being asked is the statement by the customer : "The client is connected at IP1 ( 172.18.32.3 ) of the AIX lpar. The way back on the AIX lpar is possible over DG1 ( 172.18.32.30 ) and ( 10.40.139.254 ) DG2. The Multipath Routing default attitude is Weighted Round Robin. If the way back is made now by DG2 and not by DG1, the Firewall a IP recognizes Spoofing and communication is not possible." .

The core if the statement is just the words: "the Firewall a IP recognizes Spoofing and communication is not possible." . The source IP address of a packet being different is the real issue here. .

This is caused by applications making the wrong choice: (They have 2 choices in this regard) .

Choice #1: (antiquated, but still in use by legacy apps). this choice lets the routing table decide the source IP address of a reply packet. -Back when the internet was young (very young by todays standards) - then this did not cause too much trouble because it was a fact of those days that the only hosts with more than one interface were routers, and routers of those days were "dedicated" to being routers.. they generally did not also function as application servers. Application servers usually only had ONE route to any remote hosts, and so applications were coded to not even care which local address the query was sent to, they just let the OS`s routing table find the interface and put the IP on it as per the very simple (by todays` standards) routing table, because, like I said above - back then, there was only one route usually out of the machine, and it always led to the same interface, and it was pretty well guaranteed that it would be the same IP and same interface that any traffic came in on, - and then those replies were always going to be coming from the same address that they were sent to. . NOTE: Choice #1 (above) - is a bad choice in today`s multipath network environment. .

Choice #2: Server applications coded to "do it properly" in a multipath, asymmetric routing world we have today. (Asymmetric routing = the route there, is not always the route back). Such applications pay proper attention to the inbound packet (the call is "getpeername") and through such a series of API calls they can find out exactly which local IP address they were contacted on - so that when they send replies to such contact, they bind() the socket they are about to reply on TO that exact IP address before they send() the reply. This in no way affects how the packet will actually leave the machine (by the way) it can still follow the routing table to the destination - even leaving a different interface than the one which address is bound to. What`s important is that it will go out with the exact same source address that the packet it is an answer to came in on as a destination address. This is what is supposed to prevent "firewall troubles" . . It`s not just firewalls either - most new applications will not even accept (for security reasons) a packet coming form a different address than the one they sent a query to. A prime example is: the DNS server application "named" USED to have such a problem. (Not in the client - but in the server) - The DNS server would fail to follow choice #2 in it`s coding, and instead use choice #1. ---This worked for the early internet days where asymmetric routing (often caused by equal cost multipath) was not common at all. But - this had to be "fixed" in the named code at one point - because as people started to use asymmetric routes, it started to fail. . SO: The upshot is this: If you use a lot of legacy apps which are still using choice #1 in thier code.. (they will all soon die if they do not make coding corrections like the named daemon did) - then you are going to be restricted from using asymmetric routes along with these as these will not work. There has been an intermittent solution though, (instead of waiting for programmers to re-program all those legacy apps) that STILL lets you use asymmetric routes along with such apps: The VIPA interface. The AIX VIPA interface has the unique property of making applications which try to do a wildcard bind() bind only to it`s address. The VIPA can also be directed to use ANY interface to send traffic on - even though such traffic will always carry the IP of the VIPA instead of the one on whichever external interface it leaves the machine on. . The only thing you need is to give the routers any host-specific routes back to the VIPA using the hosts own external interface addresses as the gateways for such routes. . The routing policies then are only of concern to load balancing, or for higher availability, or for other traffic load control purposes. - But they are not effective against the issue brough up by "IP spoofing" as even without multipath routing, asymmetric routes can and do still exist. .

Labels

BlogCatalog