3

I have two interfaces in my computer and this is how my routing table looks like when it boots up:

default via 192.168.80.1 dev enp4s1  proto static  metric 100
default 192.168.0.1 dev enp2s0  proto static  metric 101

However my Internet gateway is 192.168.0.1 so I won't have Internet connection each time my computer is rebooted, because the second network should be used for Internet access. I can set the default route manually and everything will work well:

sudo ip route add default via 192.168.0.1

but I don't want to do that every time. How to configure default gateway permanently?

2
  • 2
    Tell the administrator of the DHCP server which is providing the address 192.168.80.nnn to stop assigning a non-functional default gateway? Or, if you are using static addresses, don't assign a default gateway to enp4s1?
    – AlexP
    Dec 29, 2016 at 12:32
  • Can't do that. One network is our internal company network, second one much faster is for Internet access. Dec 30, 2016 at 7:13

2 Answers 2

4

Well I managed to solve this by myself simply by adding line

ip route add default via 192.168.0.1

to the /etc/rc.local script, so it gets executed every time automatically.

Note for everyone else, remember to change gateway IP address accordingly.

1
  • If you want to use the command on the console, you need sudo for this, and can also add the interface for that you want to add the default route, for example wifi: sudo ip route add default via 192.168.0.1 dev wlp2s0 – and if you want to use rc.local, you first have to enable the rc.local service on systemd.
    – rubo77
    Nov 11, 2018 at 9:03
1

Open the network manager and modify the connection. Click the networking icon in the tray then go to Edit Connections to open the dialog. In the dialog find your connection like Ethernet and press Edit and a dialog will appear. Go to the IPV4 tab and set your IP address or restore it to use DHCP which should find an IP address automatically.

enter image description here

1
  • I don't have any problems with connecting to both networks. My question is how to permanently add that static route I mentioned. Dec 30, 2016 at 7:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .