Unix & Linux Asked by swapfile on December 29, 2021
I have a Raspberry with eth0
(192.168.0.2
/ static
) connected to a router (Fritz Box @ 192.168.0.1
). The Router has internet connection. The Raspberry has a mobile usb stick with ppp
connect to the internet. Actually if ppp
is not connected the internet access from the Raspberry is through the Router over eth0
. If ppp
is connected the internet access is via ppp
. if I del the default route for eth0
there is no internet connection if ppp
is not connected and if ppp
is connected internet connection is through ppp
. So far everything fine. But if restart the raspberry it again has internet connection through eth0
. I want to allow the raspberry internet connection only via ppp
. eth0
just for internal communication like ssh. Any ideas how to configure that?
/etc/network/interfaces
looks like:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.178.2
netmask 255.255.255.0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Replacing the default route for eth0
with a higher metric (= lower priority) should work:
auto eth0
iface eth0 inet static
address 192.168.178.2
netmask 255.255.255.0
up ip route replace default via 192.168.178.1 dev eth0 metric 1024
# ^^^^^^^^^^^
This way if a default route with a lower metric is present, for example when ppp0
is connected, then that one will be selected. Otherwise, this metric 1024
one will be selected and your Pi will still have access to internet.
Answered by iBug on December 29, 2021
If you don't want the Raspberry to have an connection when PPP is disconnected, remove the gateway from your network configurations. Probably you're using the file /etc/network/interfaces, so open it on a text editor and change it from
auto eth0
inet iface eth0 static
address 192.168.0.1
netmask 255.255.255.0
gateway 192.168.0.1
to
auto eth0
inet iface eth0 static
address 192.168.0.1
netmask 255.255.255.0
#gateway 192.168.0.1
You'll still able to access the raspberry on local network (192.168.0.0/24) but it won't have an internet connection if PPP is down.
Answered by JucaPirama on December 29, 2021
Sounds like you want to get rid of a static route. Check your /etc/network/interfaces
file for any route configuration. Comment these lines (add a #
at the beginning of the line), save the file, reboot, and try again.
But your Pi is more than likely getting this info via DHCP, I would suggest configuring the interface with static details (and without a route).
Answered by relevantRope on December 29, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP