At my work we have some test machines that we run scripts on via ssh. During the test we want to only have the machines access the local network through their Ethernet connection, but then would like to have them be able to access the Internet through the same interface for cleanup and data transmission after.
We can do this by going to each machine and toggling the "Use this connection only for resources on its network"
option in the network manager
> IPv4 options
> routes menu
, but it would be a lot more convenient to be able to add this into our test script.
I can find some similar questions that have to do with VPN connections, but I want to make sure I handle the routing correctly for the regular Ethernet interface. Thanks for any help.
Best Answer
You can use
nmcli
to do it, the key isipv4.never-default
:enp3s0
with your own connection name.false
ortrue
to toggle between this config.