You are not logged in.

#1 2009-08-17 02:02:06

anarxi
Member
From: schaumburg, IL
Registered: 2008-12-20
Posts: 55
Website

netcfg on boot

Wiki is a bit confusing, or missing some parts. like what do I specify in adapter options

example eth0 = "dhcp";

so I want netcfg to connect to wireless network. so what option i should put to wlan0 = " ... " ?

and in NETWORK(...) what is the correct sintax? NETWORKS=(one_conig,second config, third_config) and it auto tries? or NETWORKS=(netcfg config, netcfg config2, etc..)

?

(i do have netwrok-profiles in demons list, but cant get wireless connect on boot..)


there is now knowledge that is not power

Offline

#2 2009-08-17 02:36:38

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

Re: netcfg on boot

There are two paths for setting up your network. One path uses variables like eth0 and ROUTES and INTERFACES in rc.conf, and also the entry "network" in DAEMONS. (And also the files /etc/conf.d/{wireless,bonding,bridges,dhcp}.)

The other path uses netcfg. Here there are really two-subpaths, one using net-auto and the other using net-profiles. But you should get things working with net-profiles before trying net-auto. net-profiles reads from the NETWORKS array in /etc/rc.conf. My NETWORKS array looks something like this:

NETWORKS=(!my_ethernet_profile my_wifi_profile)

This has two entries, separated by spaces. The first is disabled (it has a "!" in front of it). Only the second is enabled. net-profiles will go through the list trying to connect each enabled network until it finds one that succeeds. To do that, net-profiles itself needs to be in the DAEMONS list, with no "!" in front of it. You may be able to put a "@" in front of net-profiles, depending on what other daemons you try to load at startup; but until you get things working I'd say don't do that yet.

net-profiles is only going to be able to connect my_wifi_profile if netcfg can also connect that profile when I run it by hand. So open a terminal and try:

netcfg my_wifi_profile

