Skip to main content
Share Your Experience: Take the 2024 Developer Survey
36 votes
Accepted

Is it possible to have multiple default gateways for outbound connections?

Solved it myself. There seems to be very little information about the networking stuff that you can do with Linux, so I have decided to document and explain my solution in detail. This is my final ...
rosix's user avatar
  • 1,043
21 votes

Is it possible to have multiple default gateways for outbound connections?

Linux provides a better solution than your scripted workaround: active-backup bonding. This way your machine will have only one ip address (and one mac address) and automatically and transparently ...
Thilo's user avatar
  • 319
17 votes

Why does Ubuntu resolve the name `_gateway` to the default gateway instead of `gateway`?

Taken from systemd System and Service Manager, "CHANGES WITH 235": nss-myhostname/systemd-resolved will now by default synthesize an A/AAAA resource record for the "_gateway" ...
Chris Davies's user avatar
5 votes
Accepted

Can't change the default gateway with static IP

Your broadcast address should be 192.168.1.255, not 192.168.1.1.
Johan Myréen's user avatar
5 votes

How to set the Default gateway

For remove gateway in Linux Command : route delete default gw 192.168.1.1 eth1 For add gateway in Linux Command : route add default gw 192.168.1.250 eth1
gajjar rohit's user avatar
5 votes
Accepted

Configure two Routers on one Device

You need to create a second routing table and use policy based routing. Applied to your case you need to: Setup the first default route using the main routing table. This table will be used for the ...
Gohu's user avatar
  • 2,094
4 votes

How to blindly forward all packets from one interface to another?

Edit: Forgot that detail "no bridging", but the second article should do the trick as requested, providing the layer 3 solution that can connect different network types such as ethernet and wireless ...
Mr. Donutz's user avatar
3 votes
Accepted

How to prevent an unwanted default gateway to be added during reboot

You see the route is added by connmand (ConnMan daemon). It's not related to the normal interfaces settings but a separate config. If You cannot disable it completely (don't know whether it's needed ...
user301446's user avatar
3 votes
Accepted

Define network interface as the default gw independently of IP

