OpenWrt Forum Archive

Topic: Setting up routed wireless

The content of this topic has been archived on 14 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I was wondering how to setup the ip address (networking information) for a wireless interface that is not bridged to any other interfaces

Thanks
Alex

alexsamad wrote:

I was wondering how to setup the ip address (networking information) for a wireless interface that is not bridged to any other interfaces

Thanks
Alex

Has nobody setup openwrt this way, I can do it with my own scripts, just wondering how to do it the kamikaze way

I had to do the same thing some time ago.

You should add the line:

ifconfig [interface] [address]
#for example
#ifconfig wl0 192.168.2.1

at the bottom of /etc/init.d/custom-user-startup.

The script will act at boot time and your interface will have that address assigned.

(Last edited by ggp81 on 16 Oct 2007, 09:24)

So, you like to have the router in routed client-mode and the wireless interface should be the WAN interface?

hi

I know how to use ifconfig and ip a a dev ....


my desire is to seperate Wireless and LAN and a WAN.  WAN is adsl.

such that

LAN = 192.168.0.1/24
Wireless = 192.168.1.1/24

I will route between the two.  I know about the /ete/config/network file - but it does seem to be the write place for assigning ip addresses to wireless interfaces ?

I also know about /etc/config/wireless - I have define my AP here.

I thought there might be a configuration place somewhere for assigning the ip address for the wireless interface.  I suppose I could add it to hotplug and look for a wifi0 coming up and then assign my own ip address to it ?

try following approach:
adapt 'network' along following lines:

#### Switch configuration wrt54g v2.1
config switch            "eth0"
    option vlan0        "1 2 3 4 5*"
    option vlan1        "0 5"

#### Loopback configuration
config interface loopback
    option ifname        "lo"
    option proto        "static"
    option ipaddr        "127.0.0.1"
    option netmask    "255.0.0.0"

#### LAN configuration"
config interface        "lan"
    option ifname        "eth0.0"
    option proto        "static"
    option ipaddr        "<your ip address on the lan subnet>"
    option netmask    "255.255.255.0"

#### WAN configuration
config interface        "wan"
    option ifname        "eth0.1"   
    option proto        "static"
    option ipaddr        "<your ip address on the wan subnet>"
    option netmask    "255.255.255.0"

#### WIFI configuration
config interface        "wifi"
    option ifname    "wl0"
    option proto    "static"
    option ipaddr    "<your ip address on the wifi subnet>"
    option netmask    "255.255.255.0"
    option gateway    "<your gateway's ip address in case it is to be reached via wireless>"
## put this gateway option with that one interface where  the gateway is to be found; so could be alternatively
## with lan of wan section i.s.o. wifi


add to 'wireless':

config wifi-device        "wifi0"
    option type    "broadcom"
    option country    JP
    option channel    "<your channel nr>"
    option maxassoc    "<your desired max allowed associations in case of an ap>"
#    option distance    

config wifi-iface
    option network    "wifi"
    option device    "wifi0"
    option mode    "<sta | ap>"
    option ssid        "<your ssid>"
#    option bssid    bssid address
    option encryption    "psk"
    option cipher    "aes"
    option key        "<your psk>"
    option hidden    0
    option isolate    0

(Last edited by doddel on 16 Oct 2007, 21:56)

That was what i was looking for, but a question

in the network section you have wl0, how does that relate to wifi0 - this seems to be the device that gets created ? (note I am using 2.6).  Does wl1 => wifi1 ?

my understanding is that ifname relates to the broadcom driver and has to be 'wl0';
'wifi' is the name given in user space for routing and interface definition purposes; it can be anything unique you like, probably within some length bounds.

