0

My Pi is connected to my router by Ethernet.

Attempting to set up a static IP address for my Pi, I added the following lines to dhcpcd.conf:

interface eth0

static ip_address=192.168.0.2/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1

interface wlan0

static ip_address=192.168.0.2/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1

I rebooted and found that I couldn't connect to my Pi with SSH using 192.168.0.2 as the IP address. I connected to my router and found that the Pi appeared to be connected by Ethernet but with the following IP address: fe80::340b:6d47:32d:fb60. I am able to connect to my Pi via SSH using this address. There's a (6) icon next to this address which makes me think that the issue is to do with IPv6 vs. IPv4. I notice that in the example static IP adress configuration there's a field called static ip6_address but I don't know how I should use it.

If I run hostname -I I get: 192.168.0.2.

If I run ip a the output under eth0 is the following:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:9f:26:20 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.2/24 brd 192.168.0.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::340b:6d47:32d:fb60/64 scope link 
       valid_lft forever preferred_lft forever

Why is the set static IP address not working, and how can I remedy this?

4
  • Welcome. "Why is the IP address not the one which I intended to set" -> It is: inet 192.168.0.2/24. Why it doesn't work I can't tell you, but it likely is to do with IPv6. When IPv4 and v6 are enabled (which is normal), you will have two addresses. They should both work.
    – goldilocks
    Commented Jan 12, 2019 at 16:36
  • @goldilocks Good point; question updated.
    – C Ren
    Commented Jan 12, 2019 at 17:16
  • @goldilocks it's IPv4 - nothing to do with IPv6 (which is an entirely separate network stack). What we need to ask is what's the address of the router, is it really 192.168.0.1 (some home systems use 192.168.0.254, some use 192.168.1.1 or 192.168.1.254). Before setting a static address look at what's assigned by DHCP. Also if the router supports it do the static assignment in the router (that's less likely to conflict with DHCP pools). So the first move the OP needs to do is look at settings on their laptop with ipconfig /all (windows) or ifconfig -a (Linux/OSX).
    – Dougie
    Commented Jan 12, 2019 at 18:27
  • What's the output of ip route show ? that will show what the Pi thinks it's network set up is.
    – user72404
    Commented Jan 12, 2019 at 18:45

2 Answers 2

1

You can't have duplicate ip addresses on the same network and if both wifi and network cable are connected that would be the case with your static settings. Either disable one of the interfaces (Wifi/wlan0 or cable/eth0) or change one of the IP addresses then SSH will know which to connect to.

1
  • I'm fairly certain that I disabled Wi-Fi when I started using Ethernet.
    – C Ren
    Commented Jan 12, 2019 at 17:42
0

By changing the static ip_address field for both wlan0 and eth0 to 192.168.1.1 I managed to make it work. Nothing else was changed. I'm not sure why this works though.

2
  • Before setting static addresses you must look at what's assigned by your router's DHCP server. That usually gives you a clue as to what address block should be used for static addresses.
    – Dougie
    Commented Jan 12, 2019 at 18:28
  • 1
    192.168.1.x and 192.168.0.x are different subnets that don't "talk" to each other without further setup which I doubt you have done, since you seem to have chosen the 192.168.0.x subnet almost randomly without regard to your current LAN settings Commented Jan 12, 2019 at 23:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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