Tag Info

Hot answers tagged

14

You can use route to find your default route: $ route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.1.0 * 255.255.255.0 U 1 0 0 eth0 link-local * 255.255.0.0 U 1000 0 0 eth0 default 192.168.1.1 0.0.0.0 ...


13

echo 200 isp2 >> /etc/iproute2/rt_tables ip rule add from <interface_IP> dev ppp0 table isp2 ip route add default via <gateway_IP> dev ppp0 table isp2 The above doesn't require any packet marking with ipfilter. It works because the outgoing (reply) packets will have the IP address that was originally used to connect to the 2nd interface ...


10

"IP forwarding" is a synonym for "routing." It is called "kernel IP forwarding" because it is a feature of the Linux kernel. A router has multiple network interfaces. If traffic comes in on one interface that matches a subnet of another network interface, a router then forwards that traffic to the other network interface. So, let's say you have two NICs, ...


10

It's not the ssh client that decides through which interface TCP packets should go, it's the kernel. In short, SSH asks the kernel to open a connection to a certain IP address, and the kernel decides which interface is to be used by consulting the routing tables. (The following assumes you're on GNU/Linux; the general concept is the same for all Unices, ...


10

You're close. The actual reason that the application isn't seeing the return traffic is because of the kernel's built in IP spoofing protection. I.e., the return traffic doesn't match the routing table and is therefore dropped. You can fix this by turning off spoofing protection like this: sudo sysctl net.ipv4.conf.wlan0.rp_filter=0 But I wouldn't ...


10

Here is a similar setup from one of our routers (with some irrelevant stuff snipped). Note that this handles incoming connections as well. Note the use of variables instead of hard-coded mark numbers. So much easier to maintain! They're stored in a separate script, and sourced in. Table names are configured in /etc/iproute2/rt_tables. Interface names are ...


8

There are several possibilities, depending on how you want to decide what packets go where. Most of them will require some understanding of how TCP/IP networking works in Linux. The main tools you'll have to know to do complex things are iptables (Ubuntu: iptables ) and iproute2 (ip command) (Ubuntu: iproute , iproute-doc ). If you can discriminate fully by ...


8

After extensive study of the openvpn manual, I have found an answer for my question: I you don't want the routes to be executed automatically, but to be handled by your own tool, use the following option: --route-noexec Don't add or remove routes automatically. Instead pass routes to --route-up script using environmental variables. If you ...


8

No packets are received for several seconds and then ~6 are sent back in quick succession. This is symptomatic of two similar phenomena: network congestion or network discards (usually due to congestion). In the first case, a router between here and there has a burst of traffic unrelated to your activities which cause your traffic to be buffered in ...


7

If you use ip instead of route, you could simply run: ip route del 0/0 I believe that catches all default routes.


7

You need to set the promote_secondaries option on the interface, or on all interfaces: echo 1 > /proc/sys/net/ipv4/conf/eth0/promote_secondaries or sysctl net.ipv4.conf.eth0.promote_secondaries=1 Change eth0 to all to have it work on all interfaces. This option has been in since 2.6.12. I tested this with a dummy interface and it worked there.


7

0.0.0.0 has the specific meaning "unspecified". This roughly translates to "there is none" in the context of a gateway. Of course, this means that the network is locally connected, as there is no next hop. As a destination, 0.0.0.0/0 is special: if there are no network bits, there can't be anything in the network number either. So, it's naturally ...


6

You could set up two virtual machines on the physical machine, and set up the network interface bridging so that one VM uses eth0 and the other VM uses eth1. See the virtual box documentation section on bridged networking.


6

It's pretty easy. You need to connect PC to notebook. Configure eth0 on PC (set for example ip = 192.168.2.3 and default gateway 192.168.2.2 and dns server to 8.8.8.8). That's all you need to do on PC. On notebook you need to set up the internet connection as usual and configure eth0 with the following way: set ip address to 192.168.2.2, enable net ...


6

From the wikipedia page, 0.0.0.0 excerpt In the Internet Protocol version 4 the address 0.0.0.0 is a non-routable meta-address used to designate an invalid, unknown or non applicable target. To give a special meaning to an otherwise invalid piece of data is an application of in-band signaling. From the wikipedia page, Default Route. excerpt ...


5

The following commands create an alternate routing table via eth1 for packets that have the mark 1 (except packets to localhost). The ip command is from the iproute2 suite (Ubuntu: iproute , iproute-doc ). ip rule add fwmark 1 table 1 ip route add 127.0.0.0/0 table 1 dev lo ip route add 0.0.0.0/0 table 1 dev eth1 The other half of the job is recognizing ...


5

You'll want to use the iptables owner module and perhaps some clever packet mangling. owner This module attempts to match various characteristics of the packet creator, for locally-generated packets. It is only valid in the OUTPUT chain, and even then some packets (such as ICMP ping responses) may have no owner, and hence never match. ...


5

The Linux Advanced Routing & Traffic Control HOWTO has a section describing to solve the problem. The key step to balance traffic between the two routes is to give them both a weight. ip route add default scope global \ nexthop via 192.168.0.1 dev eth1 weight 1 \ nexthop via 192.168.1.1 dev eth0 weight 1


5

For a simple router, there are really only two steps that need to be done. Enable routing The first step is to enable routing in the kernel. By default, the kernel drops packets that it doesn't recognize; once you enable routing, it'll forward them. You need to issue either of these two commands when the computer boots: sysctl -w net.ipv4.ip_forward=1 ...


5

It maps to RTF_EXPIRES. It means the route has a non-infinite lifetime. In this case, the kernel probably learned the route dynamically from a RA (Router Advertisement). I recommend you use ip instead of route (and instead of ifconfig). Although it's Linux-specific and unportable, its syntax is much less archaic than the legacy commands. ip -6 route would ...


5

Well - this IS a routing-question. The answer is simple: The first entry that will give the best routing-entry is "the winner". So look at netstat -rn to see which interface is first. Update: The network-inferface-routing-settings normally get set up during system startup. So the startup order of network devices will be the order in that table. With ...


5

Note: I only have considered the first script, ignoring the old one. You don't need to modprobe netfilter modules by hand with current iptables. This is only necessary for custom connection trackers. Don't mix up route and ip route. This is pure evil. Just use ip everywhere and forget about ifconfig and route /etc/iproute2/rt_tables is not reset across ...


5

To build up on @jsbillings's solution, repeat the command until it fails: while ip route del default; do :; done


5

My question is: Why is it possible for a computer on the 172.16.2.0/24 subnet to ping 172.16.1.1 (ip address of eth1 interface)? Because you allowed it, and Linux does it by default. Linux uses what is called a weak host model. That mean when it receives a packet coming from eth2, it will consider the packet to be for him if the destination address is ...


5

Add the following line to /etc/dhcp/dhclient.conf on your server: prepend domain-name-servers 127.0.0.1; This makes it prepend 127.0.0.1 to whatever content of /etc/resolv.conf was forced on it by the gateway DHCP. Why option domain-name-servers x.x.x.x doesn't work From the dhclient.conf(5) man page: The option statement is used to specify the ...


5

First, you need tun2socks (often a part of the 'badvpn' package). tun2socks sets up a virtual interface which you can route traffic through, and that traffic will get sent through the target socks proxy. Setting it up gets a little tricky as you only want to route certain traffic through the tunnel. This script should do what you want: #!/bin/bash ...


4

bahamat's solution is correct; however, please note that the only way for me to make this work was to disable the rp_filter for every interface in the system, not only the two (eth1 and wlan0 in this case) involved in the NATing. for f in /proc/sys/net/ipv4/conf/*/rp_filter; do echo 0 > $f; done echo 1 > /proc/sys/net/ipv4/route/flush (see the ...


4

The kernel is what adds the routing rules after adding an IP to the box, not the ip command. So you cannot prevent it from adding to the 'main' table. The only way to do this is to manually remove the route from 'main' and add it to your custom table.


4

I've done something similar with real interfaces, but I can't see why it wouldn't work with VPN interfaces. The idea is that, as you have the same subnet available at different interfaces on that router, it complicates the routing. Basically, when a packet for 10.10.13.123 enters the router, it is DNATed before routing to 192.168.0.123, so you have to be ...


4

BatchyX already give some very good explanation about iptables and routing, so I will exercise my laziness and go directly to script. It should NAT all traffic to port 80,443,22,4070 through 192.168.0.91. All the rest will NAT through 192.168.1.254. I re-do my testing and end up following this guide. What is missing in that guide is the last 3 lines in my ...



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