Setting a static local IP from the command line

1 view
Skip to first unread message

Richard Reina

unread,
Jul 19, 2021, 4:58:59 PM7/19/21
to luni-chicago
In the past I have been able to set a static local IP address and join a linux machine to my local network by plugging it in via the ethernet cable to the switch and doing:

/sbin/ifconfig eth0 192.168.0.23 up

However, when I do this with my newest raspberry pi and try pinging a local machine I ge

PING 192.168.0.12 (192.168.0.12) 56(84) bytes of data.
From 67.130.92.145 icmp_seq=1 Destination Net Unreachable
From 67.130.92.145 icmp_seq=2 Destination Net Unreachable
From 67.130.92.145 icmp_seq=3 Destination Net Unreachable

/sbin/ifconfig
eth0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.0.23  netmask 255.255.255.0  broadcast 192.168.0.255
        ether dc:a6:32:f2:c0:a4  txqueuelen 1000  (Ethernet)
        RX packets 148856  bytes 218800427 (208.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14185  bytes 1133435 (1.0 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Am I missing a step?

Richard

Hef

unread,
Jul 19, 2021, 5:34:51 PM7/19/21
to luni-c...@googlegroups.com
What does `ip route` show?
you should have a `default via x.x.x.x` or something like that
> --
> You received this message because you are subscribed to the Google Groups "Linux Users of Northern Illinois" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to luni-chicago...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/luni-chicago/CAKLxnzZPhDXMyHqJjBJ7YZmrtnqTzA0JURErvnytnTNbaaNsEA%40mail.gmail.com.

Richard Reina

unread,
Jul 19, 2021, 5:53:25 PM7/19/21
to luni-c...@googlegroups.com
ip route
default via 192.168.1.1 dev wlan0 proto dhcp src 192.168.1.34 metric 303
192.168.1.0/24 dev wlan0 proto dhcp scope link src 192.168.1.34 metric 303 

Hef

unread,
Jul 19, 2021, 5:59:14 PM7/19/21
to luni-c...@googlegroups.com
did you mean to set your local static ip to 192.168.1.23 instead of
192.168.0.23? (and ping 192.168.1.12 instead of 192.168.0.12)
> To view this discussion on the web visit https://groups.google.com/d/msgid/luni-chicago/CAKLxnzaayy0Q9rbmnQ1QCAQaUnuXMOASCYGbUYViN29BmV6YOA%40mail.gmail.com.

Richard Reina

unread,
Jul 19, 2021, 6:11:59 PM7/19/21
to luni-chicago
No, eth0 is plugged into a switch for a private LAN 192.168.0.1/24. wlan0 connects to the internet via a router 192.168.1.N


Hef

unread,
Jul 19, 2021, 6:47:09 PM7/19/21
to luni-c...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages