Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ?… – 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 – 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
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 dev wlan0
ip route add default via

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' >/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, but not ping or nslookup My resolv.conf does have nameserver in it. ping works, but ping says ping: unknown host – BenjiWiebe May 15 '13 at 0:11
Try ping 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, and I can also ping Google's IP address. I still can't ping though. It says ping: unknown host – 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .