Bring up network interface and set up network connection on Fedora Linux (command line)
Saturday, March 15th, 2008Have you ever tried firing up a Linux VMware virtual machine configured with a static IP address on another machine? I did and I got into trouble with the local network and the Internet access.
In my case the vm was created by VMware Server on Linux and then copied onto my Mac and loaded in VMware Fusion. The appliance run in level 3 so it did not have any graphical environment (like KDE or Xfce) installed so all the configuration needed to be done on the command line.
The first symptom there was something wrong could be observed during the boot process when the following message popped up:
“Bringing up interface eth0: pcnet32 device eth0 does not seem to be present, delaying initialisation [FAILED]“.
After logging in as root I run this command just to make sure that was the case:
# /sbin/ifup eth0
… and got pretty much the same message as the one above.
I had a look at the VMware Fusion network device settings to ensure my wireless network card was bridged and connected and then run a set of commands described below.
1. Display all available network interfaces
# /sbin/ifconfig -a
eth1 Link encap:Ethernet HWaddr 00:0C:29:3E:42:B1
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:17 Base address:0x1080
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:560 (560.0 b) TX bytes:560 (560.0 b)
2. eth1 is down, so let’s assign some IP address and the subnet mask to it (please note we do not use DHCP here)
# /sbin/ifconfig eth1 10.0.1.7 netmask 255.255.255.0
3. Check the current routing table
# /sbin/route
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.1.0 * 255.255.255.0 U 0 0 0 eth1
4. Specify default gateway
# /sbin/route add default gw 10.0.1.1
5. Last step - specify the name server address using a command line editor called vi
# vi /etc/resolv.conf
nameserver 10.0.1.1
(:wq to save the changes and quit)
6. Voila, the routing table now shows everything has been set up correctly
# /sbin/route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.1.0 * 255.255.255.0 U 0 0 0 eth1
default 10.0.1.1 0.0.0.0 UG 0 0 0 eth1
That’s it, your virtual machine is back on the network and you can now check it by pinging any domain you like. And to make these changes available after reboot you might want create/edit the /etc/sysconfig/network-scripts/ifcfg-eth1 file. My one has the following contents:
DEVICE=eth1
BOOTPROTO=static
BROADCAST=10.0.1.255
HWADDR=00:0C:29:3E:42:B1
IPADDR=10.0.1.7
NETMASK=255.255.255.0
GATEWAY=10.0.1.1
NETWORK=10.0.1.0
ONBOOT=yes