Skip to main content
56 votes

How to refuse routes that are PUSHed by OpenVPN server?

Times have moved on, and as of 2017 (OpenVPN 2.4) this is possible with pull-filter accept "route 192.168." pull-filter ignore "route 172." pull-filter accept "route 1" pull-filter ignore "route " ...
Criggie's user avatar
  • 1,791
50 votes

How to find out which interface am I using for connecting to the internet?

My version which is basically based on this and this: route | grep '^default' | grep -o '[^ ]*$' And this, experimentally, for macOS: route -n get default | grep 'interface:' | grep -o '[^ ]*$'
Ebrahim Byagowi's user avatar
42 votes

How can I make changes to the network routing metric permanently

If you are using NetworkManager, the proper way to change the metric for the default route is to modify the connection associated with interface enp0s3 in this way: nmcli connection modify <...
bengal's user avatar
  • 559
34 votes

Modifying existing route entry in linux

(Combining various comments into an answer) Currently, it is not possible to modify a route's metric. As a 2005 message on LKML states: [...] The metric/priority cannot be changed because we do ...
Mark's user avatar
  • 441
27 votes
Accepted

Linux 64-bit SSH port numbers?

Is it possible to configure Linux to use 64 bit ports? You cannot change a parameter to use 64bit ports in TCP/UDP. You could create similar protocols, but you would only be able to communicate with ...
Eduardo Trápani's user avatar
24 votes

How to find out which interface am I using for connecting to the internet?

One liner: ip route get 8.8.8.8 | sed -n 's/.*dev \([^\ ]*\).*/\1/p'
h0tw1r3's user avatar
  • 833
22 votes

Can I prevent a default route being added when bringing up an interface?

I faced similar problem on Raspbian (I suppose the solution below will be applicable to Debian as well). Raspberry Pi 3 has 2 NICs integrated: Wi-Fi and Ethernet. I use both of them, they are wlan0 ...
Roman Me's user avatar
  • 361
22 votes
Accepted

How can I view IPv6 router advertisements that are being received by my computer for diagnostic purposes?

Using tcpdump which is installed by default on many distributions: tcpdump -n -i eth0 icmp6 will show you all ICMPv6 packets of which - under usual conditions - almost all are neighbor discovery ...
countermode's user avatar
  • 7,553
21 votes

Modifying existing route entry in linux

ifmetric will allow you to change your route metric on the fly, given the interface the routes you want to change are going through. Usage ifmetric <iface> [<metric>] For example, use ...
AeroClassics's user avatar
20 votes

Use ssh with a specific network interface

I don't know when it was introduced but the OpenSSH client on RHEL7 has this in its manpage: -b bind_address Use bind_address on the local machine as the source address of the connection. ...
ugob's user avatar
  • 301
19 votes
Accepted

What is the interface scope (global vs. link) used for?

suppose we have NIC settings with 3 ip's with different scopes 14: ens160: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000 link/ether 36:ee:4c:d0:...
Alex's user avatar
  • 570
18 votes

OpenVPN - Understand the routing table + How to route only the traffic to a specific ip via the VPN

I don't understand the second default gateway, this is the default when the vpn is not active, is it simply bypassed? This is one of OpenVPN's hacks to route traffic through your tunnel while ...
smokes2345's user avatar
16 votes

Linux 64-bit SSH port numbers?

Having a 64b port makes it almost impossible to randomly attack a service, targeting either DoS or a login. Like ssh -p 141592653589793238 my.site.com And how would the client know about ...
Gilles 'SO- stop being evil''s user avatar
15 votes

How to find out which interface am I using for connecting to the internet?

Get the default network interface typically used to route to the "remaining" internet in opposite to DMZ, private network, VM host etc. which are usually routed explicitly. $ ip route get 8....
EugeneP's user avatar
  • 159
15 votes

Bind unix program to specific network interface

Solution I: Preloading a specific library App-Route-Jail: use ld_preload to force the interface gateway (great idea but require root or marks capabilities) usage is detailed on notes bellow ...
intika's user avatar
  • 14.4k