to see whether it works. (Here obviously you substitute the name of your own chosen profile, which you've created in /etc/network.d/.) Does that work? If not, then you've got a problem with your configuration or profile, which you need to fix first. Are you able to connect the network yourself, by hand, using commands like:

ifconfig eth0 192.168.0.2 up
route add default gw 192.168.0.1

or:

ifconfig eth0 up
dhcpcd -L -t10 eth0

It'll be easiest for you to figure out why you're profile isn't working if you already know how to configure your network manually. But if you don't, don't worry. Just try to follow the examples on the wiki and in /etc/network.d/examples/ to get a netcfg profile that works for you. Once you're able to successfully run "netcfg my_profile" from a terminal, then you can set it up to be run automatically at boot, in the way I outlined above.

Offline

#3 2009-08-17 03:08:06

anarxi
Member
From: schaumburg, IL
Registered: 2008-12-20
Posts: 55
Website

Re: netcfg on boot

Profjim wrote:

There are two paths for setting up your network. One path uses variables like eth0 and ROUTES and INTERFACES in rc.conf, and also the entry "network" in DAEMONS. (And also the files /etc/conf.d/{wireless,bonding,bridges,dhcp}.)

The other path uses netcfg. Here there are really two-subpaths, one using net-auto and the other using net-profiles. But you should get things working with net-profiles before trying net-auto. net-profiles reads from the NETWORKS array in /etc/rc.conf. My NETWORKS array looks something like this:

NETWORKS=(!my_ethernet_profile my_wifi_profile)

This has two entries, separated by spaces. The first is disabled (it has a "!" in front of it). Only the second is enabled. net-profiles will go through the list trying to connect each enabled network until it finds one that succeeds. To do that, net-profiles itself needs to be in the DAEMONS list, with no "!" in front of it. You may be able to put a "@" in front of net-profiles, depending on what other daemons you try to load at startup; but until you get things working I'd say don't do that yet.

net-profiles is only going to be able to connect my_wifi_profile if netcfg can also connect that profile when I run it by hand. So open a terminal and try:

netcfg my_wifi_profile

to see whether it works. (Here obviously you substitute the name of your own chosen profile, which you've created in /etc/network.d/.) Does that work? If not, then you've got a problem with your configuration or profile, which you need to fix first. Are you able to connect the network yourself, by hand, using commands like:

ifconfig eth0 192.168.0.2 up
route add default gw 192.168.0.1

or:

ifconfig eth0 up
dhcpcd -L -t10 eth0

It'll be easiest for you to figure out why you're profile isn't working if you already know how to configure your network manually. But if you don't, don't worry. Just try to follow the examples on the wiki and in /etc/network.d/examples/ to get a netcfg profile that works for you. Once you're able to successfully run "netcfg my_profile" from a terminal, then you can set it up to be run automatically at boot, in the way I outlined above.

it works ok from the command line. I'm having troubles getting it on boot.

Last edited by anarxi (2009-08-17 03:10:33)


there is now knowledge that is not power

Offline

#4 2009-08-17 05:41:13

Runiq
Member
From: Germany
Registered: 2008-10-29
Posts: 1,053

Re: netcfg on boot

You don't need to put anything in NETWORKS if you want to connect automatically. As the wiki says, you need to use the following line in your rc.conf:

AUTO_NETWORKS=(auto-wireless wlan0)

for wlan0, for example. Then, add net-auto to your daemons. No need for the net-profiles daemon here.

Also, the very last paragraph on above mentioned wiki page tells you what you don't need if you are using netcfg. If you set up auto-wireless, you also don't need the NETWORKS array.

Offline

#5 2009-08-17 13:21:19

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

Re: netcfg on boot

Well, there are two ways to do netcfg at boot. You could do:

AUTO_NETWORKS=(auto-wireless wlan0)
...
DAEMONS=(...net-auto...)

or you could do:

NETWORKS=(my_profile)
...
DAEMONS=(...net-profiles...)

Last edited by Profjim (2009-08-17 13:21:47)

Offline

#6 2009-08-18 01:46:59

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,355

Re: netcfg on boot

The wiki does seem a bit sparse on this matter. In the end I'm just booting and then running netcfg lan or netcfg wifi or whichever I need...

Is there any way to script it such that netcfg auto-connects to the right network? For example lan IF a lan cable is connected, and wifi IF a particular ESSID is in the region? I'm aware that's not netcfg's job, but the wiki ends with 'this is easily scriptable' but I haven't seen scripts for this anywhere...


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#7 2009-08-18 14:47:53

jacko
Member
Registered: 2007-11-23
Posts: 840

Re: netcfg on boot

ngoonee wrote:

The wiki does seem a bit sparse on this matter. In the end I'm just booting and then running netcfg lan or netcfg wifi or whichever I need...

Is there any way to script it such that netcfg auto-connects to the right network? For example lan IF a lan cable is connected, and wifi IF a particular ESSID is in the region? I'm aware that's not netcfg's job, but the wiki ends with 'this is easily scriptable' but I haven't seen scripts for this anywhere...

as previously stated, net-auto!!!! ^^^^^ read, it's clearly explained in the netcfg wiki.


http://wiki.archlinux.org/index.php/Net … _detection

net-auto is the second boot-time script of the netcfg package. Its function is to determine automatically which profile should be started.

whether your using net-profile or net-auto, both ways require that you have a profile(s) defined for netcfg to use to connect with your correct settings.

Last edited by jacko (2009-08-18 14:52:28)

Offline

#8 2009-08-18 16:52:54

bhadotia
Member
From: Karnal, India
Registered: 2008-12-09
Posts: 87

Re: netcfg on boot

Look here are the relevant parts of my rc.conf:

# -----------------------------------------------------------------------
# NETWORKING
# -----------------------------------------------------------------------
#
# HOSTNAME: Hostname of machine. Should also be put in /etc/hosts
#
HOSTNAME="Krsna"

# Use 'ifconfig -a' or 'ls /sys/class/net/' to see all available interfaces.
#
# Interfaces to start at boot-up (in this order)
# Declare each interface then list in INTERFACES
#   - prefix an entry in INTERFACES with a ! to disable it
#   - no hyphens in your interface names - Bash doesn't like it
# 
# DHCP:     Set your interface to "dhcp" (eth0="dhcp")
# Wireless: See network profiles below
#

#Static IP example
#wlan0="wlan0 172.16.22.2 netmask 255.255.252.0 broadcast 172.16.23.255"
eth0="dhcp"
INTERFACES=(!wlan0 eth0)

# Routes to start at boot-up (in this order)
# Declare each route then list in ROUTES
#   - prefix an entry in ROUTES with a ! to disable it
#
gateway="default gw 172.16.20.1"
ROUTES=(!gateway)
 
# Enable these network profiles at boot-up.  These are only useful
# if you happen to need multiple network configurations (ie, laptop users)
#   - set to 'menu' to present a menu during boot-up (dialog package required)
#   - prefix an entry with a ! to disable it
#
# Network profiles are found in /etc/network.d
#
# This now requires the netcfg package
#
NETWORKS=(wimaxB3-2 wimaxb3-1)

# -----------------------------------------------------------------------
# DAEMONS
# -----------------------------------------------------------------------
#
# Daemons to start at boot-up (in this order)
#   - prefix a daemon with a ! to disable it
#   - prefix a daemon with a @ to start it up in the background
#
DAEMONS=(syslog-ng hal cpufreq !network @net-profiles dnsmasq !gpm netfs crond)

And here is one of my profiles:

cat /etc/network.d/wimaxB3-2
CONNECTION="wireless"
DESCRIPTION="A simple opened wireless connection"
INTERFACE="wlan0"
ESSID="wimax(B3-2)"
IP="dhcp"

Offline

#9 2009-08-18 17:25:43

whordijk
Member
From: the Netherlands
Registered: 2008-12-12
Posts: 147
Website

Re: netcfg on boot

Profjim wrote:

Well, there are two ways to do netcfg at boot. You could do:

AUTO_NETWORKS=(auto-wireless wlan0)
...
DAEMONS=(...net-auto...)

or you could do:

NETWORKS=(my_profile)
...
DAEMONS=(...net-profiles...)

What's the big difference between these two methods anyway..? As I read it now, net-profiles tries the networks in the array and connects to the first one it can connect to. How is net-auto any different?

Offline

#10 2009-08-18 20:08:22

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

Re: netcfg on boot

I think I spoke wrongly. What net-profiles does in the normal case is cycle through the entries in the NETWORKS array. The first entry it finds which is _enabled_ (that is, has no '!' at the start), it attempts to connect to. If it succeeds great. If it fails it stops. Things work differently if one of the entries is "menu" or if you passed a NET environment variable on your kernel line, but this is the basic behavior.

You might ask, why not change /etc/rc.d/net-profiles so that instead of quitting if that connection attempt failed, it continued on through the NETWORKS array? Well, you probably don't want to do that unless you have only a tiny number of profiles. There'd be substantial delays as you tried to connect to each network in turn. Plus you'd get more screen output/error reports than you'd like.

net-auto is currently only defined to work for wireless interfaces. What it does is wifi-scan the neighborhood to see what ESSIDs are visible, then sift through your profiles to see if any of them are wireless profiles for that ESSID. It tries to connect the first match it finds. (And if I remember right, quits if that connection fails.) This is much speedier.

However, it doesn't address ngoonee's desire to have wireless and wifi interfaces defer to each other. Netcfg alone doesn't now do that. You'd have to do something like, for example:
1. install ifplugd, and tell it to connect my_ethernet_profile whenever it detects a live ethernet cable plugged in.
2. have the POST_UP argument on my_ethernet_profile instruct netcfg to disconnect any wireless profiles that might be connected.
3. have the PRE_UP argument on your wireless profiles check to see if any ethernet profiles are connected (look in /var/run/network/interfaces), and if so, exit with a non-zero status. Then netcfg will abort the connection attempt. (At least, the version we're working on in git will, I don't think this is in the stable release yet.)

Offline

#11 2009-08-18 21:43:47

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,355

Re: netcfg on boot

Ah, thanks Profjim, that clears things up. I suppose I could also use PRE_UP on my lan profile to exist if the LAN cable is NOT plugged in? How would we check for that anyway, besides using ifplugd (an additional daemon, hmmm...)


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#12 2009-08-18 22:02:49

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

Re: netcfg on boot

You can check for a connected profile on a given interface, for instance, eth0, by:

test -e /var/run/network/interfaces/eth0

(If you need to learn how to use test aka [ ... ], google Advanced Bash Scripting Guide. Settle in for a long but important read.)
If you just want to check for a live ethernet wire, do:

cat "/sys/class/net/eth0/carrier"

It will give you an error if the interface is inactive (i.e., no live wire), else output 1 if the interface is up (ifconfig eth0 up), else output something else (0? I forget) if there's a live wire but the interface is down.

Offline

#13 2009-08-19 01:08:21

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,355

Re: netcfg on boot

Actually, I just tested /sys/class/net/eth0/carrier...

Its an error if the interface is inactive (ifconfig eth0 down), output 1 if active (ifconfig eth0 up) and plugged in, output 0 if active and not plugged in.

And /var/run/network/interfaces/eth0 only exists on a live connection, which is not very useful at bootup time if I'm trying to determine whether or not to bring the connection up.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#14 2009-08-19 02:02:26

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

Re: netcfg on boot

ngoonee wrote:

Actually, I just tested /sys/class/net/eth0/carrier...

Its an error if the interface is inactive (ifconfig eth0 down), output 1 if active (ifconfig eth0 up) and plugged in, output 0 if active and not plugged in.

OK, I misremembered.

And /var/run/network/interfaces/eth0 only exists on a live connection

Exactly.

Offline

Board footer

Powered by FluxBB