[quote=“Clem73666, post:21, topic:9467, full:true”]
This command does not give any error, and it adds another Ethernet address to the pi.
command hostname -I
prior returns:
192.168.1.4 192.168.1.15
.4 is the non static allocated ip for eth0, …15 is the wifi ip.
after command
hostname -I
192.168.1.17 192.168.1.4 192.168.1.15
In other words, eth0 now has two ip addresses, …17 and … 4
Also how do I get rid of the old ip and how do I put this in a config file?
It’s not clear why you want a static address. I guess you have your reasons. The easiest way is go to DHCP settings in your router. You will find there’s a way to associate an IP address with a MAC address. If you require both eth0 and wlan connectivity then both devices have MAC addresses and DHCP can allocate IP addresses to both. The IP addresses must be different. Then set the pi to use DHCP.
If you really want static configuration then I think you have the right answer but have to remove spaces around static routers=192.168.1.1
The fact you added a route and it worked indicates to me the static routers line was ignored. There’s probably a message telling you that hidden in a log somewhere.
This is what I get on the console:
Pi17 boots as non static IP, 4 is allocated by router on boot
Pi101 console:
prior to running sudo ifconfig eth0 192.168.1.17
on Pi17:
Starting Nmap 7.40 ( https://nmap.org ) at 2021-02-26 13:11 AEST
Nmap scan report for 192-168-1-1.tpgi.com.au (192.168.1.1)
Host is up (0.0039s latency).
Nmap scan report for 192-168-1-3.tpgi.com.au (192.168.1.3)
Host is up (0.011s latency).
Nmap scan report for 192-168-1-4.tpgi.com.au (192.168.1.4)
Host is up (0.0024s latency).
Nmap scan report for 192-168-1-8.tpgi.com.au (192.168.1.8)
Host is up (0.0011s latency).
Nmap scan report for 192-168-1-11.tpgi.com.au (192.168.1.11)
Host is up (0.0011s latency).
Nmap scan report for 192-168-1-13.tpgi.com.au (192.168.1.13)
Host is up (0.0021s latency).
Nmap scan report for 192-168-1-15.tpgi.com.au (192.168.1.15)
Host is up (0.087s latency).
Nmap scan report for 192-168-1-21.tpgi.com.au (192.168.1.21)
Host is up (0.0015s latency).
Nmap scan report for 192-168-1-101.tpgi.com.au (192.168.1.101)
Host is up (0.0011s latency).
Nmap scan report for 192-168-1-102.tpgi.com.au (192.168.1.102)
Host is up (0.00091s latency).
Nmap scan report for 192-168-1-200.tpgi.com.au (192.168.1.200)
Host is up (0.0038s latency).
Nmap done: 256 IP addresses (11 hosts up) scanned in 2.34 seconds
`
Pi101 console:
after running sudo ifconfig eth0 192.168.1.17
on Pi17:
pi@raspberrypi:~ $ nmap -sn 192.168.1.0/24
Starting Nmap 7.40 ( https://nmap.org ) at 2021-02-26 13:14 AEST
Nmap scan report for 192-168-1-1.tpgi.com.au (192.168.1.1)
Host is up (0.0038s latency).
Nmap scan report for 192-168-1-3.tpgi.com.au (192.168.1.3)
Host is up (0.0062s latency).
Nmap scan report for 192-168-1-4.tpgi.com.au (192.168.1.4)
Host is up (0.0022s latency).
Nmap scan report for 192-168-1-8.tpgi.com.au (192.168.1.8)
Host is up (0.00096s latency).
Nmap scan report for 192-168-1-11.tpgi.com.au (192.168.1.11)
Host is up (0.0018s latency).
Nmap scan report for 192-168-1-13.tpgi.com.au (192.168.1.13)
Host is up (0.00091s latency).
Nmap scan report for 192-168-1-15.tpgi.com.au (192.168.1.15)
Host is up (0.042s latency).
Nmap scan report for 192-168-1-17.tpgi.com.au (192.168.1.17)
Host is up (0.0018s latency).
Nmap scan report for 192-168-1-20.tpgi.com.au (192.168.1.20)
Host is up (0.0015s latency).
Nmap scan report for 192-168-1-21.tpgi.com.au (192.168.1.21)
Host is up (0.0021s latency).
Nmap scan report for 192-168-1-101.tpgi.com.au (192.168.1.101)
Host is up (0.00036s latency).
Nmap scan report for 192-168-1-102.tpgi.com.au (192.168.1.102)
Host is up (0.0024s latency).
Nmap scan report for 192-168-1-200.tpgi.com.au (192.168.1.200)
Host is up (0.0017s latency).
Nmap done: 256 IP addresses (13 hosts up) scanned in 2.36 seconds
pi@raspberrypi:~ $ ^C
pi@raspberrypi:~ $ ping 192.168.1.4
PING 192.168.1.4 (192.168.1.4) 56(84) bytes of data.
64 bytes from 192.168.1.4: icmp_seq=1 ttl=64 time=0.393 ms
64 bytes from 192.168.1.4: icmp_seq=2 ttl=64 time=0.359 ms
64 bytes from 192.168.1.4: icmp_seq=3 ttl=64 time=0.289 ms
64 bytes from 192.168.1.4: icmp_seq=4 ttl=64 time=0.321 ms
64 bytes from 192.168.1.4: icmp_seq=5 ttl=64 time=0.330 ms
^C
--- 192.168.1.4 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4197ms
rtt min/avg/max/mdev = 0.289/0.338/0.393/0.038 ms
pi@raspberrypi:~ $ ping 192.168.1.17
PING 192.168.1.17 (192.168.1.17) 56(84) bytes of data.
64 bytes from 192.168.1.17: icmp_seq=1 ttl=64 time=0.372 ms
64 bytes from 192.168.1.17: icmp_seq=2 ttl=64 time=0.326 ms
64 bytes from 192.168.1.17: icmp_seq=3 ttl=64 time=0.313 ms
64 bytes from 192.168.1.17: icmp_seq=4 ttl=64 time=0.343 ms
64 bytes from 192.168.1.17: icmp_seq=5 ttl=64 time=0.323 ms
--- 192.168.1.17 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4133ms
rtt min/avg/max/mdev = 0.313/0.335/0.372/0.026 ms
^Cpi@raspberrypi:~ $ ping 192.168.1.15
PING 192.168.1.15 (192.168.1.15) 56(84) bytes of data.
64 bytes from 192.168.1.15: icmp_seq=1 ttl=64 time=83.0 ms
64 bytes from 192.168.1.15: icmp_seq=2 ttl=64 time=14.1 ms
64 bytes from 192.168.1.15: icmp_seq=3 ttl=64 time=1.71 ms
64 bytes from 192.168.1.15: icmp_seq=4 ttl=64 time=1.39 ms
^C
--- 192.168.1.15 ping statistics
---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 1.393/25.075/83.024/33.850
ms
pi@raspberrypi:~ $
`
Console of Pi17:
pi@raspberrypi:~ $ hostname -I
192.168.1.4 192.168.1.15 fdfc:3f7c:39fb:6000:66ad:dea2:b55:a64f fdfc:3f7c:39fb:6000:dea6:32ff:fe7c:3538
pi@raspberrypi:~ $ sudo ifconfig eth0 192.168.1.17
pi@raspberrypi:~ $ hostname -I
192.168.1.17 192.168.1.4 192.168.1.15 fdfc:3f7c:39fb:6000:66ad:dea2:b55:a64f fdfc:3f7c:39fb:6000:dea6:32ff:fe7c:3538
pi@raspberrypi:~ $
`
Why does the Pi17 finish up with two ipo addresses ( .17 AND .4) ?
How do I do this in a config file so that it will ask for the IP address upon boot up.
I need to be able to determine the ip addresses of each device in this network and I want to be able to do it when I set up the Pi prior to adding it to the network. I do NOT want to have to fool around with the router, this also has to be able to be configured on a network with a switch only - no router and then I will configure then as static IP’s
AHHH! the code block does not work properly!
Pi17 boots as non static IP, 4 is allocated by router on boot
Pi101 console:
prior to running sudo ifconfig eth0 192.168.1.17
on Pi17:
’
Starting Nmap 7.40 ( https://nmap.org ) at 2021-02-26 13:11 AEST
Nmap scan report for 192-168-1-1.tpgi.com.au (192.168.1.1)
Host is up (0.0039s latency).
Nmap scan report for 192-168-1-3.tpgi.com.au (192.168.1.3)
Host is up (0.011s latency).
Nmap scan report for 192-168-1-4.tpgi.com.au (192.168.1.4)
Host is up (0.0024s latency).
Nmap scan report for 192-168-1-8.tpgi.com.au (192.168.1.8)
Host is up (0.0011s latency).
Nmap scan report for 192-168-1-11.tpgi.com.au (192.168.1.11)
Host is up (0.0011s latency).
Nmap scan report for 192-168-1-13.tpgi.com.au (192.168.1.13)
Host is up (0.0021s latency).
Nmap scan report for 192-168-1-15.tpgi.com.au (192.168.1.15)
Host is up (0.087s latency).
Nmap scan report for 192-168-1-21.tpgi.com.au (192.168.1.21)
Host is up (0.0015s latency).
Nmap scan report for 192-168-1-101.tpgi.com.au (192.168.1.101)
Host is up (0.0011s latency).
Nmap scan report for 192-168-1-102.tpgi.com.au (192.168.1.102)
Host is up (0.00091s latency).
Nmap scan report for 192-168-1-200.tpgi.com.au (192.168.1.200)
Host is up (0.0038s latency).
Nmap done: 256 IP addresses (11 hosts up) scanned in 2.34 seconds
'
Pi101 console:
after running sudo ifconfig eth0 192.168.1.17
on Pi17:
pi@raspberrypi:~ $ nmap -sn 192.168.1.0/24
Starting Nmap 7.40 ( https://nmap.org ) at 2021-02-26 13:14 AEST
Nmap scan report for 192-168-1-1.tpgi.com.au (192.168.1.1)
Host is up (0.0038s latency).
Nmap scan report for 192-168-1-3.tpgi.com.au (192.168.1.3)
Host is up (0.0062s latency).
Nmap scan report for 192-168-1-4.tpgi.com.au (192.168.1.4)
Host is up (0.0022s latency).
Nmap scan report for 192-168-1-8.tpgi.com.au (192.168.1.8)
Host is up (0.00096s latency).
Nmap scan report for 192-168-1-11.tpgi.com.au (192.168.1.11)
Host is up (0.0018s latency).
Nmap scan report for 192-168-1-13.tpgi.com.au (192.168.1.13)
Host is up (0.00091s latency).
Nmap scan report for 192-168-1-15.tpgi.com.au (192.168.1.15)
Host is up (0.042s latency).
Nmap scan report for 192-168-1-17.tpgi.com.au (192.168.1.17)
Host is up (0.0018s latency).
Nmap scan report for 192-168-1-20.tpgi.com.au (192.168.1.20)
Host is up (0.0015s latency).
Nmap scan report for 192-168-1-21.tpgi.com.au (192.168.1.21)
Host is up (0.0021s latency).
Nmap scan report for 192-168-1-101.tpgi.com.au (192.168.1.101)
Host is up (0.00036s latency).
Nmap scan report for 192-168-1-102.tpgi.com.au (192.168.1.102)
Host is up (0.0024s latency).
Nmap scan report for 192-168-1-200.tpgi.com.au (192.168.1.200)
Host is up (0.0017s latency).
Nmap done: 256 IP addresses (13 hosts up) scanned in 2.36 seconds
pi@raspberrypi:~ $ ^C
pi@raspberrypi:~ $ ping 192.168.1.4
PING 192.168.1.4 (192.168.1.4) 56(84) bytes of data.
64 bytes from 192.168.1.4: icmp_seq=1 ttl=64 time=0.393 ms
64 bytes from 192.168.1.4: icmp_seq=2 ttl=64 time=0.359 ms
64 bytes from 192.168.1.4: icmp_seq=3 ttl=64 time=0.289 ms
64 bytes from 192.168.1.4: icmp_seq=4 ttl=64 time=0.321 ms
64 bytes from 192.168.1.4: icmp_seq=5 ttl=64 time=0.330 ms
^C
--- 192.168.1.4 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4197ms
rtt min/avg/max/mdev = 0.289/0.338/0.393/0.038 ms
pi@raspberrypi:~ $ ping 192.168.1.17
PING 192.168.1.17 (192.168.1.17) 56(84) bytes of data.
64 bytes from 192.168.1.17: icmp_seq=1 ttl=64 time=0.372 ms
64 bytes from 192.168.1.17: icmp_seq=2 ttl=64 time=0.326 ms
64 bytes from 192.168.1.17: icmp_seq=3 ttl=64 time=0.313 ms
64 bytes from 192.168.1.17: icmp_seq=4 ttl=64 time=0.343 ms
64 bytes from 192.168.1.17: icmp_seq=5 ttl=64 time=0.323 ms
--- 192.168.1.17 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4133ms
rtt min/avg/max/mdev = 0.313/0.335/0.372/0.026 ms
^Cpi@raspberrypi:~ $ ping 192.168.1.15
PING 192.168.1.15 (192.168.1.15) 56(84) bytes of data.
64 bytes from 192.168.1.15: icmp_seq=1 ttl=64 time=83.0 ms
64 bytes from 192.168.1.15: icmp_seq=2 ttl=64 time=14.1 ms
64 bytes from 192.168.1.15: icmp_seq=3 ttl=64 time=1.71 ms
64 bytes from 192.168.1.15: icmp_seq=4 ttl=64 time=1.39 ms
^C
--- 192.168.1.15 ping statistics
---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 1.393/25.075/83.024/33.850
ms
pi@raspberrypi:~ $
’
Console of Pi17:
pi@raspberrypi:~ $ hostname -I
192.168.1.4 192.168.1.15 fdfc:3f7c:39fb:6000:66ad:dea2:b55:a64f fdfc:3f7c:39fb:6000:dea6:32ff:fe7c:3538
pi@raspberrypi:~ $ sudo ifconfig eth0 192.168.1.17
pi@raspberrypi:~ $ hostname -I
192.168.1.17 192.168.1.4 192.168.1.15 fdfc:3f7c:39fb:6000:66ad:dea2:b55:a64f fdfc:3f7c:39fb:6000:dea6:32ff:fe7c:3538
pi@raspberrypi:~ $
Cannot figure out how to use code blocks properly!!
I don’t know anything about code blocks, a little about the pi, more about Linux and a lot about networking
As far as I can figure it, the key is in the dhcpcd.conf file and the recommendation is to add the lines at the end, not the beginning. This was a sample:
interface eth0
static ip_address=192.168.0.10/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1
interface wlan0
static ip_address=192.168.0.200/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1
If you are thinking of working without a router, you will not be able to access the Internet. The router is what gets you a connection to the Internet. If you put a switch in the network it is “invisible”, you configure the network like it isn’t there. The router provides DHCP (gives out IP addresses) and also (usually) resolves names to IP addresses. Take the router out and you won’t have these either.
If you’ve fiddled with the router table or /etc/network/interfaces then they need to be put back to original.
please get rid of the spaces in the line static routers = 192.168.1.1 - should be static routers=192.168.1.1
You really need to look at the router to see what addresses are being allocated by DHCP. You must ensure the range doesn’t cover your static addresses.
I have been able to get the static IPs working now - it appears that the no space around the = sign in the config file is important.
Hi Clem,
Yes, in most programming languages there’s filtering to remove the whitespaces so that you can indent text however you would like (for example the C obfuscation challenge abuses this constantly) however, in config files, scripts usually just read all characters that aren’t commended and won’t filter spaces from the strings, thanks for sharing this issue so others can hopefully realise here rather than after hours of troubleshooting Best of luck with your project!
The links for those curious: