Saturday, September 28, 2013

And then we connected

One of the first things I ever learned with RedHat systems was the file /etc/sysconfig/network-scripts/ifcfg-eth0 is used to configure the primary network adapter.
I say that I cannot always remember these settings off the top of my head, because I really don't remember all of them.
I remember that it should look something like this

DEVICE=eth0 
HWADDR=00:00:00:00:00:00
TYPE=Ethernet 
ONBOOT=YES
IP{something}=10.10.10.100 
GATEWAY=10.10.10.1
NETMASK=255.255.255.0 
BOOTPROTO=none

but there are so many more flags, that is just all i remember from the top of my head. Is this good enough to get by? Sure, but honestly, at this stage I should know all the command options available, like how to create a NIC bonding (ifcfg-bond0), or what NW_CONTROLLED=yes/no means.
So lets write this out in a little detail and get those brain cells firing and review the bulk of the options and what they are.

Device=eth0 
This one should be obvious, it is the name of the network card, it should be the same as the device listed in ifconfig, so if the device is eth1 the file name should be ifcfg-eth1 and be listed as DEVICE=eth1

HWADDR=00:00:00:00:00:00 
This is the mac address of the adapter. If you need to compare it do an ifconfig -a and it will show you all the details of all interfaces. Since I am currently working within a VM, I have two adapters, lo and eth0

[root@CentOS01 ~]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:0C:29:6E:8C:BD  
          inet addr:10.10.10.100 Bcast:10.10.10..255  Mask:255.255.255.0
          inet6 addr: 2601:9:1400:11c:20c:29ff:fe6e:8cbd/64 Scope:Global
          inet6 addr: fe80::20c:29ff:fe6e:8cbd/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:452 errors:0 dropped:0 overruns:0 frame:0
          TX packets:93 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:41651 (40.6 KiB)  TX bytes:12272 (11.9 KiB)

The HWaddr I happen to have landed is 00:0C:29:6E:8C:BD so this would be my MAC address.

TYPE=Ethernet
If it is a network adapter the the type is Ethernet, in general though, the TYPE= can be left out or matched to the type of device.

ONBOOT=yes
This means it will be enabled when the system reboots

IP{something}=10.10.10.100 
This turns out to be IPADDR= and this would be the IP address of the system. You can enter any acceptable IP address in this value, just make sure its on your network/subnet

NETMASK=255.255.255.0 
Without going into too much detail this is the subnet mask of your network. It is generally a 255.255.255.0 for a /24 and is adjusted with that range.

GATEWAY=10.10.10.1
I have noticed that the Gateway can live in different locations on the system, and can even be set manually with the route command. ( route add default gw 10.10.10.1 netmask 255.255.255.0)
I just like to put it in the ifcfg-eth0 file out of habit.


BOOTPROTO=none
This is mainly used to control if the server is on DHCP or static IP address. If you want to use DHCP change the BOOTPROTO=dhcp and this will overwrite all the IP Address settings you have configured. Don't believe me, try it out.

Now we get to the parts that I dont have fully commited to memory.

USERCTL=NO
This allows the standard user to interact with the interface. On servers it should be NO but on workstations YES is fine.

UUID=e89cd5ff-22ff-49b4-9d77-94777e90e6d3
This is just a unique identification number for the NIC, because sometimes you can run across a MAC address that is duplicated, think LARGE VMware environment. This number can be created and changed by running uuidgen and then copying the new number into its place. 

NM_CONTROLLED=no
By enabling this you give the Network Manager daemon control of the network device. 
This can be good or bad, but if you are having random issues, say the network card does not work on system boot, switch this to NO and setup the IP manually here. 


Ok so it turns out I do remember most of the options for making a network adapter work.
Also, do not forget to edit your /etc/resolve.conf with your DNS settings or else you will not get out. 

No comments:

Post a Comment