View previous topic :: View next topic |
Author |
Message |
garo Bodhisattva
Joined: 15 Jul 2002 Posts: 860 Location: Edegem,BELGIUM
|
Posted: Thu Apr 24, 2003 5:52 pm Post subject: How to get good names for networkdevices |
|
|
Do you always forget that your network card is named eth0 ?
Do you use gentoo as a router and always mix up the different network devices ?
Or maybe you are just bored and want to try something new...
Anyway, I will show you in this post how you can give eth0,eth1 and all your other networkdevices better names.
Let's take the following example: you have a gentoo box that uses:
-eth1 for the internet connection and you want to call this "inet"
-eth0 for the lan connection and you want to call this "lan"
1) login as root
2) create the file "/etc/init.d/nameif" with the following content:
Code: | #!/sbin/runscript
start() {
/sbin/nameif
/etc/init.d/adjustNetScripts.pl
}
|
3) make this file a executable:
Code: | chmod +x /etc/init.d/nameif |
4) open the file "/etc/init.d/net.eth0" and change the text:
Code: |
depend() {
use pcmcia
}
| into
Code: |
depend() {
need nameif
use pcmcia
}
|
5) rename this file to "/etc/init.d/net.lan"
Code: | mv /etc/init.d/net.eth0 /etc/init.d/net.lan |
6) Make a hard link from "/etc/init.d/net.lan" to "/etc/init.d/net.inet":
Code: | ln /etc/init.d/net.lan /etc/init.d/net.inet |
and remove the net.eth1 script:
Code: | rm /etc/init.d/net.eth1 |
7) create the file "/etc/mactab" with the following content:
Code: |
lan 00:00:00:00:00:00
inet 00:00:00:00:00:01
|
"00:00:00:00:00:00" has to be the MAC-adress of the networkinterface "lan" (eth0) and "00:00:00:00:00:01" has to be the MAC-adress of the networkinterface "inet" (eth1)
You can find the MAC-adress of the eth0 and eth1 with the command: and The MAC-address is behind the text "HWaddr"
8) remove the old and add the new networkdevices in the default runlevel
Code: |
rc-update del net.eth0 default
rc-update del net.eth1 default
rc-update add net.lan default
rc-update add net.inet default
|
9) If you have a firewall/router script change "eth0" and "eth1" in that script by "lan" and "inet"
10) If you compiled the drivers for your network interfaces as modules then you will have to edit your "etc/modules.d/aliases". If you compiled your 1st networkcard as module, you will see the following line: change this line has into (you probably use a other driver then 8139too, but that doesn't matter)
Do the same for eth1 if it's also a module
11) if you compiled eth0 as module then add the word lan to /etc/modules.autoload
if you compiled eth1 as module then add the word inet to /etc/modules.autoload
example: If you compiled them both as modules and your "/etc/modules.autoload" originaly contained: it should now contain:
12) create the file "/etc/init.d/adjustNetScripts.pl" with the following content:
Code: | #!/usr/bin/perl -w
open(ETH0,"/etc/init.d/net.eth0") || exit;
open(LAN,">/etc/init.d/net.lan");
while(defined($_=<ETH0>)){
print LAN $_;
if($_ eq "depend() {\n"){print LAN "\tneed nameif\n"}
}
close(ETH0);close(LAN);
unlink("/etc/init.d/net.eth0");
|
make this file executable with:
Code: | chmod +x /etc/init.d/adjustNetScripts.pl |
13) reboot and tell me if it works
I hope i didn't forget anything, tell me if i did.
Send me a PM if you find bugs/spelling errors or if you have suggestions/additions
I am planning to make a script that does everything automatic, I don't know when it's going to be ready, depends how lazy i am (i am guessing next week)
EDIT 1: step 10 and 11 added thanks to Toon
EDIT 2: added the "/bin/rm" line in the nameif script in step 2 (i noticed net.eth0 becomes created when you update the base layout) (the "/bin/rm" line disapeared in edit 3, it became a part of the script in step 12)
EDIT 3: added the script in step 12 and the "/etc/init.d/adjustNetScripts.pl" line in step 2 to start this script. (this is necessary to let the system work if you ever update the baselayout (with "emerge -u world" for example)) _________________ My favorite links this month:
- Surf Random
- Web-based SSH
- Stop Spam |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|