14 votes
Accepted

Changing the metric of an interface permanently

One of the solutions is to configure settings in /etc/network/interfaces adding default route with a predefined metric: auto lo iface lo inet loopback # Primary interface auto wlan0 iface wlan0 inet ...
Gnat's user avatar
  • 366
13 votes

NetworkManager changes default routing policy

If using GUI, try checking the "Use only for resources on this connection" checkbox. If using the config files (like you are :) ), in the [ipv4] section add never-default=true . If using ...
Richlv's user avatar
  • 635
13 votes

What is kernel ip forwarding?

When enabled, "IP forwarding" allows a Linux machine to receive incoming packets and forward them. A Linux machine acting as an ordinary host would not need to have IP forwarding enabled, because it ...
Andrea Araldo's user avatar
13 votes
Accepted

How can I make changes to the network routing metric permanently

The correct way to do this, in Debian and derivatives, is to write a file in /etc/NetworkManager/dispatcher.d (call it whatever you like), with the following content: #!/bin/sh # Change the metric of ...
MariusMatutiae's user avatar
13 votes
Accepted

Is net.ipv6.conf.all.forwarding=1 equivalent to enabling forwarding for all individual interfaces?

Looks like indeed it is designed to work differently compared to IPv4's */forwarding and all/forwarding: From https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt: conf/all/forwarding - ...
Vi.'s user avatar
  • 5,708
13 votes

How to route between interfaces

No need to use iptables. If you have successfully enabled the ip forwarding (i.e. by setting /proc/sys/net/ipv4/ip_forward to 1), device B will do the job because both networks are directly connected ...
Winnie Tigger's user avatar
12 votes

How to find out which interface am I using for connecting to the internet?

Different distros of Linux, Unix, some versions of Microsoft Windows, and many other Operating Systems are not limited to using just one network interface to reach the internet.  Many Operating ...
Just Jeff's user avatar
  • 121
12 votes

Linux Source Routing, Strong End System Model / Strong Host Model?

Just adding firewall rules won't be enough for this one. You want the system to route traffic as if it was two independent systems that just happen to share the same hardware and processes: that's ...
telcoM's user avatar
  • 97.2k
11 votes

How can I view IPv6 router advertisements that are being received by my computer for diagnostic purposes?

While not built in, I find the command-line tool radvdump (part of the radvd package on my distro) very informative as it fully decodes the router advertisements and displays them in detail, including ...
Malvineous's user avatar
  • 6,903
11 votes
Accepted

In Linux, what metric has a route with no metric?

Are you sure about your first observation? What does ip route show or route -n show then? Does the result change if you add proto static in first case? I have found at least two resources that ...
Patrick Mevzek's user avatar
11 votes
Accepted

Is there no routing entry for loopback addresses?

The routing table isn’t the first thing taken into account when the kernel processes a packet; there’s a rule table which comes first, which you can see with ip rule list. ip route list (and the ...
Stephen Kitt's user avatar
10 votes

Can I prevent a default route being added when bringing up an interface?

On RHEL6/Fedora 22 the following has been tested. In /etc/sysconfig/network-scripts/ifcfg-eth1 add the line: DEFROUTE=no Replace eth1 with name of interface where default routing is not wanted. ...
user3489409's user avatar
10 votes

OpenConnect: Setting default routes

I found that the best way to achieve split tunneling is to use vpn-slice. You basically can tell which routes you want and it will be your vpn script that does the routing, instead of what the ...
Farid Nouri Neshat's user avatar
10 votes
Accepted

How does Linux choose between multiple default gateways?

In this case the kernel chooses based on the metric: the lower metric wins. (Route selection is based on route specificity, administrative cost, and metric in that order. Both your default gateways ...
Stephen Kitt's user avatar
9 votes
Accepted

i don't get ipv6. Why cannot I ping ipv6.google.com?

You have only Link-Local, non routable ipv6 (fe80::/10). So You have no public routable IPv6. In this configuration You can make ipv6 connect only to Link-Local addresses in same L2 segment.
mmv-ru's user avatar
  • 615

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