| 1 |
swift |
1.1 |
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
|
|
<!DOCTYPE sections SYSTEM "/dtd/book.dtd">
|
| 3 |
|
|
|
| 4 |
|
|
<!-- The content of this document is licensed under the CC-BY-SA license -->
|
| 5 |
swift |
1.2 |
<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
|
| 6 |
swift |
1.1 |
|
| 7 |
jkt |
1.5 |
<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-net-start.xml,v 1.4 2005/07/14 10:22:46 fox2mike Exp $ -->
|
| 8 |
neysx |
1.3 |
|
| 9 |
swift |
1.1 |
<sections>
|
| 10 |
|
|
|
| 11 |
jkt |
1.5 |
<version>1.3</version>
|
| 12 |
|
|
<date>2005-12-22</date>
|
| 13 |
swift |
1.1 |
|
| 14 |
|
|
<section>
|
| 15 |
|
|
<title>Getting started</title>
|
| 16 |
|
|
<body>
|
| 17 |
|
|
|
| 18 |
|
|
<note>
|
| 19 |
|
|
This document assumes that you have correctly configured your kernel, its
|
| 20 |
|
|
modules for your hardware and you know the interface name of your hardware.
|
| 21 |
jkt |
1.5 |
We also assume that you are configuring <c>eth0</c>, but it could also be
|
| 22 |
|
|
<c>eth1</c>, <c>wlan0</c>, etc.
|
| 23 |
swift |
1.1 |
</note>
|
| 24 |
|
|
|
| 25 |
|
|
<note>
|
| 26 |
jkt |
1.5 |
This document requires you are running <c>baselayout-1.11.11</c> or better.
|
| 27 |
swift |
1.1 |
</note>
|
| 28 |
|
|
|
| 29 |
|
|
<p>
|
| 30 |
|
|
To get started configuring your network card, you need to tell the Gentoo RC
|
| 31 |
jkt |
1.5 |
system about it. This is done by creating a symbolic link from
|
| 32 |
|
|
<path>net.lo</path> to <path>net.eth0</path> in <path>/etc/init.d</path>.
|
| 33 |
swift |
1.1 |
</p>
|
| 34 |
|
|
|
| 35 |
swift |
1.2 |
<pre caption="Symlinking net.eth0 to net.lo">
|
| 36 |
swift |
1.1 |
# <i>cd /etc/init.d</i>
|
| 37 |
|
|
# <i>ln -s net.lo net.eth0</i>
|
| 38 |
|
|
</pre>
|
| 39 |
|
|
|
| 40 |
|
|
<p>
|
| 41 |
|
|
Gentoo's RC system now knows about that interface. It also needs to know how
|
| 42 |
|
|
to configure the new interface. All the network interfaces are configured in
|
| 43 |
swift |
1.2 |
<path>/etc/conf.d/net</path>. Below is a sample configuration for DHCP and
|
| 44 |
|
|
static addresses.
|
| 45 |
swift |
1.1 |
</p>
|
| 46 |
|
|
|
| 47 |
|
|
<pre caption="Examples for /etc/conf.d/net">
|
| 48 |
|
|
<comment># For DHCP</comment>
|
| 49 |
|
|
config_eth0=( "dhcp" )
|
| 50 |
|
|
|
| 51 |
|
|
<comment># For static IP using CIDR notation</comment>
|
| 52 |
|
|
config_eth0=( "192.168.0.7/24" )
|
| 53 |
|
|
routes_eth0=( "default via 192.168.0.1" )
|
| 54 |
|
|
|
| 55 |
|
|
<comment># For static IP using netmask notation</comment>
|
| 56 |
|
|
config_eth0=( "192.168.0.7 netmask 255.255.255.0" )
|
| 57 |
|
|
routes_eth0=( "default gw 192.168.0.1" )
|
| 58 |
|
|
</pre>
|
| 59 |
|
|
|
| 60 |
|
|
<note>
|
| 61 |
|
|
If you do not specify a configuration for your interface then DHCP is assumed.
|
| 62 |
|
|
</note>
|
| 63 |
|
|
|
| 64 |
|
|
<note>
|
| 65 |
swift |
1.2 |
CIDR stands for Classless InterDomain Routing.
|
| 66 |
swift |
1.1 |
Originally, IPv4 addresses were classified as A, B, or C.
|
| 67 |
|
|
The early classification system did not envision the massive popularity of the
|
| 68 |
|
|
Internet, and is in danger of running out of new unique addresses. CIDR is an
|
| 69 |
|
|
addressing scheme that allows one IP address to designate many IP addresses.
|
| 70 |
|
|
A CIDR IP address looks like a normal IP address except that it ends with a
|
| 71 |
|
|
slash followed by a number; for example, 192.168.0.0/16.
|
| 72 |
|
|
CIDR is described in <uri link="http://rfc.net/rfc1519.html">RFC 1519</uri>.
|
| 73 |
|
|
</note>
|
| 74 |
|
|
|
| 75 |
|
|
<p>
|
| 76 |
|
|
Now that we have configured our interface, we can start and stop it using the
|
| 77 |
|
|
below commands
|
| 78 |
|
|
</p>
|
| 79 |
|
|
|
| 80 |
|
|
<pre caption="Starting and stopping network scripts">
|
| 81 |
|
|
# <i>/etc/init.d/net.eth0 start</i>
|
| 82 |
|
|
# <i>/etc/init.d/net.eth0 stop</i>
|
| 83 |
|
|
</pre>
|
| 84 |
|
|
|
| 85 |
|
|
<impo>
|
| 86 |
fox2mike |
1.4 |
When troubleshooting networking, it is recommended to set
|
| 87 |
|
|
<c>RC_VERBOSE="yes"</c> in <path>/etc/conf.d/rc</path> so that you get more
|
| 88 |
|
|
information about what's happening.
|
| 89 |
swift |
1.1 |
</impo>
|
| 90 |
|
|
|
| 91 |
|
|
<p>
|
| 92 |
|
|
Now that you have successfully started and stopped your network interface, you
|
| 93 |
|
|
may wish to get it to start when Gentoo boots. Here's how to do this. The last
|
| 94 |
|
|
"rc" command instructs Gentoo to start any scripts in the current runlevel
|
| 95 |
|
|
that have not yet been started.
|
| 96 |
|
|
</p>
|
| 97 |
|
|
|
| 98 |
|
|
<pre caption="Configuring a network interface to load at boot time">
|
| 99 |
|
|
# <i>rc-update add net.eth0 default</i>
|
| 100 |
|
|
# <i>rc</i>
|
| 101 |
|
|
</pre>
|
| 102 |
|
|
|
| 103 |
|
|
</body>
|
| 104 |
|
|
</section>
|
| 105 |
|
|
|
| 106 |
|
|
</sections>
|