My network structure has a switch where the gateway is, and my computer has the IP address

I want to continue using this IP address and use the gateway Why?

To avoid conflicts with another networks - And also, i have a BUNCH of Firewall rules configured for

Is this possible?

I saw a server once that had IP and had a totally different gateway!! It worked just fine but i have no clue on how they did it.

Thanks in advance!

  • A default gateway is an IP address that traffic gets sent to when it's bound for a destination outside the current network. So by definition, it is totally possible. Now what system is this for which you need configuration? Which device? Which firmware? Which manufacturer? – advay rajhansa 2 days ago
  • It's not clear what you mean by "different address". Normally, a gateway has a different address than the device that uses the gateway. Two devices with the same address on the same network will cause trouble. The firewall rules are irrelevant, except if they block access to the gateway. – berndbausch 2 days ago
  • The device is a Linux distro: CentOS 7. – Raul Chiarella 2 days ago
  • @berndbausch What i mean by different address is exactly that, actually. The gateway is a IP and the IP of the machine is totally different - Gateway: IP Address: I just dont know how to do that. I tried just setting up for the IP and for the gateway but it didnt work... I get host unreacheable – Raul Chiarella 2 days ago
  • If i change the IP to (Or another one on the same range than the gateway) and gateway it works :/ I dont want to use tho - I want – Raul Chiarella 2 days ago

You can achieve this by defining the default gateway adress and the connection/interface used to reach it. By default your system only knows how to reach the locally defined subnet (I guess it's a /24 network mask, so you can reach adresses to without any changes). Now you must tell it the address of the gateway and which interface is connected to it.

E.g.: You have interface eth0 connected to your LAN with IP and netmask 24 (=, then you define the default gateway by saying "default gw is reachable via eth0".

With CentOS7 the network managment is done by NetworkManager. You can use the cli to setup the default gateway:

sudo nmcli connection modify eth0 ipv4.gateway ""
sudo nmcli connection up eth0

See also https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/sec-configuring_static_routes_using_nmcli

You can also modify configuraton files directly by following this guide: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/sec-configuring_static_routes_in_ifcfg_files

Edit (as I can't post comments):

You can connect to any address that is reachable via a physically connected network. The poster didn't tell us if there are multiple physical networks involved and if there is some dedicated router that does the connection between the networks. Therefore I suggest he can reach the gateway directly and only needs to tell his system which interface to use.

  • How can you talk to a device in if your interface is in How would the router reply to you? It would have no local interface capable of reaching – vidarlo yesterday

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.