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