Difference between revisions of "Netcfg"

From ArchWiki
Jump to navigation Jump to search
m (→‎net-profiles: Grammatical correction)
(netcfg was deprecated in favour of netctl, just redirect there)
(345 intermediate revisions by more than 100 users not shown)
Line 1: Line 1:
#REDIRECT [[Netctl]]
{{i18n_entry|English|Network Profiles}}
{{i18n_entry|Türkçe|Ağ Profilleri}}
==Step 1: Install==
Network profiles are handled by the bash scripts available in the netcfg package.
# pacman -Sy core/netcfg
For information relating to the latest development version of netcfg, see [[Network Profiles development]]
==Step 2: Create the profile(s)==
A profile is a single text file in /etc/network.d which defines variables used by netcfg. The file name will become the name of the profile, and can be anything you wish, it is not a setting involved in the connection.
The easiest way to create a new profile is to copy one of the example profiles from /etc/network.d/examples and edit it to fit with your network.
Below are some examples of these profiles:
====Simple ethernet example====
DESCRIPTION="A very basic ethernet profile, using dhcp"
====Wireless examples====
{{Note|for more informations about Wireless networks see the detailed article: [[Wireless Setup]].}}
Please note that the last configuration also works for WPA2 encription connections.
{{Box Note | Your network information (e.g. wireless passkey) will be stored in plain text format, so you may want to change the permissions on the newly created /etc/network.d/*.conf file (e.g. <tt>chmod 0600 /etc/network.d/*.conf</tt> to make it readable by root only), depending upon how security conscious you are. }}
====More examples====
''For more examples and further options see the files in '''/etc/network.d/examples'''.''
===Proxy settings===
Just use the PRE_UP value to set environment variables as described in [[Proxy settings]]. Here is an example:
PRE_UP="http_proxy=; export http_proxy;"
{{Note|using POST_DOWN to unset the ''protocol''_proxy variable(s) might not be a good idea because, given two profiles "a" and "b" which both set and "clean" the http_proxy variable:
*you up a then b
*you down a
the result is that the http_proxy variable is empty even if b is still up and need its proxy.}}
==Step 3: Connect==
To connect a profile just execute the following command ''as root'':
# netcfg <profile-name>
===Wireless connections===
For wireless connections, make sure the required drivers and firmwares are installed as explained in [[Wireless Setup]].
===Network unavailable===
This is typically one of:
* Out of range
* Driver issue (See Driver Quirks above)
* Trying to connect to a hidden network
If you know your network is hidden, set
===Wireless Association failed===
This is typically one of:
* Out of range/reception
* Incorrect configuration
* Invalid key
* Driver problem (See Driver Quirks above)
If it is a range problem, increasing TIMEOUT= can help.
===Unable to get IP address with DHCP===
This is typically one of:
* Out of range/reception
Try increasing DHCP_TIMEOUT
===Not a valid connection, check spelling or look at examples===
You must set CONNECTION= to "ethernet", "ppp", or "wireless".
===Using a string WEP key===
This is for a STRING WEP key, not a HEX WEP key, not a WPA key.
===Ralink legacy drivers rt2500, rt2400 that use iwpriv===
I have no intention of supporting these. rt2x00 is supported, however, and will replace these.
If you must use them, create a shell script that runs the needed iwpriv commands and put its path in PRE_UP=""
===Passing arguments to iwconfig before connecting===
Where <arguments> can be any valid iwconfig argument. The script then runs "iwconfig $INTERFACE $IWCONFIG"
For example, setting bssid/ap mac:
IWCONFIG="ap 12:34:56:78:90:12"
This supercedes the IWOPTS and WEP_OPTS options which were incompletely implemented.
===Driver Quirks (netcfg 2.1 and later)===
'''''You probably do not need these, ensure your configuration is correct and sane before you attempt to use any quirks'''''
Some drivers behave oddly and need workarounds to connect. These have to be enabled manually. They're best determined by reading the forums, seeing what others have used, and, if that fails, trial and error. They '''can''' be combined.
* prescan - Run "iwlist $INTERFACE scan" before attempting to connect (Some broadcom)
* preessid - Run "iwconfig $INTERFACE essid $ESSID" before attempting to connect. (Some ipw3945 and Intel PRO/Wireless 4965AGN)
* wpaessid - Same as previous, run before starting wpa_supplicant
* predown - Take interface down before association and then restore it after. (madwifi)
* postsleep - Sleep 1 second before checking if the association was successful
* postscan - Run "iwlist scan" after associating
For example
QUIRKS=(prescan preessid)
If you are having problems with DNS and DHCP, try adding to your profile:
This will tell netcfg to use dhcpcd instead of dhclient
If you get "Wireless Network Not Found" or "Association Failed" and have tried the above, try:
===It still doesn't work, what do I do ?===
If the FAQs below didn't solve your problem the next best place to go is the forums, or the mailing list.
To be able to determine what's wrong, we need information so when you post, make sure that you provide the following output:
* '''''ALL OUTPUT FROM netcfg'''''
* '''''ALL OUTPUT FROM netcfg'''''
* '''''ALL OUTPUT FROM netcfg''''' - this is absolutely cruicial to be able determine what went wrong. The message might be short or nonexistant, but it can mean a great deal.
* '''''Your /etc/network.d network profiles''''' - Also cruicial as many problems are simple config issues. Feel free to censor your wireless key.
* '''''netcfg version'''''
* lsmod
* iwconfig
==Step 4: Connecting on boot==
<code>net-profiles</code> allows you to start some profiles on boot.
In order to do that you need to list the /etc/network.d/ profiles you want netcfg to try at boot in the <code>NETWORKS=()</code> line in /etc/rc.conf.
NETWORKS=(home mywireless)
You also need to add <code>net-profiles</code> to the DAEMONS array, eg: DAEMONS=(... '''net-profiles''' ...).
====Display a menu at boot====
<code>net-profiles</code> can also display a menu so you can pick which profile you want to set up. For that you just need to set NETWORKS= to menu (ie <code>NETWORKS=menu</code>).
You can also access that menu at any time by running <code>netcfg-menu</code> in a terminal.
The dialog package is needed.
===Automatic detection===
<code>net-auto</code> is the second boot-time script of the netcfg package. Its function is to determine automatically which profile should be started.
<code>net-auto</code> reads the AUTO_NETWORKS=() line in /etc/rc.conf. For example:
AUTO_NETWORKS=(auto-wireless wlan0)
Like <code>net-profiles</code> it needs to be added to the DAEMONS=() line.
To run after boot:
# /usr/bin/netcfg-auto-wireless $interface
A Qt-based netcfg frontend called ArchAssistant exists. It proposes to manage & connect/disconnect profiles from a systray icon. Automatic wireless detection is also available. This tool is particularly useful for laptop users.
[http://aur.archlinux.org/packages.php?ID=15655 archassistant on AUR] | [http://www.kde-apps.org/content/show.php/ArchAssistant?content=76760 archassistant on kde-apps.org] | archassistant package on archlinux.fr [http://repo.archlinux.fr/i686/ i686] and [http://repo.archlinux.fr/x86_64/ x86_64]
==Supplementary tools==
There is a console tool for selecting wireless networks "in real-time" (in NetworkManager manner) called <code>wifi-select</code>. The tool is convinient for use in wifi-cafe or another places you are visiting for the first (and maybe the last) time. Then you don't need to create the file-profile for a new network, just type <code>sudo wifi-select wlan0</code> and choose the network you need.
The tool is currently packaged and available in AUR (<code>yaourt -S wifi-select</code>).
It works as follows:
* parses <code>iwlist scan</code> results and presents list of networks along with its security settings (wpa/wep/none) using <code>dialog</code>
* if user selects network with existing profile -- just use this profile to connect with <code>netcfg</code>
* if user selects a new network (for example network from wifi-cafe he currently visited), <code>wifi-select</code> automatically generates new profile with corresponding <code>$SECURITY</code> and asks for the key (if needed). It uses DHCP as <code>$IP</code> by default
* then, if connection succeeds, profile is saved for later usage
* if connection fails, user is asked if he/she wants to keep generated profile for further usage (for example to change <code>$IP</code> to static or adjust some additional options)
[http://bbs.archlinux.org/viewtopic.php?id=63973 Forum thread] related to development of <code>wifi-select</code> |  [http://aur.archlinux.org/packages.php?ID=23471 wifi-select on AUR] | [http://hg.horna.org.ua/wifi-select/ wifi-select mercurial repository]
===Why doesnt netcfg do ''x''?===
netcfg doesn't need to. It connects to networks.
But netcfg is super modular and re-usable. Have a look at /usr/lib/networks/ -- heaps of reusable functions for your own scripts.
===Why doesn't netcfg behave in this way? It makes more sense===
netcfg doesn't enforce any rules. It's task is to connect to networks. It doesn't impose any heuristics, like 'disconnect from wireless if ethernet is connected'.
If you want behaviour like that, it'd be really easy to write a separate tool over netcfg. See the question above.
===Do I still need ''x'' when I'm using netcfg?===
* /etc/hosts: Yes, you still need this, this is important. Don't remove your hostname from this otherwise you'll have some odd problems.
* HOSTNAME= in /etc/rc.conf: It's strongly recommended you keep this, otherwise no hostname will be set if a profile fails
* DAEMONS=(network) and INTERFACES=() in /etc/rc.conf: If you've setup all your networks with netcfg instead, yes, you can remove this. You can also safely remove lo, it's been moved into rc.sysinit.
* lo: This is now in rc.sysinit, you don't need to configure it anywhere.

Latest revision as of 15:26, 16 July 2013

Redirect to: