LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   How to get and then use DHCP offers to config the wlan connection? (https://www.linuxquestions.org/questions/linux-networking-3/how-to-get-and-then-use-dhcp-offers-to-config-the-wlan-connection-880330/)

rylan76 05-12-2011 10:52 AM

How to get and then use DHCP offers to config the wlan connection?
 
Hi guys

I'm using the following in a script to connect to my house's wi-fi - it works perfectly for me - simple, and with a static IP:

Code:

modprobe zd1211rw #load the module needed by my wireless LAN adapter
ifconfig wlan0 up
iwconfig wlan0 essid my_network_name_at_home
ifconfig wlan0 10.0.0.8 netmask 255.255.255.0
route add default gw 10.0.0.2 wlan0
iwconfig wlan0 key key_comes_here

However, if I take my machine to the office, we've got DHCP assigned dynamic IPs. How can I modify the above script to NOT do

Code:

ifconfig wlan0 10.0.0.8 netmask 255.255.255.0
route add default gw 10.0.0.2 wlan0

but instead get them from the DHCP service running at work on the W-LAN?

Thanks!

acid_kewpie 05-13-2011 03:14 AM

Well from the slightly odd position you're coming from you would just surely use an if statement checking the essid you are connected to or something, but your script already forces you to use a specific essid in the first place so surely what you want to achieve is not actually going to help you? What's wrong with just using network manager or something else normal?

rylan76 05-16-2011 01:47 PM

Quote:

Originally Posted by acid_kewpie (Post 4355116)
Well from the slightly odd position you're coming from you would just surely use an if statement checking the essid you are connected to or something, but your script already forces you to use a specific essid in the first place so surely what you want to achieve is not actually going to help you? What's wrong with just using network manager or something else normal?

I'll only ever use the connection in my house's wi-fi hotspot (taking it elsewhere was hypothetical), the ESSID will always be a constant. I've stopped using any form of automatic config since FC10 - had an incredible amount of trouble there getting things working - doing it by hand in FC11 had me going in 5 minutes flat. So I fell back on how I did it in the past on even older distros - wrote my own script to call the needed binaries to configure my connection.

So what you're saying is I'm screwed if I use this approach and now suddenly want to change horses in mid-stream and use DHCP?

AFAIK I can only call dhclient and leave it at that...? All I effectively need is the ability to find an available IP in the local subnet, and the syntax I need to pass, for doing that, to dhclient - if any...


All times are GMT -5. The time now is 05:36 PM.