Linux.com

Community Blogs



Naming Network Interfaces on LInux

Introduction

When the Linux kernel boots, it assigns names (eth0 etc..) to network devices in the order that it finds them. This means that two different versions of the kernel, say 2.4 and 2.6, might find the network interfaces in a diffent order. When this happens you might have to swap all the cables to get your connections to work the way you want. The proper way to do this is to name the interfaces with the nameif command (part of the net-tools).

You can install net-tools by running:

[root@host]# yum install net-tools

MACTAB and NAMEIF

The nameif command can be driven from the command line, if you want to do that, then read it's man page. Another way is to set up a /etc/mactab file to relate the MAC addresses of the network cards to the names you want.

Every NIC interface in the (known) universe has a unique MAC address (Media Access Control address), which is usually expressed as a 12 digit hexadecimal number, colon-dotted in pairs for readability.

You will need to find the MAC addresses of each of your network cards. The easiest way to find these (if you didn't make a note of the MAC label when you installed the card) is to use ifconfig, each interface that is configured will report its MAC address. e.g:

[root@host]# /sbin/ifconfig

eth0 Link encap:Ethernet HWaddr 00:60:97:52:9A:94
inet addr:192.168.1.3 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6043 errors:0 dropped:0 overruns:0 frame:0
TX packets:6039 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:1439604 (1.3 Mb) TX bytes:509857 (497.9 Kb)
Interrupt:10 Base address:0xc800

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:7218 errors:0 dropped:0 overruns:0 frame:0
TX packets:7218 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1085452 (1.0 Mb) TX bytes:1085452 (1.0 Mb)

Take note of the HWaddr, this the NIC's MAC address.

Now you can decide what you would like the NIC to be called, and set up your /etc/mactab, here's mine as an example:

# Begin /etc/mactab
# This file relates MAC addresses to interface names.
# We need this so that we can force the name we want
# even if the kernel finds the interfaces in the
# wrong order.

# eth0 under 2.4, eth1 under 2.6
cyberint 00:60:97:52:9A:94

# eth1 under 2.4, eth0 under 2.6
newint 00:A0:C9:43:8F:77

# End /etc/mactab

If you run nameif (without parameters) now you will probably get an error message, since nameif must be run when the interfaces are down.

[root@host]# nameif
cannot change name of eth0 to beannet: Device or resource busy

so, first take the interface down, then rename it:

[root@host]# ifconfig eth0 down
[root@host]# nameif
[root@host]# ifconfig eth0 up
[root@host]# ifconfig

cyberint Link encap:Ethernet HWaddr 00:60:97:52:9A:94
inet addr:192.168.1.3 Bcast:192.168.1.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6617 errors:0 dropped:0 overruns:0 frame:0
TX packets:6596 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:1748349 (1.6 Mb) TX bytes:598513 (584.4 Kb)
Interrupt:10 Base address:0xc800

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:9097 errors:0 dropped:0 overruns:0 frame:0
TX packets:9097 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1340480 (1.2 Mb) TX bytes:1340480 (1.2 Mb)

Using ifrename as a newer alternative

nameif has been obsoleted by the ifrename command.

To use the ifrename command first create the /etc/iftab file containing the new interface name and the corresponding MAC address like this:

ifname mac 00:16:3E:3B:B0:52

Bring the interface down and run:

[root@host]# ifrename

Then bring the interface up with the new name specified in the config file:

[root@host]# ifconfig ifname up

 

/etc/sudoers

The sudo command gives users access to otherwise inaccessible commands. The /etc/sudoers file makes use of 3 sets of groups to allow or deny access to commands on the nodes of a network.
 

UbuntuOne -- Selling a sevice? Or themselves?

I recently applied for the UbuntuOne beta program. It seems interesting enough, and sounds like a good idea. But the thing is, why is Canonical trying to hide a storage server and make it seem like it's so much more? What is UbuntuOne you say. Well here's a cap:

 

Sync your files, share your work with others or work remotely, all with your Ubuntu computer.Sync your files, share your work with others or work remotely, all with your Ubuntu computer. 

 

Well, that's not very descriptive now is it. If you go to the plans page, it will give you the option of choosing a 2GB (free) or 10GB (pay) for storage. I'm not saying that this is a bad thing. I'm just trying to say that disguising a FTP storage site as a brand new idea isn't very sportsmanshiplike.

So, am I going to buy an account? Probably. But I still don't like the cover up. Oh ya, and one more thing--Linux Mint had this first, with a storage site and their own FTP for access to it. Just some thoughts for chew.

 

Copy files recursive with folder hierarchy (rsync method)

rsync --include-from=/tmp/include.txt --exclude-from=/tmp/exclude.txt -aRvm ./src /tmp/dest

include.txt
>>*.pdf

exclude.txt
>>*.*

 

-a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)

