Operating System - Linux
1826775 Members
1484 Online
109702 Solutions
New Discussion

Re: RHEL5 need to re-ordering network interfaces

 
tanagool
Occasional Contributor

RHEL5 need to re-ordering network interfaces


My system install with RHEL5 and I have

eth0 to eth5

when I ran command

#ip addr

the list shown like :

eth2
eth4
eth0
eth5
eth3
eth1

The question is

How I manipulate this order. I need eth5 to be the first by this command

Note : "ip addr" will show the list of interface with ip , ordering by ifindex, how can i tell kernel to remember the sequence that I really need ?


Thx in advanced for any expert here :)
5 REPLIES 5
Steven Schweda
Honored Contributor

Re: RHEL5 need to re-ordering network interfaces

> The question is

My question is, "Why do you care?".

man sort
Matti_Kurkela
Honored Contributor

Re: RHEL5 need to re-ordering network interfaces

As far as I know, there is no way to manipulate the output order of "ip addr" - it reads the kernel structures and outputs the interfaces at the order it finds them.

However, if you need the information of eth5 in particular, why don't you say so to the system?

ip addr show dev eth5

This command will show you the information of eth5 *only*.

If you want to list all the interfaces in some particular order, you could do something like this:

for i in eth0 eth1 eth2 eth3 eth4 eth5
do
ip addr show dev $i
done

This script would output a listing similar to "ip addr", but ordered exactly as specified in the "for iface in..." line.

If you need to pipe the custom-ordered list into something, you need to either save the ordered-list routine into a separate script file, or put parentheses ( ) around the entire routine before the redirection, like this:

( for i in eth5 eth4 eth3 eth2 eth1 eth0
do
ip addr show dev $i
done ) | somecommand

MK
MK
tanagool
Occasional Contributor

Re: RHEL5 need to re-ordering network interfaces

OK , come to the point

I have snmpd install on this system and send the trap to SIM server through eth5.

when the trap send the source ip is the eth5 ip address , yes that correct but I sniff the packet and look into the snmp PDU, I found the agentaddress field is not the eth5 ip address but it is the ip address of the eth2.

I try to change many of snmpd.conf to fix the agentaddress but not work.

So, I realize the fact that snmpd will use first ip address list by "ip addr" command encap into the trap PDU.

So, I change my strategy to re-order the list of ifindex ,but it seem I am going to the kernel mazed. Fortunately, I found this forum that may be helpfull for me so I come and post.

Anyway, thx for all of you to posting any comment for my problem.

Today, I gonna to fix this problem by new strategy.

by disable the NIC card that is not belong to eth5 . I think may be the kernel will remember the new order.

B/r

:)
Matti_Kurkela
Honored Contributor

Re: RHEL5 need to re-ordering network interfaces

When you run "nslookup $(hostname -f)" on your RHEL5 system, which IP address do you get?

If it's the IP address of eth2, then this may be the procedure snmpd uses to find the agentaddress. In other words, the agentaddress would be the IP address associated with the fully-qualified hostname.

If this is true, it might be helpful to make sure that the IP address of eth5 is associated with the hostname in /etc/hosts file. If there are any other lines listing the hostname in /etc/hosts, re-order them so that the line with the IP address of eth5 is the first of them.

MK
MK
tanagool
Occasional Contributor

Re: RHEL5 need to re-ordering network interfaces

no output from nslookup

then add the eth5 ip address at the first line in /etc/hosts

service network restart

then send snmp trap

#!/bin/sh
snmptrap -v 1 -c public 10.235.35.220 enterprises.232 '' 6 11003 '' system.5.0 s `cat /proc/sys/kernel/hostname` enterprises.232.11.2.11.1 i 0 enterprises.232.11.2.8.1 s 'Test Trap'


but result still the same


:(