In the wireless section 'network' is not to be taken literal as in 'a wireless network' but is just a reference to the definition file which was baptized 'network' and in which in my example 'wifi' got defined.
That interface can have multiple coexisting virtual implementations, called devices within the iface section (confusing), which get enumerated like wifi0, wifi1.
If you like you can also in the 'network' file assign different subnets to different wireless virtual interfaces.
As long as it is on the same physical medium (channel), one radio can emulate an access point and a client, or two or more access points with different ssids at the same time !
In the 'wireless' wifi-device section those medium characteristics get defined that all virtual interfaces must have in common (obviously the simple radio cannot channel hop and there is only one radio hardware). In the wifi-iface section(s) the characteristics of the individual virtual interfaces get defined, like their role and authentication and key management. 

Personally I find it all rather confusing terminolgy (interface, iface, device, network, ifname); also not sure that I understood it all correctly, hence the 'my understanding is' in the first sentence, so take it with a grain of salt.
I did manage to make a wrt54g emulate two APs with different ssids at the same time.

(Last edited by doddel on 16 Oct 2007, 23:23)

Thanks, it has helped to clear it up, I will have a play and go from there

okay that did not work

here is my /etc/config/network

#### Wireless configuration
#### wl0
config interface        wireless
        option ifname   "wifi0"
        option proto    static
        option ipaddr   192.168.10.1
        option netmask  255.255.255.0


here is my /etc/config/wireless
config wifi-device  wifi0
        option type     atheros
        option channel  5
#       option mode   "11g"
#       option country au
        option distance 2000
        option disabled 0
        option diversity 1
        option txantenna 0
        option rxantenna 0


config wifi-iface
        option device   wifi0
        option mode     ap
        option ssid     barbarast.com
        option hidden   0
        option encryption psk2
        option key XXXXXXXXXXXXXXXXXXXXXXXXXXXXX


when i try a ifup wireless get device not found, I had to change to [option ifname   "wifi0" ] in the network section

my other problem is which happens first, bringing up the network or the wireless ? if the wireless config is run first then the device will exist.

Seems like I really need something in hotplug so when the device comes up I can assign an ip address to it, or some way of putting info into the wireless config for the ip address

The wireless configuration is dynamic, you should not use the fixed ifname option because it can change. The relation between the network interface and the wireless interface is arranged by the network option!
The option ifname was probably necessary in 7.06 when using the wireless interface as the wan. You should not use it in 7.09.
[size=6]You can add it in case of any troubles, it is ath0 for the atheros wifi and the 1st wireless interface (maybe mbm will not see the small text).[/size]

The doddel's configuration is basically good except of the option ifname    "wl0".

/etc/config/network
...
config interface        wireless
        option proto    static
        option ipaddr   192.168.10.1
        option netmask  255.255.255.0
...

/etc/config/wireless
...
config wifi-iface
        option device   wifi0
        option network wireless
        option mode     ap
        option ssid     barbarast.com
        option hidden   0
        option encryption psk2
        option key XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
...

The network scripts handle both the wireless and the network interface in the proper order. You need to do nothing more than starting the network by the init script.

But you must add the dhcp configuration if you want to serve ips  and modify the firewall scripts to enable the communication between the new wireless network and the lan or the Internet (notice also the isolate option in your wifi interface).

You can learn more about the network configuration using the webif2 interface. big_smile

Thanks

I was starting the dissection  of wifi, this sort of makes sense, also read something like this in the documentation.  But

config wifi-iface
      option network  the interface you want wifi to bridge with

it talks about bridging with this interface.  I didn't want it to bridge with anything !

The only problem is it is not really intuative.  I can't just use ifup / ifdown to handle the wireless interface, I have to also use wifi ?  Couldn't /etc/config/network have an option to mark the interface as a wireless one ?

Currently I am doing everything by command line, I  prefer it that way

Thanks again.

network
Selects the interface section from /etc/config/network to be used with this interface


Imagine that you would set up for example the monitoring interface first, atheros wireless interfaces are created like athX (similarly the broadcom wifi interfaces are numbered too). The first available interface would be ath1, as ath0 would be occupied by the monitoring interface. If you include the hardcoded ifname option, the dynamics in the network scripts will not work and you would end up setting all by hand.

