slitaz-doc-wiki-data view pages/en/handbook/networkconf.txt @ rev 140

Add TazPanel to en:handbook:networkconf
author Christian Mesh meshca@clarkson.edu
date Mon Mar 19 21:55:06 2012 +0000 (2012-03-19)
parents 70b5f3ae5339
children
line source
1 ====== Network Configuration ======
3 ===== About the Network =====
5 By default SliTaz starts a DHCP client (udhcpc) on eth0 at boot time. If your network card has been identified as an eth0 interface and you use a router, your connection should already be working. DHCP is dynamically configured, on each boot the client asks for a new IP address from the DHCP server which is integrated into the router, or on another computer. If you need a static IP, you can directly edit config files or use the GUI //netbox// available from the //System menu --> System// tools. In a terminal or a Linux console, you can list all available network interfaces with the command //ifconfig// followed by the //-a// option:
7 <code> $ ifconfig -a </code>
9 To display the Kernel's IP routing table, you can use the route command without any arguments:
11 <code> $ route </code>
13 The system wide network configuration file is ///etc/network.conf//. It can be graphically configured with netbox or directly edited by the root administrator.
15 ==== TazPanel - Network ====
17 TazPanel aims to be the new way to configure your system. The legacy systems still exist below. The main network page in TazPanel displays current networking information. The other two tabs, Ethernet and Wifi allow you to configure each respectivly for your system.
19 ===== Netbox - Configure the network =====
21 Netbox is a small GTK+ application to configure a network interface using DCHP or a fixed (static) IP address. The tabs can be used to start/stop the connections and automatically change the values in the system files. Netbox provides a system wide tab from which you can directly edit network configuration files, and tabs to configure PPP/PPPoE username/passwords. Servers such as SSH, DHCP, PXE, DNS, etc can also be configured and it's possible to create your own virtual private network (VPN) using the tools provided.
23 {{:en:handbook:image:netbox.png}}
25 You can start netbox from the System tools menu or via a terminal:
27 <code> $ subox netbox </code>
29 ===== Wifibox - Graphical configuration of the wireless network =====
31 Wifibox is small interface to configure a network connection (Wifi, WLAN, or Wireless). The 'Networks' tab displays a list of available networks, just double click on a network name to connect. If the network is secure, the key will then be sought.
33 {{:en:handbook:image:wifibox.png}}
35 The 'Favorites' tab allows you to set your preferred networks. Once a network is added, just double click on the network name to connect. The 'Configuration' tab lets you configure a connection manually using the advanced settings such as the mode or channel. The 'Drivers' tab allows you to configure a network card; there are 3 options:
37 - The card is supported directly by the kernel via a module.
38 - The card needs a module and non-free firmware that can be installed automatically via the auto-detect tool (tazhw).
39 - The card is not supported by Linux and a Windows driver must be installed via the Windows driver manager (tazndis).
41 ===== /etc/hostname - The hostname =====
43 The file ///etc/hostname// sets the machine name. This is loaded at system startup with the command 'hostname', without an argument this command returns the current machine name:
45 <code> $ hostame </code>
47 To change the hostname, you can use the echo command or a text editor available on SliTaz (you must be root). Example using echo and the machine name kayam:
49 <code> # echo "kayam" > /etc/hostname </code>
51 ===== /etc/network.conf =====
53 ///etc/network.conf// is the SliTaz system network configuration file. It's syntax is simple and you can edit its contents with a text editor such as Nano. ///etc/network.conf// is used by the script ///etc/init.d/network.sh// to configure the network interface at boot time.
55 ===== Dynamic IP - DHCP client udhcpc =====
57 The DHCP client udhcpc supplied with Busybox uses the ///usr/share/udhcpc/default.script// to get an IP address dynamically at boot. It supports various options which you can view with the <nowiki>--help</nowiki> option:
59 <code> # udhcpc --help </code>
61 To disable udhcpc on eth0 or modify the interface (eg eth1), you must edit the ///etc/network.conf// file and place the value "no" in the variable DHCP=:
63 <file>
64 # Dynamic IP address.
65 # Enable/disable DHCP client at boot time.
66 DHCP="no"
67 </file>
69 ===== Static IP - Using a specific address =====
71 You can specify a fixed IP address to configure at boot time by using the value "yes" in the variable STATIC=:
73 <file>
74 # Static IP address.
75 # Enable/disable static IP at boot time.
76 STATIC="yes"
77 </file>
79 For the configuration to work, you must specify an IP address, its subnet mask, a default gateway (gateway) and DNS server to use. Example:
82 <file>
83 # Set IP address, and netmask for a static IP.
84 IP="192.168.0.6"
85 NETMASK="255.255.255.0"
87 # Set route gateway for a static IP.
88 GATEWAY="192.168.0.1"
90 # Set DNS server. for a static IP.
91 DNS_SERVER="192.168.0.1"
93 </file>
95 ===== PPPoE connection kernel-mode =====
97 PPPoE connection in kernel-mode needs 2 files. The first file is ///etc/ppp/options// where you must specify your login name:
99 <file>
100 plugin rp-pppoe.so
101 name <your provider connection ID>
102 noipdefault
103 defaultroute
104 mtu 1492
105 mru 1492
106 lock
107 </file>
109 Now you have to configure ///etc/ppp/pap-secrets// or ///etc/ppp/chap-secrets//:
112 <file>
113 # client server secret IP addresses
114 "your_login" * "your_password"
115 </file>
117 The config file /etc/resolv.conf will be automatically loaded. Finished, you can now connect to the internet with pppd:
119 <code> # pppd eth0
120 </code>
122 On an installed system you can start pppd on each boot using the local startup script: ///etc/init.d/local.sh//
124 ===== Enable Dial-up Modem - PPPoE with rp-pppoe =====
126 To set an ASDL protocol via PPPoE, SliTaz provides the utilities package //rp-pppoe//. Using pppoe-setup is a snap and you can quickly configure the network. If you use DCHP it's even easier, because the server from your ISP will take care of everything. If you do not have DHCP, you must first disable its use via DHCP="no" in the configuration file ///etc/network.conf//. It should be noted that to modify configuration files and system logs you must first become root. To install and change the variable DHCP with Nano (ctrl + X to save & exit):
129 <code>
130 $ su
131 # tazpkg get-install rp-pppoe
132 # nano /etc/network.conf
133 </code>
135 === Configure with pppoe-setup ===
137 To begin to configure your PPPoE connection, you must first open an Xterm or Linux console and launch pppoe-setup and then begin to answer the following questions:
140 <code> # pppoe-setup
141 </code>
143 - Enter your username, please note that this is the username with which you communicate with your ISP.
144 - Internet interface, default is eth0 unless you have more than one, in which case you will have eth1, eth2, etc. Usually the Enter key is sufficient.
145 - If you have a permanent ASDL link answer yes, otherwise answer no (default).
146 - Specify the primary and secondary DNS your ISP uses (you may have to ask).
147 - Enter the password with which you communicate with your ISP (you need to enter it twice).
148 - Choose the firewall settings depending on your hardware. If you have a router you can enter 1 or 2. If in doubt enter 1.
150 === Start and Stop the connection ===
152 Still using the command line, simply type pppoe-start to start the connection. A few seconds later the system tells you that it is connected. If it gives you a message like TIMED OUT, you may have poorly configured or the connection is defective. Please check the wiring and repeat the installation from the beginning. To start the connection:
154 <code> # pppoe-start
155 </code>
157 To stop the connection, you can type:
158 <code> # pppoe-stop
159 </code>
161 ===== Install network card driver =====
163 In case you need a network card driver and don't know the driver name, you can use the command lspci to find your card and then modprobe to load a module. In Live mode you can use the SliTaz boot option modprobe=modules to automatically load Kernel modules. To get a list of all available network card drivers, display PCI eth cards and load a module:
166 <code>
167 # modprobe -l | grep drivers/net
168 # lspci | grep [Ee]th
169 # modprobe -v module_name
170 </code>
172 On an installed system you just need to add the module_name to the variable LOAD_MODULES in ///etc/rcS.conf// to load your module on each boot.
174 ===== Manage the Firewall (firewall) using Iptables =====
176 SliTaz provides a very basic firewall, the kernel security rules are launched at boot time and iptables rules are disabled by default. You can activate/disable these at startup by using the configuration file ///etc/firewall.conf//.
178 The default firewall script begins with its own set options for the Kernel ie. ICMP redirects, source routing, logs for unresolved addresses and spoof filters. The script then launches the rules defined in the //iptables_rules()// function of the configuration file: ///etc/firewall.conf//.
180 The firewall uses Iptables, it consists of two files: ///etc/firewall.conf// and ///etc/init.d/firewall//, you shouldn't need to modify these. Note Iptables has lots of options. For more infomation see the official documentation available online: http://www.netfilter.org/documentation/.
182 === Start, stop, restart the firewall ===
184 The script ///etc/init.d/firewall// lets you start/restart, stop or display the status of the firewall. The restart option is often used to test new rules after editing the configuration file. Example:
187 <code>
188 # /etc/init.d/firewall restart
189 </code>
191 === Enable/Disable the firewall at boot ===
193 To enable/disable options specific to the Kernel place "yes" or "no" in the variable KERNEL_SECURITY= :
195 <file>
196 # Enable/disable kernel security at boot time.
197 KERNEL_SECURITY="yes"
198 </file>
200 And to activate/deactivate the iptables rules, it is necessary to modify the IPTABLES_RULES= variable :
202 <file>
203 # Enable/disable iptables rules.
204 IPTABLES_RULES="yes"
205 </file>
207 === Add, delete or modify the iptables rules ===
209 At the bottom of the configuration file: ///etc/firewall.conf//, you will find a function named: //iptables_rules()//. This function contains all of the //iptables// commands to launch when the firewall starts. To delete a rule, It is advisable to comment out the corresponding line with a #. It is not advisable to leave the function completely empty, if you want to disable the iptables rules just add //"no"// to the variable //IPTABLES_RULES=// in the configuration file.
211 Here's an example of using iptables rules. It only allows connections on the localhost and the local network, and ports 80, 22, and 21 used by the web server HTTP, the SSH secure server and FTP respectively. All other incoming and outgoing connections are refused, so it's fairly restrictive.
213 <file>
214 # Netfilter/iptables rules.
215 # This shell function is included in /etc/init.d/firewall.sh
216 # to start iptables rules.
217 #
218 iptables_rules()
219 {
221 # Drop all connections.
222 iptables -P INPUT DROP
223 iptables -P OUTPUT DROP
225 # Accept all on localhost (127.0.0.1).
226 iptables -A INPUT -i lo -j ACCEPT
227 iptables -A OUTPUT -o lo -j ACCEPT
229 # Accept all on the local network (192.168.0.0/24).
230 iptables -A INPUT -s 192.168.0.0/24 -j ACCEPT
231 iptables -A OUTPUT -d 192.168.0.0/24 -j ACCEPT
233 # Accept port 80 for the HTTP server.
234 iptables -A INPUT -i $INTERFACE -p tcp --sport 80 -j ACCEPT
235 iptables -A OUTPUT -o $INTERFACE -p tcp --dport 80 -j ACCEPT
237 # Accept port 22 for SSH.
238 iptables -A INPUT -i $INTERFACE -p tcp --dport 22 -j ACCEPT
239 iptables -A OUTPUT -o $INTERFACE -tcp --sport 22 -j ACCEPT
241 # Accept port 21 for active FTP connections.
242 iptables -A INPUT -i $INTERFACE -p tcp --dport 21 -j ACCEPT
243 iptables -A OUTPUT -i $INTERFACE -p tcp --sport 21 -j ACCEPT
245 }
246 </file>