LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Red Hat (https://www.linuxquestions.org/questions/red-hat-31/)
-   -   change eth1 to eth0 ? (https://www.linuxquestions.org/questions/red-hat-31/change-eth1-to-eth0-815620/)

czezz 06-22-2010 05:00 AM

change eth1 to eth0 ?
 
Hello Red Hat users!
I'd like to ask you all for a simple thing on Slackware that I dont know how to do under RHEL 5.4.

Under Slackware 12.2 it is easy to change eth0 to eth1.
This should be done in file: /etc/udev/rules.d/75-network-devices.rules:
Code:

KERNEL=="eth?", ATTR{address}=="00:0c:29:a3:ed:27", NAME="eth1"
KERNEL=="eth?", ATTR{address}=="00:0c:29:a3:ed:31", NAME="eth0"
KERNEL=="eth?", ATTR{address}=="00:0c:29:a3:ed:3b", NAME="eth2"
KERNEL=="eth?", ATTR{address}=="00:0c:29:2b:7c:a0", NAME="eth3"
KERNEL=="eth?", ATTR{address}=="00:0c:29:2b:7c:aa", NAME="eth4"
KERNEL=="eth?", ATTR{address}=="00:0c:29:2b:7c:b4", NAME="eth5"

and execute:
Code:

# /etc/rc.d/rc.udev restart
... to restart udev.

Well, under Red Hat it looks slight diffrent. It looks like RHEL does not use udev ( correct me if i am wrong but there is no simillar file in /etc/udev/rules.d and cant see any script in /etc/init.d/).

I have found that all NIC configuration is stored in /etc/sysconfig/netwotk-scripts/ifcfg-ethx.
On this file it is possible to place varible: HARDWARE=
However after reboot it doesnt work.
So, my question is - how to assign eth[number] to specified MAC-addr ?

DrLove73 06-22-2010 11:15 AM

You need to change "X" in ethX both on the file itself AND inside. The "DEVICE=ethX" is actually used to identify what file is for what interface.

So if you change ifcfg-eth0 with:
Code:

DEVICE=eth0
BOOTPROTO=static
BROADCAST=xxx.ccc.vvv.95
HWADDR=40:61:86:63:EB:37
IPADDR=xxx.ccc.vvv.92
NETMASK=255.255.255.248
NETWORK=xxx.ccc.vvv.88
ONBOOT=yes
GATEWAY=xxx.ccc.vvv.94
TYPE=Ethernet
USERCTL=yes
IPV6INIT=no
PEERDNS=yes

to ifcfg-eth1 with :

Code:

DEVICE=eth1
BOOTPROTO=STATIC
BROADCAST=xxx.ccc.vvv.95
HWADDR=70:61:86:63:CD:54
IPADDR=xxx.ccc.vvv.92
NETMASK=255.255.255.248
NETWORK=xxx.ccc.vvv.88
ONBOOT=yes
GATEWAY=xxx.ccc.vvv.94
TYPE=Ethernet
USERCTL=yes
IPV6INIT=no
PEERDNS=yes

you are good to go.

smoker 06-22-2010 11:24 AM

Redhat does use udev, but not for this purpose AFAIK.
Also, see this howto.

czezz 06-23-2010 01:55 AM

DrLove73... come on!
I have just written that ifcfg-ethX (where X = 1,2,3,4,5,6,7,8,9...n).
The scripts ifcfg-ethX doesnt work well after reboot.

I have machine with 20 network interfaces (eth0 to eth19).
Its a real problem to me.

I have also find that MAC addr are set in /etc/sysconfig/hwconf file which is managed by kudzu. Is this good idea to make changes there ?

Come on Red Hat users! On Slackware it's a pice of cake ;)

DrLove73 06-23-2010 03:13 AM

You can always create a bash script to change them. And you only really need to change the DEVICE=ethX line (2 letters max) and file name ( also 2 letters max).

Those files can carry MUCH more informations then meets the eye, and they do not require HWADDR line. You can place it in only 1-2 files and the rest will get them in order kernel finds them and enumerates them.

Combined with ifcfg-ethX files are route-ethX where you can set your entire static routing.

Since you can also have ifcfg-br0 files, you can create bridges from files and by only changing insides of the ifcfg-eth0 you can make them members of those bridges.

Another good thing is that you can (for laptops mostly) many different ifcfg-XXXXXXXX files all with similar but different contents and activate them as you see fit. File names are not important for deciding the interface name, just are handy for human recognition. For example, if you are in your office, run "ifup ifcfg-eth0_office". When you reach your home, run "ifdown ifcfg-eth0_office; ifup ifcfg_eth0_home". Since GATEWAY=xxx.xxx.xxx.xxx can also be the part of the ifcfg-ethX file, you effectively should change your default route also (Most of us use NetworkManager and network profiles to do this for us (/etc/sysconfig/networking/profiles).

Virtual IP's are also easy to create. You just create/copy file ifcfg-ethX:0(1,2,...), change IP information and remove all the necessary lines and activate those interfaces or entire network service and that is it.

I also bet they it is much harder to change MAC address on the Windows you are writing from then from the Linux-es we are writing from ;)

czezz 06-23-2010 01:15 PM

DrLove73 - why u r still writing about ifcfg-eth scripts ?
I have answered u that it doesnt work after reboot. AI have also written that at beginning of this topis.

Please stop repeating what ifcfg scripts can do.
Im looking for a file where I can assign MAC addr to ethX.
That is why I have shown example with Slackware.

DrLove73 06-23-2010 06:10 PM

You wrote:
Quote:

Originally Posted by czezz (Post 4011165)
On this file it is possible to place varible: HARDWARE=
However after reboot it doesnt work.

Variable is HWADDR, not HARDWARE. Check my examples.

Quote:

Originally Posted by czezz (Post 4012870)
DrLove73 - why u r still writing about ifcfg-eth scripts ?
I have answered u that it doesnt work after reboot. AI have also written that at beginning of this topis.

Please stop repeating what ifcfg scripts can do.
Im looking for a file where I can assign MAC addr to ethX.
That is why I have shown example with Slackware.

I successfully changed the order of the eth interfaces by changing the HWADDR line in ifcfg-ethX many times. That is why I am still writing about it. As far as I know, this is the ONLY way to pair up MAC address to a speific ethX interface on RHEL/CentOS/Fedora.

czezz 06-24-2010 02:15 AM

DrLove73 - once again. Please stop repeating about ifcfg scripts. I told u many times above that it DOESNT WORK AFTER REBOOT (for sure - not for 20 int.). Also please note - Im not asking about ifcfg syntax.

I am looking for working solution.
Anyone know it ?

I also asked for /etc/sysconfig/hwconf which is for kudzu - is this good way ?

Does anyone is Red-Hat expert here ?


All times are GMT -5. The time now is 04:41 AM.