Some modem cards are doing Proxy ARP. That means you can tell the default route is through the card without gateway and your system will start issuing an ARP request for any IP (eg ARP for 8.8.8.8 ...
A.B's user avatar
  • 36.9k
3 votes

UFW allow rules not working?

After some investigation, it turns out that UFW defaults to rejecting forwarding requests. One potential solution was to edit /etc/default/ufw and set DEFAULT_FORWARD_POLICY="ACCEPT", but this seemed ...
merlin2011's user avatar
  • 3,955
3 votes

Centos 7 running on VM how to set default gateway - ping google.com fails

This is expected behavior. Using host-only networking allows only connections between the host and the VM, or among VMs on the same host, as the name suggests. From the manual: "...and the virtual ...
user4556274's user avatar
  • 9,035
3 votes
Accepted

Does the Linux kernel support changing gateways based on state of IP outside your network?

does the Linux kernel support setting to check an IP through a gateway and using the state of that route to also change my gateways? No. Something like that is not in scope for the kernel. You should ...
Celada's user avatar
  • 44.3k
2 votes

Create tunnel from Host to Gateway

On the gateway: sysctl -w net.ipv4.ip_forward=1 iptables -t nat -A POSTROUTING --destination 10.0.20.0/24 -j MASQUERADE On the host (presumably in 192.168.20.0/xx), from which you are trying to ping ...
NarūnasK's user avatar
  • 2,375
2 votes
Accepted

What is difference between the gateway in ifcfg-ens192 and the one print by route

You misunderstand the meaning of a gateway. You need a gateway for reaching an IP address which is not link-local. 10.2.2.0/255.255.255.0 is link-local thus you do not need a gateway for it. This ...
Hauke Laging's user avatar
  • 90.1k
2 votes
Accepted

How to forbid my PC in LAN to make DNS queries? (in a PC -> VPN gateway scenario)

Drop all DNS queries that don't go to the VPN. DNS can use UDP port 53 or TCP port 53. iptables -A FORWARD -i eth0 ! -o tun0 -p udp --dport 53 -j DROP iptables -A FORWARD -i eth0 ! -o tun0 -p tcp --...
RalfFriedl's user avatar
  • 9,021
2 votes
Accepted

system get wrong gateway when bonding

Well, it seems gateway (also known as default gateway) is something different from what you think it is, since the way you have it configured looks incorrect to me. The default gateway defines how ...
filbranden's user avatar
  • 21.8k
2 votes
Accepted

DHCP-PD on wan side with Stateful DHCPv6 assigned globally routable ips on lan side. Need to dynamically configure DHCPv6 on lan side

So, I said the next step was to write scripts. Well, here they are. To explain, the solution I've come up with has two main parts. A template for the dhcpd.conf file. And a script to query the needed ...
Cliff Armstrong's user avatar
2 votes

Two default routes with same metric

Try: sudo ip route append default via 192.168.1.1 dev eth0 proto dhcp metric 11 note that append is used instead of add.
Dexuan's user avatar
  • 131
2 votes

How to have two different gateways on two different bridges in Proxmox VE

You're confusing the network routing table for the host with the definition of a bridge. A bridge does not have a default route; it's just a device for connecting different network interfaces. Routing ...
Chris Davies's user avatar
2 votes

NetworkManager doesn't change the metric of the default gateway immediately

I just tried that on my Linux Mint. Metric by default: 100. I used nmcli to change it to 50, then I disconnected, so the default route is removed. Then I reconnected, and I could see that the default ...
Dju's user avatar
  • 21
2 votes
Accepted

Isn't the gateway statement supposed to work for a subnet?

from my understanding you are only able to have one default route which it seems debian will take the first interface configured with a gateway as the default route. in your case eth0, if you are ...
vip32's user avatar
  • 36
2 votes
Accepted

Port forwarding does not work using different gateway

TL;DR (1st method only) On Desktop: ip route add 192.168.10.0/24 dev eth0 table 1000 ip route add default via 192.168.10.1 dev eth0 table 1000 ip rule add iif lo ipproto tcp sport 22 lookup 1000 The ...
A.B's user avatar
  • 36.9k
2 votes
Accepted

Unexpected Route Selection

It's a multipath route: both gateways are used, one has no precedence over the other, but for a specific destination (and other factors), the same gateway will be used to avoid disturbing flows using ...
A.B's user avatar
  • 36.9k
2 votes
Accepted

How to override isc-dhcpd option in child group, to hide default gateway

Use "option dhcp-parameter-request-list" to limit the parameters that the DHCP server can return to the client. see man page for dhcp-options (5). In that innermost group add something like: ...
Dave Funk's user avatar
1 vote

debian: cannot ping beyond the router

Assuming the iptables output is from the Debian router, your firewall MASQUERADE rule hasn't been applied. (In fact, none of your rules has been applied.) To fix the problem you can do one of two ...
Chris Davies's user avatar
1 vote

/etc/network/interfaces - multiple gateways 3 NICs

This link will describe how to do "load balancing" beetween this two gateways... http://tldp.org/HOWTO/Adv-Routing-HOWTO/lartc.rpdb.multiple-links.html It is important for you to read it carefully ...
Luciano Andress Martini's user avatar
1 vote

Two default gateways with different metric on CentOS 7 box - how?

Add IPV4_ROUTE_METRIC=xxx in /etc/sysconfig/network-scripts-/ifcfg-interface file. I had the same problem in a Centos 7 box; after some googling, I found this setting and got it to work across ...
Frankie's user avatar
  • 11
1 vote

Define network interface as the default gw independently of IP

try IP=$(ip a s dev eth0 | awk '$1=="inet" { split($2,I,"/") ;print I[1] }') ip route add default via $IP dev eth0 you might replace eth0 with a variable. I fail to se the point if eth0 (or ...
Archemar's user avatar
  • 31.6k
1 vote
Accepted

How can I find out what my default gateway should be?

If you have access to another host on the same network segment, look at its TCP settings. Chances are, the same Default Gateway will work for another host on the same segment. Do not assign the same ...
DopeGhoti's user avatar
  • 76.5k
1 vote

On OS X, how to grant network 192.168.3.* access to network 192.168.1.*?

To accomplish what you described, first you have to configure your Mac OS X host to act as a router between networks 192.168.1.0/24 and 192.168.3.0/24. To do that, you should enable forwarding in ...
filbranden's user avatar
  • 21.8k

Only top scored, non community-wiki answers of a minimum length are eligible