illyasviel
Posts: 3
Joined: Thu Jun 13, 2019 6:46 am

Can't connect to internet after setting a static eth0 ip address

Thu Jun 13, 2019 7:27 am

Hi,
I am running Raspbian GNU/Linux 9 on my raspberry 3b+, and have installed the latest updates.
I managed to set a wlan0 static ip address which properly works however setting a static ip to eth0 interface is causing me some troubles, as I lose internet connection and can't even use SSH anymore.
I modified the /etc/dhcpcd.conf file and wrote this (there may be some minor typos and formatting inconsistencies as I am manually copying it, they are not in the original file)

Code: Select all

interface eth0
static ip_address=192.168.43.40/24
static routers=192.168.43.43
static domain_name_servers=192.168.43.43

interface wlan0
static ip_address=192.168.43.200/24
static routers=192.168.43.43
static domain_name_servers=192.168.43.43
This is my /etc/resolv.conf

Code: Select all

#generated by resolvconf
nameserver 192.168.43.43
nameserver  240e:470:xxx:xxxx::41 
route -n is giving me this

Code: Select all

Destination	Gateway		GenMask 		Flags 	Metric 	Iface
0.0.0.0		192.168.43.43	0.0.0.0		UG		202		eth0
0.0.0.0		192.168.43.43	0.0.0.0		UG		303		wlan0
192.168.43.0	0.0.0.0		255.255.255.0	U		202		eth0
192.168.43.0	0.0.0.0		255.255.255.0	U		303		wlan0
arp is giving me this after an arp flushing:

Code: Select all

Address			HWtype 	HWaddress	Flag Mask		Iface
192.168.43.43				(incomplete)				eth0
(The physical connection is OK as I am running SSH over ethernet cable just fine with DHCP instead of static IP)

Thank you for reading my post.

pcmanbob
Posts: 5948
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Can't connect to internet after setting a static eth0 ip address

Thu Jun 13, 2019 10:46 am

Hi.

So when you use DHCP to assign your pi IP address what IP address do you get ?

are the addresses you are assigning to your pi outside of the address range assigned by your router DHCP ?

and lastly were are you trying to do this , at home, office/work, university/school ?
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

illyasviel
Posts: 3
Joined: Thu Jun 13, 2019 6:46 am

Re: Can't connect to internet after setting a static eth0 ip address

Thu Jun 13, 2019 12:22 pm

Hi,
So when you use DHCP to assign your pi IP address what IP address do you get ?
If I am not using static ip then I have 169.254.120.101
are the addresses you are assigning to your pi outside of the address range assigned by your router DHCP ?
I am using an android mobile hotspot as a router, any ip in 192.168.43.X would be reserved for Android's DHCP server according to this post:
https://android.stackexchange.com/quest ... id-hotspot
and lastly were are you trying to do this , at home, office/work, university/school ?
At an office, the issue is that the wifi is only available to a certain number of registered device using their mac address, that's why I am using my 4G.

pcmanbob
Posts: 5948
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Can't connect to internet after setting a static eth0 ip address

Thu Jun 13, 2019 12:56 pm

Well if you hot spot obeys normal networking rules when you connect both wan and eth interfaces to the same network at the same time the eth connection will become the default , so you will have to ssh in via the eth IP.

Of course it may be that your hot spot does not like the same device having both a wan and eth connection at the same time, I have no way of knowing what rules are set within the hotspot.

generally its not good practice to have 2 connections wan & eth to the same router at the same time , as it often causes problems as you have discovered.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

illyasviel
Posts: 3
Joined: Thu Jun 13, 2019 6:46 am

Re: Can't connect to internet after setting a static eth0 ip address

Fri Jun 14, 2019 1:22 am

generally its not good practice to have 2 connections wan & eth to the same router at the same time , as it often causes problems as you have discovered.
Good to know, thanks, I will remember it!

Ok I am an idiot, I didn't change the ethernet interface of my computer which was on a different subnet...

Return to “Networking and servers”