networking

Setting up CentOS with no X Window Manager

For a nice VM I needed a Linux server, but no need for a GUI, so went for CentOS.

Installed fine, but no networking. How do I install that? Turns out, it is installed, just disabled by default:

vi /etc/sysconfig/network-scripts/ifcfg-eth0

Find the line ONBOOT and change to yes:

DEVICE=eth0
HWADDR=00:00:00:00:00:00:00 TYPE=ETHERNET
UUID=some guid string
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp

Then just restart networking at you should be up and running:

service network restart

Test by entering ifconfig and you should see the loopback address.

If you need to install Guest Additions on VirtualBox:

yum update
yum install gcc make kernel-devel
mkdir /media/cdrom
mount /dev/scd0 /media/cdrom
sh /media/cdrom/VBoxLinuxAdditions.run

Get MAC address from IP address

Had a routing issue the other day, and I was remotely trying to forward a port to a device. I didn’t know the MAC address of the device, and my Home Hub was insisting on that information for the forward destination. I knew the IP address, so there is a simple Windows command to get the MAC address from the IP address:

arp -a <ip_address>

I.e.

arp -a 192.168.1.70

Easy. This command works in Windows as well as Linux! Well theres a thing… It also works in Mac, but you drop the -a parameter:

arp 192.168.1.70

New install of Centos – No network

If you have just set up a new Centos server and found that the network isn’t functioning, and you have no IP address for it then fear not, its a ‘secure’ default for Centos to not enable networking until you are ready to do so.

cd /etc/sysconfig/network-scripts/ 
sed -i -e 's@^ONBOOT="no@ONBOOT="yes@' ifcfg-eth0

Then reboot.

If this doesn’t help, then double check the filename in that folder. You may have ifcfg-lo instead.

More help here: http://wiki.centos.org/FAQ/CentOS6#head-b67e85d98f0e9f1b599358105c551632c6ff7c90