| « HOWTO: Setup Apache server on Fedora | HOWTO Setup autofs on Fedora » |
I assume you are reading this as you are getting annoyed with Network Manager screwing with your network configuration and breaking it each time you reboot. If you wanted a computer that broke and an OS that messed with your configuration you would be using Windows right!
To be able to turn off Network manager you need to create a new network interface configuration. Then bring down NM and stop it starting again.
To setup hand crafted network configurations we will edit and create files in /etc/sysconfig/network-scripts.
We will start with a basic configuration for eth0, getting its IP address from a DHCP server. This will also send the host name 'linux12' to the DHCP server. If you use dnsmasq this name can be used to return the same IP address every time for example. The hardware address is optional. If you have two or more network cards it will be used to help identify the actual hardware. Use a # to comment out any unwanted lines or to add comments.
In the above configuration file rather than hard coding the hostname we can use the output of the hostname command. This will have the same effect, which is to pass the hostname to the DHCP server. BUt it has the added bonus that if we ever change the hostname we do not have to edit tjis file as well. See my HOWTO Change The Hostname.
The new line will look like this
Now to setup a configuration for eth0 with an static IP address.
The options PREFIX (strange name as it is usually a suffix as in /24 ) and NETMASK do the same job. PREFIX is used in preference to NETMASK unless this is an alias or ippp device.
Okay, so now we have our hand crafted configuration, lets get rid of Network manager. ![]()
Now you can even go so far as, removing NM altogether.
Now you are back in control of your own network. Using a bridge or an alias is simple.
If you are running KVM or Xen you probably have your NIC bridged or would like to do so. This will allow the virtual machine(s) to access the outside world.
To make the bridge you will need to create a new device file called ifcfg-br0 and modify the file ifcfg-eth0. A bridged NIC can have either a static IP or a dynamic IP address. Using our dhcp example above the files should look similar to these
Things to note are; we now have a BRIDGE=br0 line in ifcfg-eth0 the br0 is the name of the bridge and used to name the config file for the bridge.
In the file ifcfg-br0, which is almost identical to the old eth0 file, we have a DEVICE=br0 and the TYPE is Bridge. (The word Bridge must have an upper case
.
the output from ifconfig now looks like this
br0 Link encap:Ethernet HWaddr 00:26:18:35:B5:10
The device eth0 no longer has an IP address but we have a new device called br0 and that does have an IP address.
To setup an aliased NIC for eth0 we will create eth0:1. For this to work eth0 can get its IP address from a DHCP server but eth0:1 cannot. So using the setup from above where eth0 was using a dynamic IP address we will add a second IP address via an aliased name.
Create a new file called ifcfg-eth0:1 with the following, I'm still using the example dhcp eth0 file from above and the NIC is NOT bridged.
After bringing the network back up again and running ifconfig you will see there are two IP addresses
eth0 Link encap:Ethernet HWaddr 00:26:18:35:B5:10
Your machine should also respond to a ping on both IP addresses.
But what happens if you want to have both a bridge and aliases on a single NIC. Well what about making an alias of the bridge :-). So in the same way we made an alias for the NIC we can also do that for a bridge see below.