FIX: manpage links
[ikiwiki.git] / docs / handbook / handbook-config-network-setup.mdwn
1
2
3
4 ## 6.8 Setting Up Network Interface Cards 
5
6
7
8 ***Contributed by Marc Fonvieille. ***
9
10
11
12 Nowadays we can not think about a computer without thinking about a network connection. Adding and configuring a network card is a common task for any DragonFly administrator.
13
14
15
16 ### 6.8.1 Locating the Correct Driver 
17
18
19
20 Before you begin, you should know the model of the card you have, the chip it uses, and whether it is a PCI or ISA card. DragonFly supports a wide variety of both PCI and ISA cards. Check the Hardware Compatibility List for your release to see if your card is supported.
21
22
23
24 Once you are sure your card is supported, you need to determine the proper driver for the card. The file `/usr/src/sys/i386/conf/LINT` will give you the list of network interfaces drivers with some information about the supported chipsets/cards. If you have doubts about which driver is the correct one, read the manual page of the driver. The manual page will give you more information about the supported hardware and even the possible problems that could occur.
25
26
27
28 If you own a common card, most of the time you will not have to look very hard for a driver. Drivers for common network cards are present in the `GENERIC` kernel, so your card should show up during boot, like so:
29
30
31
32     
33
34     dc0: <82c169 PNIC 10/100BaseTX> port 0xa000-0xa0ff mem 0xd3800000-0xd38
35
36     000ff irq 15 at device 11.0 on pci0
37
38     dc0: Ethernet address: 00:a0:cc:da:da:da
39
40     miibus0: <MII bus> on dc0
41
42     ukphy0: <Generic IEEE 802.3u media interface> on miibus0
43
44     ukphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
45
46     dc1: <82c169 PNIC 10/100BaseTX> port 0x9800-0x98ff mem 0xd3000000-0xd30
47
48     000ff irq 11 at device 12.0 on pci0
49
50     dc1: Ethernet address: 00:a0:cc:da:da:db
51
52     miibus1: <MII bus> on dc1
53
54     ukphy1: <Generic IEEE 802.3u media interface> on miibus1
55
56     ukphy1:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
57
58
59
60
61
62 In this example, we see that two cards using the [dc(4)](http://leaf.dragonflybsd.org/cgi/web-man?command=dc&section=4) driver are present on the system.
63
64
65
66 To use your network card, you will need to load the proper driver. This may be accomplished in one of two ways. The easiest way is to simply load a kernel module for your network card with [kldload(8)](http://leaf.dragonflybsd.org/cgi/web-man?command=kldload&section=8). A module is not available for all network card drivers (ISA cards and cards using the [ed(4)](http://leaf.dragonflybsd.org/cgi/web-man?command=ed&section=4) driver, for example). Alternatively, you may statically compile the support for your card into your kernel. Check `/usr/src/sys/i386/conf/LINT` and the manual page of the driver to know what to add in your kernel configuration file. For more information about recompiling your kernel, please see [kernelconfig.html Chapter 9]. If your card was detected at boot by your kernel (`GENERIC`) you do not have to build a new kernel.
67
68
69
70 ### 6.8.2 Configuring the Network Card 
71
72
73
74 Once the right driver is loaded for the network card, the card needs to be configured. As with many other things, the network card may have been configured at installation time.
75
76
77
78 To display the configuration for the network interfaces on your system, enter the following command:
79
80
81
82     
83
84     % ifconfig
85
86     dc0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
87
88             inet 192.168.1.3 netmask 0xffffff00 broadcast 192.168.1.255
89
90             ether 00:a0:cc:da:da:da
91
92             media: Ethernet autoselect (100baseTX <full-duplex>)
93
94             status: active
95
96     dc1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
97
98             inet 10.0.0.1 netmask 0xffffff00 broadcast 10.0.0.255
99
100             ether 00:a0:cc:da:da:db
101
102             media: Ethernet 10baseT/UTP
103
104             status: no carrier
105
106     lp0: flags=8810<POINTOPOINT,SIMPLEX,MULTICAST> mtu 1500
107
108     lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
109
110             inet 127.0.0.1 netmask 0xff000000
111
112     tun0: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
113
114
115
116
117
118  **Note:** Note that entries concerning IPv6 (`inet6` etc.) were omitted in this example.
119
120
121
122 In this example, the following devices were displayed:
123
124
125
126
127 * `dc0`: The first Ethernet interface
128
129
130 * `dc1`: The second Ethernet interface
131
132
133 * `lp0`: The parallel port interface
134
135
136 * `lo0`: The loopback device
137
138
139 * `tun0`: The tunnel device used by  **ppp** 
140
141
142
143 DragonFly uses the driver name followed by the order in which one the card is detected at the kernel boot to name the network card, starting the count at zero. For example, `sis2` would be the third network card on the system using the [sis(4)](http://leaf.dragonflybsd.org/cgi/web-man?command=sis&section=4) driver.
144
145
146
147 In this example, the `dc0` device is up and running. The key indicators are:
148
149
150
151   1. `UP` means that the card is configured and ready.
152
153   1. The card has an Internet (`inet`) address (in this case `192.168.1.3`).
154
155   1. It has a valid subnet mask (`netmask`; `0xffffff00` is the same as `255.255.255.0`).
156
157   1. It has a valid broadcast address (in this case, `192.168.1.255`).
158
159   1. The MAC address of the card (`ether`) is `00:a0:cc:da:da:da`
160
161   1. The physical media selection is on autoselection mode (`media: Ethernet autoselect (100baseTX <full-duplex>)`). We see that `dc1` was configured to run with `10baseT/UTP` media. For more information on available media types for a driver, please refer to its manual page.
162
163   1. The status of the link (`status`) is `active`, i.e. the carrier is detected. For `dc1`, we see `status: no carrier`. This is normal when an Ethernet cable is not plugged into the card.
164
165
166
167 If the [ifconfig(8)](http://leaf.dragonflybsd.org/cgi/web-man?command=ifconfig&section=8) output had shown something similar to:
168
169
170
171     
172
173     dc0: flags=8843<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
174
175                 ether 00:a0:cc:da:da:da
176
177
178
179
180
181 it would indicate the card has not been configured.
182
183
184
185 To configure your card, you need `root` privileges. The network card configuration can be done from the command line with [ifconfig(8)](http://leaf.dragonflybsd.org/cgi/web-man?command=ifconfig&section=8) as root.
186
187
188
189     
190
191     # ifconfig dc0 inet 192.168.1.3 netmask 255.255.255.0
192
193
194
195
196
197 Manually configuring the care has the disadvantage that you would have to do it after each reboot of the system. The file `/etc/rc.conf` is where to add the network card's configuration.
198
199
200
201 Open `/etc/rc.conf` in your favorite editor. You need to add a line for each network card present on the system, for example in our case, we added these lines:
202
203
204
205     
206
207     ifconfig_dc0="inet 192.168.1.3 netmask 255.255.255.0"
208
209     ifconfig_dc1="inet 10.0.0.1 netmask 255.255.255.0 media 10baseT/UTP"
210
211
212
213
214
215 You have to replace `dc0`, `dc1`, and so on, with the correct device for your cards, and the addresses with the proper ones. You should read the card driver and [ifconfig(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#ifconfig&section8) manual pages for more details about the allowed options and also [rc.conf(5)](http://leaf.dragonflybsd.org/cgi/web-man?command=rc.conf&section=5) manual page for more information on the syntax of `/etc/rc.conf`.
216
217
218
219 If you configured the network during installation, some lines about the network card(s) may be already present. Double check `/etc/rc.conf` before adding any lines.
220
221
222
223 You will also have to edit the file `/etc/hosts` to add the names and the IP addresses of various machines of the LAN, if they are not already there. For more information please refer to [hosts(5)](http://leaf.dragonflybsd.org/cgi/web-man?command=hosts&section=5) and to `/usr/share/examples/etc/hosts`.
224
225
226
227 ### 6.8.3 Testing and Troubleshooting 
228
229
230
231 Once you have made the necessary changes in `/etc/rc.conf`, you should reboot your system. This will allow the change(s) to the interface(s) to be applied, and verify that the system restarts without any configuration errors.
232
233
234
235 Once the system has been rebooted, you should test the network interfaces.
236
237
238
239 #### 6.8.3.1 Testing the Ethernet Card 
240
241
242
243 To verify that an Ethernet card is configured correctly, you have to try two things. First, ping the interface itself, and then ping another machine on the LAN.
244
245
246
247 First test the local interface:
248
249
250
251     
252
253     % ping -c5 192.168.1.3
254
255     PING 192.168.1.3 (192.168.1.3): 56 data bytes
256
257     64 bytes from 192.168.1.3: icmp_seq#0 ttl64 time=0.082 ms
258
259     64 bytes from 192.168.1.3: icmp_seq#1 ttl64 time=0.074 ms
260
261     64 bytes from 192.168.1.3: icmp_seq#2 ttl64 time=0.076 ms
262
263     64 bytes from 192.168.1.3: icmp_seq#3 ttl64 time=0.108 ms
264
265     64 bytes from 192.168.1.3: icmp_seq#4 ttl64 time=0.076 ms
266
267     
268
269     --- 192.168.1.3 ping statistics ---
270
271     5 packets transmitted, 5 packets received, 0% packet loss
272
273     round-trip min/avg/max/stddev = 0.074/0.083/0.108/0.013 ms
274
275
276
277
278
279 Now we have to ping another machine on the LAN:
280
281
282
283     
284
285     % ping -c5 192.168.1.2
286
287     PING 192.168.1.2 (192.168.1.2): 56 data bytes
288
289     64 bytes from 192.168.1.2: icmp_seq#0 ttl64 time=0.726 ms
290
291     64 bytes from 192.168.1.2: icmp_seq#1 ttl64 time=0.766 ms
292
293     64 bytes from 192.168.1.2: icmp_seq#2 ttl64 time=0.700 ms
294
295     64 bytes from 192.168.1.2: icmp_seq#3 ttl64 time=0.747 ms
296
297     64 bytes from 192.168.1.2: icmp_seq#4 ttl64 time=0.704 ms
298
299     
300
301     --- 192.168.1.2 ping statistics ---
302
303     5 packets transmitted, 5 packets received, 0% packet loss
304
305     round-trip min/avg/max/stddev = 0.700/0.729/0.766/0.025 ms
306
307
308
309
310
311 You could also use the machine name instead of `192.168.1.2` if you have set up the `/etc/hosts` file.
312
313
314
315 #### 6.8.3.2 Troubleshooting 
316
317
318
319 Troubleshooting hardware and software configurations is always a pain, and a pain which can be alleviated by checking the simple things first. Is your network cable plugged in? Have you properly configured the network services? Did you configure the firewall correctly? Is the card you are using supported by DragonFly? Always check the hardware notes before sending off a bug report. Update your version of DragonFly to the latest PREVIEW version. Check the mailing list archives, or perhaps search the Internet.
320
321
322
323 If the card works, yet performance is poor, it would be worthwhile to read over the [tuning(7)](http://leaf.dragonflybsd.org/cgi/web-man?command=tuning&section=7) manual page. You can also check the network configuration as incorrect network settings can cause slow connections.
324
325
326
327 Some users experience one or two ***device timeouts***, which is normal for some cards. If they continue, or are bothersome, you may wish to be sure the device is not conflicting with another device. Double check the cable connections. Perhaps you may just need to get another card.
328
329
330
331 At times, users see a few ***`watchdog timeout`*** errors. The first thing to do here is to check your network cable. Many cards require a PCI slot which supports Bus Mastering. On some old motherboards, only one PCI slot allows it (usually slot 0). Check the network card and the motherboard documentation to determine if that may be the problem.
332
333
334
335 ***`No route to host`*** messages occur if the system is unable to route a packet to the destination host. This can happen if no default route is specified, or if a cable is unplugged. Check the output of `netstat -rn` and make sure there is a valid route to the host you are trying to reach. If there is not, read on to [advanced-networking.html Chapter 19].
336
337
338
339 ***`ping: sendto: Permission denied`*** error messages are often caused by a misconfigured firewall. If `ipfw` is enabled in the kernel but no rules have been defined, then the default policy is to deny all traffic, even ping requests! Read on to [firewalls.html Section 10.7] for more information.
340
341
342
343 Sometimes performance of the card is poor, or below average. In these cases it is best to set the media selection mode from `autoselect` to the correct media selection. While this usually works for most hardware, it may not resolve this issue for everyone. Again, check all the network settings, and read over the [tuning(7)](http://leaf.dragonflybsd.org/cgi/web-man?command=tuning&section=7) manual page.
344
345
346
347
348
349
350
351 CategoryHandbook
352
353 CategoryHandbook-configuration
354