Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

I have arch-linux-arm running on a raspberryPi.
The network I am in uses static IPs.
gateway IP is 192.168.178.5
IP for my device is 192.168.178.201

To connect to the internet I use:
ip addr add 192.168.178.201 dev eth0
ip route add default via 192.168.178.5
However the latter yields
RTNETLINK answeres: Network is unreachable
What am I missing?

UPDATE
mtak's answer fixed the initial problem,
however I still cannot reach the gateway.
Attempting to ping result in destination host unreachable

share|improve this question
    
Is the link up? ip link set eth0 up – Patrick Jul 4 '14 at 8:55
1  
@Patrick yup. Initial problem already solved by mtak's answer. – Mark Jul 4 '14 at 8:57
up vote 4 down vote accepted

You need to add a subnet mask when you add the IP address. Now the system will think the IP is a /32, which does not include the ip 192.168.178.5, therefore it's unreachable.

To add the new IP address with a subnet mask:

ip addr add 192.168.178.201/24 dev eth0
share|improve this answer
    
Now it does not complain anymore when trying to set the route. However I still don't get to the internet. ping on the gateway itself results in destination host unreachable – Mark Jul 4 '14 at 8:51
2  
same problem here.. did you manage to get it to work? – branquito Feb 12 '15 at 21:39

try

ip route add 192.168.178.0/24 dev eth0 proto kernel  scope link  src 192.168.122.201

I flush my route main table, set static ip, encounter this problem.

I try to delete the static ip, readd again, observe what has been added to route table, and find this entry. Then I add default route, it works.

ip a del 192.168.178.201/24 dev eth0
ip a add 192.168.178.201/24 dev eth0
ip route add default via 192.168.178.5 dev eth0
share|improve this answer

Do you not have systemd and netctl? that's what arch usually uses. If you are not bound to using ip to connect to the internet, you can paste this into /etc/netctl/ethernet

Interface=eth0
Connection=ethernet
IP=static
Address=('192.168.178.201/24' '192.168.1.87/24')
#Routes=('192.168.0.0/24 via 192.168.1.2')
Gateway='192.168.178.5'
DNS=('192.168.178.5')

then execute netctl start ethernet (and if that works, netctl enable ethernet to auto-connect on bootup) this is the recommended way to connect to the internet on arch as far as I can understand.

Based on your former problems, I would guess that the issue might be that you are forgetting to define a DNS server (although it might be automated, I don't know)

If you still fail to reach the gateway, maybe you should double check your gateway's IP. Have you tried connecting with DHCP (like dhcpcd? or does your network simply not support that at all?) just to make sure that the connection can be made at all?

share|improve this answer

This worked for me

ip route flush dev eth0
ip route add 10.77.132.0/24 dev eth0
ip route add 0.0.0.0/0 via 10.77.132.1
share|improve this answer

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.