How to set a subnet and gateway to an ethernet interface


I’ve a problem. I need to configure a ethernet interface with ip-address, subnetmask and gateway…

with which commands can I do this?

Thanks for answer.

You configure an interface with an IP address and it’s associated subnet mask with :

set interfaces ethernet eth0 address

(the /24 is for a subnet mask of

A gateway is not specific to an interface. Actually on a router I prefer avoid the term gateway (even if on VyOs there’s a command to define a “system-gateway”).

On a router you have… …routes.

You can define a default route with the command :

set protocols static route next-hop

for example

hope it helps.

Thanks for the fast answer!

When my ip-address is: and my Gateway:

is the command I need:
set protocols static route next-hop

Because my Vyos says:
“Prefix not on a natural network boundary.Did you mean”


You get this message because when you configure a route (with the command “set protocol static route”) you must give a network address. is not a network address. It’s an host address, this host being in the network.

The configuration you want to achieve is not clear, can you share more details about your topology and what is your goal?

Ok I understand.

My network is this:

My Vyos is on a server that is in an unsecure network and on the interface eth0 is a domain-controller connected.
My Workplace is in a secure network. So all connections from the unsecure into the secure are not available.
From my Workplace I can connect to the server in the unsecure network.

My goal is to connect from my Workplace to the domain-controller with Remote Desktop.
For this, I must configure the interface eth1 with ip/prefix and gateway (that said my network-admin, I’m an apprentice :wink: )

Ok the command I need for the gateway was
“set system gateway-address x.x.x.x”



There seems to be a problem with your IP address. How are you using in a subnet of Your IP address does not fall in the range of your gateway’s subnet – - 254. Is your subnet supposed to be /16, rather than /24? Otherwise, I suggest you change your IP address to something more like And in your static protocol, you need to set the ip address that you are trying to reach, e.g., a server in the unsecured network, or you could use the entire subnet such as Now, if your interface used to reach the unsecured network is the internet interface, then you could simply apply the default ‘set protocols static route next-hop’ and this should do it.

Note: If your IP address is dynamic, and your subnet mask is, then your gateway has to be (or depending on your router, .254).

I know, but I must write the false combination for safety reasons.
But thanks for your answer, now it works.