LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Using ifconfig without using 'ethX' (https://www.linuxquestions.org/questions/linux-newbie-8/using-ifconfig-without-using-ethx-817430/)

drydo 07-01-2010 10:49 AM

Using ifconfig without using 'ethX'
 
Hello (and thanks in advance for reading this)

I'm a relatively inexperienced with Linux, coming from a Windows background, and I struggling to solve a troublesome issue attempting to set a static ip address to a Live Debian USB Key. I know it is possible to utilise the 'ifconfig' function to set a static ip address and use 'route' to set the gateway, e.g.

ifconfig eth0 10.0.0.40 up
route add default gw 10.0.0.130 eth0

..however in both cases I need to explicitly set the 'eth0' to point at the appropriate adapter. However, this is where my problem is...

I'm creating a persistent USB key using the Debian Live CD, I'm going to create an image and then duplicate that image to a load of other USB keys. Again, not a problem as such but there are cases where I need to specify a static IP address and gateway rather than using DCHP.

And here's where problem raises its head.

Because I've created the key on another machine it has allocated 'eth0' to a specific MAC Address (assigned in /etc/udev/70-persistent-net.rules) but when I place it into machine with a different network adapter it is assigning to 'eth1' (and this increments up).

Ideally, if someone could point me in the right direction to either...

a) call 'ifconfig' and 'route' without having to identify the adapter or
b) change the script that is creating '/etc/udev/70-persistent-net.rules' so it overwrites the 'eth0' entry with the only applicavle network adapter for the current hardware.

...or any other solution that would be beneficial. Thank you for your time...

M

schneidz 07-01-2010 11:10 AM

this mite work [quick-and-dirty]:
Code:

device=`ifconfig -a | head -n 1 | awk '{print $1}'`
ifconfig $device 10.0.0.40 up
route add default gw 10.0.0.130 $device

[assuming that the first line in ifconfig -a is the device we care about]

smoker 07-01-2010 11:11 AM

http://www.science.uva.nl/research/a...InterfaceNames

catkin 07-01-2010 12:47 PM

If you delete /etc/udev/70-persistent-net.rules on the key then a new one will be created automatically during boot -- hopefully containing only eth0 for the MAC address of the current computer. If you want to use the key in several computers you could modify the shutdown scripts to delete /etc/udev/70-persistent-net.rules during shutdown.

drydo 07-06-2010 11:22 AM

Hi Everyone,

Thank you to you all for the advice. After some reading and playing the best direction was to simply delete the 70-Persistent file, in this case the file is created again and ties into the eth0 identifier.

w00t!

Thanks again!


All times are GMT -5. The time now is 08:31 AM.