[raspberry] adding two static ips on eth0
by ciroreed from LinuxQuestions.org on (#5AV1W)
Hello there!
Disclaimer, im a network noob
I have to put my rasp on a network that requires me to set an ip address of "192.168.250.X" in order to see a device.
I've readed throughout the internet and I know that dhcpcd can't configure two ips
I've tested this approach without success: https://raspberrypi.stackexchange.co...4d4c7e62fad64a
Right now I have a sh script:
Code:ip=`cat /home/pi/config/globals.json | jq -r .DEVICE_IP`
ifconfig eth0:0 $ip/24
# ip addr add $ip/24 dev eth0:0Running it from sudo does work, testing it with "$ ip addr" returns:
Code:2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether dc:a6:32:af:87:7b brd ff:ff:ff:ff:ff:ff
inet 192.168.1.210/24 brd 192.168.1.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet 192.168.250.15/24 brd 192.168.250.255 scope global eth0:0
valid_lft forever preferred_lft forever
inet6 fe80::a8fc:840c:bed9:e650/64 scope link
valid_lft forever preferred_lft foreverHowever i need to have this ip always up so I tried to run the script from @reboot directive in crontab (sudo crontab -e). @reboot /home/pi/scripts/addip.sh
But it doens't work :(
this is my dhcpcd.conf:
Code:hostname
clientid
persistent
option rapid_commit
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
option interface_mtu
require dhcp_server_identifier
slaac private
interface eth0
static ip_address=192.168.1.210/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 1.1.1.1
interface wlan0
static ip_address=192.168.210.1/24
nohook wpa_supplicantwhat am i doing wrong
thanks!


Disclaimer, im a network noob
I have to put my rasp on a network that requires me to set an ip address of "192.168.250.X" in order to see a device.
I've readed throughout the internet and I know that dhcpcd can't configure two ips
I've tested this approach without success: https://raspberrypi.stackexchange.co...4d4c7e62fad64a
Right now I have a sh script:
Code:ip=`cat /home/pi/config/globals.json | jq -r .DEVICE_IP`
ifconfig eth0:0 $ip/24
# ip addr add $ip/24 dev eth0:0Running it from sudo does work, testing it with "$ ip addr" returns:
Code:2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether dc:a6:32:af:87:7b brd ff:ff:ff:ff:ff:ff
inet 192.168.1.210/24 brd 192.168.1.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet 192.168.250.15/24 brd 192.168.250.255 scope global eth0:0
valid_lft forever preferred_lft forever
inet6 fe80::a8fc:840c:bed9:e650/64 scope link
valid_lft forever preferred_lft foreverHowever i need to have this ip always up so I tried to run the script from @reboot directive in crontab (sudo crontab -e). @reboot /home/pi/scripts/addip.sh
But it doens't work :(
this is my dhcpcd.conf:
Code:hostname
clientid
persistent
option rapid_commit
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
option interface_mtu
require dhcp_server_identifier
slaac private
interface eth0
static ip_address=192.168.1.210/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 1.1.1.1
interface wlan0
static ip_address=192.168.210.1/24
nohook wpa_supplicantwhat am i doing wrong
thanks!