47
votes
How to set the preferred network interface in Linux
Here's the complete answer, in case it helps others:
To make packets with destinations 192.168.10.* use eth0, and all other packets use eth1:
1) View your current routing table
ip route list
One ...
- 641
31
votes
Accepted
Routing selection: specificity vs metric
The routes metric is to set preference among routes with equal specificity. That is true of routing in general (i.e. Cisco, Windows, etc). So the model works like:
Find the most specific route (aka ...
- 82.8k
19
votes
Accepted
Specify route to an interface in Windows cmd
To specify the interface in windows route command, you are supposed to use 'IF'... Uppercase letters, not lowercase.
Also, where you are specifying you want to add a route to a single IP 192.168.0.6, ...
- 1,415
11
votes
Specify route to an interface in Windows cmd
This should work:
route add 192.168.0.6 mask 255.255.255.0 192.168.0.254
If you want persistence:
route -p add 192.168.0.6 mask 255.255.255.0 192.168.0.254
Not sure what the "if" was for, ...
- 9,536
10
votes
Routing selection: specificity vs metric
Linux provides a number of tools for flexible routing selection.
Single routing table
In the simplest case, there is just one kernel routing table and no routes with the SRC attribute. This table ...
- 470
9
votes
Accepted
Why am I getting different results from two servers that located in the same destination network?
You're leaving out a crucial piece of information, which is the subnet mask. You're making an incorrect assumption that these two hosts are in the same network/subnet based solely on the octet values ...
- 109k
8
votes
How can I configure openvpn server without push default gateway?
Due to I have ipv4 and ipv6, if I don't want openvpn to set my default gw, I had to add the following lines at my client configuration, and I had to add manually the ipv6 routes:
pull-filter ignore &...
- 181
8
votes
AWS VPC internet gateway and AWS services
AWS has added VPC endpoints for various services, including S3 (2015), EC2 (2017), SNS (2018), and SQS (2018), which lets you use those services without public Internet access.
New – VPC Endpoint for ...
- 485
8
votes
Why am I getting different results from two servers that located in the same destination network?
The same company host doesn't means that they are on the same network architecture... so route and ping might be different if they are connected to different network elements (proxy, firewall, ...
- 213
8
votes
Accepted
What is the local routing table used for?
First of all as some available on internet info explains "The local table is a special routing table maintained by the kernel".
If you feeling really brave today you can even get some bits of ...
- 9,314
7
votes
How to duplicate TCP traffic to one or multiple remote servers for benchmarking purposes?
Teeproxy could be used to replicate traffic. The usage is really simple:
./teeproxy -l :80 -a localhost:9000 -b localhost:9001
a production server
b testing server
When you put a HAproxy (with ...
- 2,073
7
votes
Allow Docker containers to use IPSEC VPN on host
I wrote a python program to wrap ipsec that installs iptables entries to allow docker containers to talk to the VPN tunnel:
https://github.com/cbrichford/docker-ipsec
Instead of doing:
ipsec up
You ...
6
votes
How can I configure openvpn server without push default gateway?
route-nopull in the .ovpn file, or --route-nopull on the command line.
You'll then have to set up the routes yourself, of course.
- 161
6
votes
Accepted
Making changes to default IPv6 route persistent in CentOS 7
When Red Hat's networking scripts set multiple IPv6 addresses configured in /etc/sysconfig/network-scripts/ifcfg-*, for whatever reason, they are applied in reverse order, so that the last address ...
- 240k
5
votes
Why am I getting different results from two servers that located in the same destination network?
If you are getting different traceroute results, it is because the routing is being handled differently. This could be because the hosts are not on the same network (as Paul's first comment under ...
- 339
5
votes
Why am I getting different results from two servers that located in the same destination network?
Shorter answer:
Thanks for providing the actual IP addresses. This helps us see what you are seeing to an extent. And here is what I am seeing.
37.211.166.178 appears to be unreachable while 37.211....
- 3,532
5
votes
Accepted
Traceroute and BGP peering
Yes, it's possible if there was tunneling involved and the two end points are in different networks. You won't see the hops between the two tunnel endpoints then, just the end points itself. It's not ...
- 1,837
5
votes
Add IP Routes and Rules at Startup
Put your commands in a shell script e.g. /usr/local/sbin/myrouting and make it executable.
You could use cron and an @reboot target in /etc/crontab or the root crontab e.g. /etc/crontab
@reboot root ...
- 115k
5
votes
Accepted
ip rule and route doesn't get respected
Your issue isn't issue. In rule you use not only source address, but also input interface match. So, there are two ways to solve your "problem":
Don't use the dev eth0 in the rule
Add iif eth0 in the ...
- 4,954
4
votes
Static route toward a DNS Address, it is possible?
This is more of a workaround that I use.
You can use this batch script. Just add it in task scheduler to run every time your PC starts.
This will get the IP of your domain name and add route.
:: Get ...
- 41
4
votes
Adding static route through group policy
I had the exact same problem, and my solution was the easiest "if not silliest" thing you can think of.
All I had to do to make the script work using Group Policy was to add entire command inside ...
- 3,859
4
votes
Routing from docker containers using a different physical network interface and default gateway
A friend and I ran into this exact problem where we wanted to have docker support multiple network interfaces servicing requests. We were specifically working with the AWS EC2 service where we were ...
- 141
4
votes
Accepted
How do VPN servers/clients avoid routing their own remote connection packets through themself?
You are correct that with purely destination-based routing this is a problem, if the destinations you are reaching through the tunnel overlap with routing needed for tunnel establishment, etc....
The ...
- 559
4
votes
Is there a way to ssh using hostname alias without modifying the etc/hosts file?
Honestly, it's effortless.
In ~/.ssh/config:
Host node* server*
Hostname %h.domain.org
Now every “node” and “server” is mapped to the domain.
$ ssh node04 --> $ ssh node04.domain.org
$ ssh ...
- 193
4
votes
Accepted
How to change loopback network mask or redirect subnet to another interface
As mentioned in What is the rest of the 127.0.0.0/8 address space used for? , the 127.0.0.0/8 block is the loopback block, and all packets destined to the block must be looped back to the origin host.
...
- 35.8k
4
votes
Accepted
Centos configure outbound IP address
You can change the source IP address used by default for outgoing connections using a command like the following:
ip route replace default via 87.233.82.97 dev eth0 src 87.233.82.98
Similarly, you ...
- 36.1k
4
votes
Accepted
Ubuntu, two NICs but only one with internet connection
As pointed out in the above comments you have two default routes (via 192.168.1.1 and 10.0.0.1) but only the first one connects to the Internet. If the routing table remains as you posted you will ...
- 5,477
3
votes
How to tunnel all Internet traffic via SoftEther?
First of all, I have to say that I don't know SoftEther at all. But I will post you some general hints to think about.
1.) You should not add manual routes with a default gateway of "0.0.0.0". This ...
- 241
3
votes
IPv6 default gateway route disappear after reboot
Possibly these sysctl settings might help you?
net.ipv6.conf.all.autoconf=0
net.ipv6.conf.all.accept_ra=0
- 304
3
votes
How can I configure openvpn server without push default gateway?
I found that removing
resolv-retry infinite
from my client.conf stops pushing default route from server.
- 39
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
route × 613networking × 154
linux × 150
iptables × 102
vpn × 80
routing × 73
openvpn × 71
ip × 71
linux-networking × 43
ubuntu × 39
gateway × 36
windows × 34
debian × 28
nat × 28
static-routes × 25
centos × 23
iproute2 × 20
subnet × 19
interface × 18
ifconfig × 18
router × 16
bridge × 15
ping × 14
ip-routing × 13
tunneling × 12