-R, --relative              use relative path names

-m, --prune-empty-dirs      prune empty directory chains from file-list

-v, --verbose               increase verbosity

 

Stack Growth Direction.

#include <stdio.h>

void foo(int *);
int main(int argc, char *argv[])
{
int i;
foo(&i);
}
void foo(int *ii)
{
int j;
if ( &j <>
printf("I think the stack grows down.\n");
else if ( &j > ii )
printf("I think the stack grows up.\n");
else
printf("I'm really confused now.\n");
}
 

Good Luck

Good luck!linux.
 

NOOB's adventures in Linux From Scratch

 All I've got to say is if you're from the Windows world, there's no curveballs here. I breezed thru the X windows explanations all except the configuration files area without a hitch.

  Next up .... Getting things done in Linux    

 

Ha.

Well this is neat.
 

The Insufferable State of Linux Documentation

I've been waiting for a response from anyone from The Linux Documentation Project (tldp.org). Ghost town projects are normally not such a bad thing - often the page goes down and that's the end of it. Some projects are worth abandoning, as they become obsolete and are replaced by better things.

However, The Linux Documentation Project has been an institution in the Linux Community since 1992. Many of its guides and howtos are still relevant - Linux.com using them is proof enough of that.

The project is in bad need of an overhaul, though. There's little stylistic consistency between pages, the IRC channel (#tldp on freenode) is empty, the mailing lists are no longer a hotbed of activity. The simple steps of getting on the mailing list is made difficult by using an obsolete list program (Mailman could make signing up a snap). You cannot even get anonymous CVS access outside of their ancient CVS viewer.

Half of getting TLDP back on its feet won't even be working with the guides or howto's - it will be addressing the antiquated infrasture of the project itself.

 

A way to find a text string inside all files

# find / -type f -exec grep -l "word" {} \;
 

Learn How to Choose the CMS that’s right for you

Choosing an Open Source CMS is a new book from Packt that guides readers through understanding the different types of CMSs and selecting the one that best fits their needs. Written by Nirav Mehta, this book will help users assess their technical skill level and choose a CMS that combines ease of use with flexibility and power.

Open Source CMSs are the best way to create and manage sophisticated websites. Users can create a website that precisely meets their business goals, and keep the website up-to-date easily because these systems give them full control over every aspect of their website. Open Source CMSs are free to download, and have a vast choice between the various systems.

This book will show users how to avoid choosing the wrong CMS. It will guide users through assessing their website requirements, and based on this assessment, will help identify the CMS that will best fit their needs. It then talks about the major CMSs and the issues that users should consider when choosing, such as their complexity to use, their features, and the power they offer. Users will also be introduced to technical considerations such as programming languages, and compliance with best practice standards in a clear and friendly way.

Additionally, the book highlights many quick-start guides and examples for the most popular CMSs such as WordPress, Joomla! and Drupal. This allows users to experiment with these CMSs, get a feel of how they work, and start using them to build their website. The book also teaches users how to install and customize a CMS with themes and plug-ins. In addition to this, it covers practical tips on hosting, project management, working with specialists and communities, and finding experts.

Developers interested in creating a website by using a good CMS will find this book useful. This book is out now and is available from Packt. For more information, please visit: http://www.packtpub.com/choosing-an-open-source-cms-beginners-guide/book

 
Page 120 of 131

Upcoming Linux Foundation Courses

  1. LFD331 Developing Linux Device Drivers
    25 Aug » 29 Aug - Virtual
    Details
  2. LFD411 Embedded Linux Development
    25 Aug » 29 Aug - Santa Clara, CA
    Details
  3. LFS422 High Availability Linux Architecture
    08 Sep » 11 Sep - Raleigh, NC
    Details

View All Upcoming Courses


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board