UNIVERSITY OF MANCHESTER
School of Computer Science
JTL's Fedora Tips
Setting up networks
Here are some tips for setting up networks on Fedora, without resorting to using the GNOME/KDE network GUI `patronage'. In particular, if you believe networks should be independent of desktop and user and whether anybody is even logged on, and should be able to be started from scripts, etc., then read on! ;-)
Please feel free to pass me any constructive feedback by email. jtl{at}cs.man.ac.uk (you will need to edit the abstraction of the at sign). You can also suggest other topics for me to give some hints about.
Section links
Read first | General information |
Multi-use devices | Having multiple network setups for the same device |
Wired DHCP | Setting up a wired network: DHCP |
Wired Fixed IP | Setting up a wired network: fixed IP |
Wireless -- WEP | Setting up a wireless WEP network |
Wireless -- WPA | Setting up a wireless WPA network |
Search Google for Fedora network configuration |
Read first
On Fedora (and Red Hat), every network which `belongs' to the whole machine
(as opposed to an individual user) has configuration information stored in the
directory /etc/sysconfig/network-scripts
.
Each network has a file called ifcfg-X
where X
is
the name of the network. Often the the name, X
is the same as the
name of the device used by the network, but it does not have to be.
For example, you will probably find a file called ifcfg-eth0
which was placed there by the Fedora installation process. This probably
contains a configuration for using a wired network on device eth0
(the first wired ethernet port) that will work for a network using
Dynamic Host Control Protocol (DHCP).
Networks that need authentication keys (e.g. wireless ones) will also have
a file called keys-X
where X
is the name of the
network.
To start the network called X
from the command line or within
a script, we run the command ifup X
. And to shut it down we run
ifdown X
.
The configuration may specify the network should be started at boot up, in
which case it is started when either of the network
or the
NetworkManager
services are started. Otherwise it is to be
started on demand by a user or a script.
The configuration may state that ordinary users are allowed to start and
stop the network. Otherwise only root
can do so.
Multi-use devices
The name of a network does not have to be the same as the name of the device the network uses. You may wonder why that is useful.
For a mobile machine, you probably don't want any network started up at boot. Instead you want to start a network when you're ready, and you may need to start the right one for the location you are in. For example, you might have a wireless network for use at home, another for work, a third for when you visit your girl/boyfriend, your mum, etc.. Each of these will no doubt have different settings -- in particular different authentication keys.
So you set up ifcfg-home
and keys-home
to use
device wlan0
(the first wireless LAN card), and run ifup
home
and ifdown home
as you need to.
Then you pop to your work, and set up ifcfg-work
and
keys-work
also to use the same device. And you make another pair
of files for each of the places you frequent -- this way you never need to
re-enter the setup information when you go back to a place you have been to
before! ;-)
For a desktop machine, you might want to use the same wireless card sometimes to talk to a router, and sometimes to act as an ad-hoc network when the router is not available.
Back to topWired DHCP
Setting up a wired network: DHCP
Expand: Wired DHCP
Wired Fixed IP
Here is the contents of an ifcfg-X
file, where X
is the chosen name for the network, for use with device eth0
(the
first wired ethernet port) on a wired network which does not have a
Dynamic Host Control Protocol (DHCP) server on it, or for
some other reasion a fixed IP address must be used.
TYPE=Ethernet DEVICE=eth0 # Use the first wired ethernet port. ONBOOT=no # Do not start on machine boot. BOOTPROTO=none # Do not get IP and DNS info via DHCP. USERCTL=yes # Allow ordinary users to start/stop this network. NM_CONTROLLED=no # Tell NetworkManager to keep its pesky hands off! # The remaining values will depend on the details of the network. NETWORK=192.168.1.0 # The network address. NETMASK=255.255.255.0 # The network mask: so here 192.168.1.* are local IPs. PREFIX=24 # Another way of giving the netmask. IPADDR=192.168.1.20 # The IP address of this network node. GATEWAY=192.168.1.1 # The gateway to use for non-local destinations. DNS1=192.168.1.1 # The DNS server IP address. DOMAIN=mydomain # The default DNS domain for hostname lookups.
The order of the assignments does not matter. In fact the file is sourced by a shell script, and so these are shell variable assignments. Note: you thus cannot have spaces around the equals sign.
If you want this network started at boot up, change ONBOOT
to
yes
.
USERCTL
to no
.
I prefer setting NM_CONTROLLED
to no
so that the
pesky NetworkManager
service doesn't make `clever' assumptions
and change the configuration for me -- typically losing information I have
entered! In fact I disable the NetworkManager
service completely
-- it is designed for `passive users' for whom bad decisions are better than
none! :-)
Your IP address will have been assigned to you, along with your network
mask. The mask typically says how many bytes of the 4-byte IP address are the
same for all nodes on the local network. So, 255.255.255.0
allows
for 256 IP addresses on the local network (actually 2 addresses are reserved,
so really only 254). PREFIX=24
is another way of saying `the
first 24 bits of the 32 are fixed'. PREFIX=16
(equivalent to
NETMASK=255.255.0.0
) allows for 256*256-2 IP addresses on the
local network.
One machine on the local network will have a second network port connecting it to another, probably `wider' network, and will be set up to act as the gateway for your local network. The gateway forwards ethernet packets destined for non-local machines, possibly via a large number of hops, and forwards incoming packets fron non-local machines to the correct local one.
Another machine, possibly on the local network, possibly not, will be designated as the domain name service (DNS) server. This can turn hostnames into IP addreses, possibly because it knows such information, or because it can pass on such queries to another DNS server that knows. When such searches are made, any host names that are not fully qualified (i.e. they just have the host name, but not the leading domain name) are searched for in the default domain.
Back to topWireless -- WEP
Setting up a wireless WEP network
Expand: Wireless -- WEP
Wireless -- WPA
Setting up a wireless WPA network
Expand: Wireless -- WPA
Search Google for Fedora network configuration
Google