If you set it right, you can "just use ifup / ifdown to handle the wireless interface" via the network interface (ifup / ifdown wireless in your case). big_smile

I must mention that the state of the network interface is written into /var/state/network. You can anytime look at it to find out what wireless interface is associated with the particular network interface.

alexsamad wrote:

Currently I am doing everything by command line, I  prefer it that way

You can do whatever you want but it will only make your configuration harder to maintain when going against the standard scripts. Many packages dealing with the wireless config will not work for you.

[size=8]I am trying to explain the configuration to help mbm because he seems to be tired explaining it. There are many wrong wireless configurations in the forum. It seems that the relationship between the network interface and the wireless interface used in uci configs and handled by init scripts is hard to understand for many users. Maybe it would deserve a special HOWTO.[/size]

network
Selects the interface section from /etc/config/network to be used with this interface

If you look up the page a bit it has the section i quoted.  But unfortunately when I tried it I tried it with wifi0, not ath0


<...>

alexsamad wrote:

Currently I am doing everything by command line, I  prefer it that way

You can do whatever you want but it will only make your configuration harder to maintain when going against the standard scripts. Many packages dealing with the wireless config will not work for you.


I meant in reference to the web interface you gave in the previous message.

<...>



So if from my understanding of you message if I in network I attach it to athX (the appropriate one), so in my example I believe this would always be ath0, then I would only need to use ifup/ifdown wireless.

I note that in the /etc/init.d/network script it during boot up setups up the wireless. which gets me the wifi0 and the ath0.


so just for the record

/etc/config/network

#### Wireless configuration
config interface        wireless
        option ifname   "ath0"
        option proto    static
        option ipaddr   192.168.6.1
        option netmask  255.255.255.0

/etc/config/wireless

config wifi-device  wifi0
        option type     atheros
        option channel  5
#       option mode   "11g"
#       option country au
        option distance 2000
        option disabled 0
        option diversity 1
        option txantenna 0
        option rxantenna 0


config wifi-iface
        option device   wifi0
        option network  wireless
        option mode     ap
        option ssid     barbarast.com
        option hidden   0
        option encryption none

upon reboot on the machine the wireless comes up.
to manage the wireless i can use

ifup/ifdown wireless

I can also use wifi down/up, but it also works on the underlying interface - removes the wireless interface itself.

Kebul - thanks for you time

You are getting closer.
Again: the wireless interfaces are dynamic. You should not use the hardcoded ifname option for wireless networks.

/etc/config/network

#### Wireless configuration
config interface        wireless
        #option ifname  'remove this setting for a wireless network!'
        option proto    static
        option ipaddr   192.168.6.1
        option netmask  255.255.255.0

You probably missed my previous example using the monitoring interface. The ifname option would be ath1 in such case and your config would not work.
Maybe you could understand it by using two wireless APs. Imagine such setup:

/etc/config/network

#### Wireless configuration
config interface        wap1
        option ifname   "ath1"
        option proto    static
        option ipaddr   192.168.6.1
        option netmask  255.255.255.0
config interface        wap2
        option ifname   "ath0"
        option proto    static
        option ipaddr   192.168.7.1
        option netmask  255.255.255.0

Do you know what is wrong with it? It would not function this way. The wap networks would be swapped in the best case. You cannot rely on the scripts that the config sections are processed sequentially if you think that you could try to number the interfaces sequentially (e.g. ath0 first). The scripts run in the background and you will never know the order. And there is still the option that some application creates its own wireless interface for its purposes (like the monitoring interface) and your hardcoded config will not work.

Hi

yeah I understood, my problem was when I remove the ifname, I can not use ifup wireless it doesn't bring up the device.

I tried

reboot - wireless is up and configured
ifdown wireless - interface up
ifup wireless - nothing interface did not come back ! (using ifconfig)
wifi up - brings interface up


If I set the ifname then I can use ifup/ifdown, i have made a mental not to check the athx matching if I have a problem with wireless or I setup multiple wifi

The discussion might have continued from here.