How to set a subnet and gateway to an ethernet interface


#1

Hey,

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.


#2

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

set interfaces ethernet eth0 address 192.168.0.1/24

(the /24 is for a subnet mask of 255.255.255.0)

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 0.0.0.0/0 next-hop 192.168.0.254

for example

hope it helps.


#3

Thanks for the fast answer!

When my ip-address is: 192.168.70.90/24 and my Gateway: 192.168.0.1

is the command I need:
set protocols static route 192.168.70.90/24 next-hop 192.168.0.1?

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

Thanks.


#4

You get this message because when you configure a route (with the command “set protocol static route”) you must give a network address.

192.168.70.90/24 is not a network address. It’s an host address, this host being in the 192.168.70.0/24 network.

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


#5

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: )


#6

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

^^


#7

lum,

There seems to be a problem with your IP address. How are you using 192.168.70.90 in a subnet of 192.168.0.0/24? Your IP address does not fall in the range of your gateway’s subnet – 192.168.0.1 - 254. Is your subnet supposed to be /16, rather than /24? Otherwise, I suggest you change your IP address to something more like 192.168.0.90/24. 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 192.168.0.0/24. 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 0.0.0.0/0 next-hop 192.168.0.1’ and this should do it.

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


#8

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