LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Allow outgoing traffic only from one interface (https://www.linuxquestions.org/questions/linux-networking-3/allow-outgoing-traffic-only-from-one-interface-4175718595/)

rbauduin 11-09-2022 07:59 AM

Allow outgoing traffic only from one interface
 
I explain you quickly my project to start:

I have a server (debian 11) with a 4G SIM card and a router that also has a 4G SIM card. The server is temporarily present to supervise the 4G router, my idea is to connect the server in LAN to the router so that it retrieves the logs from the router and transmits them (via promtail) to another remote server.

The server should not depend on the 4G connection of the router but on its connection, how can I, via iptables, iproute I suppose, communicate only in LAN with the router and use only the 4G connection of the server to communicate with the outside?

Thanks !

elgrandeperro 11-09-2022 08:44 AM

Default route determines that. You set default to be the 4G Sim interface, and the other, if it is on the same network, should take that route because is is a direct connect and has higher precedence.

rbauduin 11-09-2022 02:11 PM

Okay, thanks for the return.

I removed the gateway from the local network and this is what I have:

root@server:~# ip route
default via 80.125.158.44 dev wwan0 proto static metric 700
80.125.158.40/29 dev wwan0 proto kernel scope link src 80.125.158.43 metric 700
192.168.1.0/24 dev enp2s0 proto kernel scope link src 192.168.1.23 metric 100

If you can confirm me that everything is good?

Thank you!


All times are GMT -5. The time now is 04:28 PM.