How can I set up a static IP on my Arch Linux installation so I can easily SSH in?

I followed this thread, but I could not get the static IP I set to work! Here's my /etc/netctl/eth0 file:

Description='A simple ethernet connection using a static IP'
Interface=eth0
Connection=ethernet
IP=static
Address=('192.168.1.5/24')

Can anyone see what my problem is and/or point/give me to a good tutorial on how to set this up?

DHCP isn't a huge problem, just a little slower, because I have to look up the IP via the router.

EDIT: Trying @syb0rg's solution:

I worked through the solution up to the netctl start eth0 part, and then it threw an error:

$ sudo netctl start eth0

Job for netctl@eth0.service failed. See 'systemctl status netctl@eth0.service' and 'journalctl -xn' for details.

$ systemctl status netctl@eth0.service

netctl@eth0.service - Networking for netctl profile eth0
   Loaded: loaded (/usr/lib/systemd/system/netctl@.service; static)
   Active: failed (Result: exit-code) since Wed 1969-12-31 19:12:12 EST; 21s ago
     Docs: man:netctl.profile(5)
  Process: 316 ExecStart=/usr/lib/network/network start %I (code=exited, status=1/FAILURE)
 Main PID: 316 (code=exited, status=1/FAILURE)

journalctl -xn

-- Logs begin at Wed 1969-12-31 19:00:32 EST, end at Wed 1969-12-31 19:10:43 EST
Dec 31 19:08:49 ArchPiServer systemd[294]: Stopped target Sound Card.
-- Subject: Unit UNIT has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Documentation: http://www.freedesktop.org/wiki/Software/systemd/catalog/9d1aa
-- 
-- Unit UNIT has finished shutting down.
Dec 31 19:08:49 ArchPiServer systemd[294]: Starting Default.
-- Subject: Unit UNIT has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit UNIT has begun starting up.
Dec 31 19:08:49 ArchPiServer systemd[294]: Reached target Default.
-- Subject: Unit UNIT has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit UNIT has finished starting up.
-- 
-- The start-up result is done.
Dec 31 19:08:49 ArchPiServer systemd[294]: Startup finished in 830ms.
-- Subject: System start-up is now complete
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- All system services necessary queued for starting at boot have been
-- successfully started. Note that this does not mean that the machine is
-- now idle as services might still be busy with completing start-up.
-- 
-- Kernel start-up required KERNEL_USEC microseconds.
-- 
-- Initial RAM disk start-up required INITRD_USEC microseconds.
-- 
-- Userspace start-up required 830163 microseconds.
Dec 31 19:10:43 ArchPiServer sudo[301]: pam_unix(sudo:account): account server-g

What gives?

up vote 7 down vote accepted

Change directories to access the network settings:

# cd /etc/netctl
# cp examples/ethernet-static ./eth0

We need to edit the configuration file, etch0, and add in the settings we need. Before you proceed, you will need the following:

  • Static IP address – I’m using 192.168.1.36. The netmask I’m using is 255.255.255.0 which is defined as "/24" or the first 24 bits.
  • An Interface name – I’m using eth0.
  • A default gateway – I use 192.168.1.1.
  • Some DNS names servers – I’m using 8.8.8.8 and 194.168.4.100 and 194.168.8.100 – which are Google and Virgin Media’s DNS servers. You should use the ones you have been told to use by your own ISP.

When you have finished editing the file, it should look like the following, using the settings above:

Description='Anything you like'
Interface=eth0
Connection=ethernet
IP=static
Address=('192.168.1.36/24')
gateway=('192.168.1.1')
DNS=('8.8.8.8' '194.168.4.100' '194.168.8.100')

Save the file and exit the editor. Try starting the network:

# netctl start eth0

Note: On my system, that always returns an error, but the networking actually begins working.


After this, I can ping 8.8.8.8 and also ping google.com and in both cases, get a correct response.

If your network starts ok, without error, and works, then you can configure it to always start on boot by running the following command:

# netctl enable eth0

If you ever decide to disable it again, it’s equally as simple:

# netctl disable eth0
  • I noticed you spelled gateway with lowercase instead of Gateway. This was actually the solution for me. This is how I realized, that I should just leave out Gateway= (or comment it), which has the same effect as a bad spelling. I'm not sure if it was just a typo, but if it is, it solved my problem! I guess on an ethernet connection you usually don't really need to specify a gateway. – Yeti Feb 10 at 21:05

You would be better to set your router to serve a static IP to the Pi. This way you can easily use the Pi on other networks, and avoid problems with duplicate IP

You have to add

AutoWired=yes

to your static config in order to get it to work.

Here's a tutorial: http://blog.pixxis.be/post/77298179924/setting-up-a-static-ip-on-arch-linux

  • This is important indeed, but still it won't work for me... It is a pain in the A**... – 71GA Dec 13 '14 at 8:33

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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