Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What I do to connect to our wireless network:

  • run sudo ifconfig wlan0 up
  • run wpa (a script that invokes wpa_supplicant with all the necessary arguments)
  • run sudo dhclient wlan0 (this is the step I don't like)

The last step, the dhclient step, I would like to replace with a static IP configuration instead of getting it from the DHCP server. I know what the gateway address is, the DNS addresses, the IP address and the netmask, but I don't know how to set these via the command line. Is it possible?

If it matters, I am running Fedora 18 x86_64.

P.S. The IP address is set with sudo ip addr add <ip-address> dev wlan0, right?

share|improve this question
    
have you tried setting it in your ifcfg-wlan0 ? docs.fedoraproject.org/en-US/Fedora/15/html/Deployment_Guide/… –  Frank Thomas Apr 22 '13 at 20:10
    
Doesn't ifcfg files use NetworkManager? I am trying to get away from NetworkManager, as NetworkManager is not working correctly. That is why I am looking for a "basic" command line alternative. –  BenjiWiebe Apr 22 '13 at 20:58
    
try this guide wikihow.com/Assign-an-IP-Address-on-a-Linux-Computer –  shouso_boy Apr 23 '13 at 3:59
    
Other way around. these files are used by networkmanager if present, but just like the interfaces file in a debian-based system, it can be configured by hand if networkmanager is not being used. on my debian systems I configure my interfaces file and then disable networkmanager –  Frank Thomas Apr 23 '13 at 11:35
    
@shouso_boy That is exactly what I was looking for! That route add default via <gateway> is what I need! Thanks! –  BenjiWiebe Apr 23 '13 at 12:37

1 Answer 1

up vote 1 down vote accepted

You can add a static IP address with the ip command, but you need to specify the network range and default router aswell:

ip addr add 192.168.1.2/24 dev wlan0
ip route add default via 192.168.1.1

Without the later step you will only have connectivity to your local network. You will also need to update your /etc/resolv.conf with the correct nameserver address:

echo 'nameserver 8.8.8.8' >/etc/resolv.conf

Pay attention because if you have some sort of network manager running or the resolvconf package installed, it may easily overwrite your changes.

share|improve this answer
    
This works to get local network access, e.g. ping 192.168.0.1, but not ping google.com or nslookup google.com. My resolv.conf does have nameserver 8.8.8.8 in it. ping 8.8.8.8 works, but ping google.com says ping: unknown host google.com. –  BenjiWiebe May 15 '13 at 0:11
    
Try ping 8.8.8.8 if you can actually reach Google's open DNS servers. If your resolv.conf is set up correctly and you are able to reach those servers, name resolution should work (unless you have some more advanced stuff in your system like a malconfigured nsswitch.conf, etc.) –  Janoszen May 15 '13 at 7:11
    
Here is my nsswitch.conf file. (I didn't set it up; I have no idea what it does; this is the default one). EDIT: I can ping 8.8.8.8, and I can also ping Google's IP address. I still can't ping google.com though. It says ping: unknown host google.com. –  BenjiWiebe May 15 '13 at 16:55
    
The nsswitch.conf looks pretty standard. Can you check with tcpdump if your computer is actually sending out DNS packets? (port 53) –  Janoszen May 15 '13 at 16:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.