Hot answers tagged

23

There is ip route get 74.125.137.100 but it doesn't do hostname resolution (which I think is a good thing). The command is usually available from iproute or iproute2 packages.


22

The routing table is used in order of most specific to least specific. However on linux it's a bit more complicated than you might expect. Firstly there is more than one routing table, and when which routing table is used is dependent on a number of rules. To get the full picture: $ ip rule show 0: from all lookup local 32766: from all lookup main ...


21

You can add the calls to the post-up hook when the interface comes up. The interface configuration sits in /etc/network/interfaces. Here an example: auto eth1 iface eth1 inet dhcp post-up route del -net 10.1.2.0 netmask 255.255.255.0 post-up route add -host 10.1.2.51 eth1 post-up route add -host 10.1.2.52 eth1 pre-down route add -net 10.1.2.0 ...


20

You need to add the route to the gateway first: ip -6 route add 2004::3 dev eth0


18

The route or the ip utility get their information from a pseudo filesystem called procfs. It is normally mounted under /proc. There is a file called /proc/net/route, where you can see the kernel's IP routing table. You can print the routing table with cat instead, but the route utility formats the output human readable, because the IP adresses are stored in ...


18

You haven't included which system you're on or which tool-set you're using, but the two most common commands for managing the routing tables are the route and ip commands. Here is how you might remove the route by using the route command (from the net-tools package): route del -net 122.252.228.38 netmask 255.255.255.255 And here is how you might delete ...


17

According to the routing table you have included in your question, you do not have a default route pointing to ppp0, so that's why you can't delete it. ("No such process" here means "No such route"). Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.144.15.100 128.0.0.0 UG 1 ...


14

You mentioned /etc/network/interfaces, so it's a Debian system... Create a named routing table. As an example, I have used the name, "mgmt," below. echo '200 mgmt' >> /etc/iproute2/rt_tables Above, the kernel supports many routing tables and refers to these by unique integers numbered 0-255. A name, mgmt, is also defined for the table. Below, a ...


11

Your table is basically saying: If you want to reach another host with an IP address starting with 192.168.0 -> send it to interface eth1 starting with 169.254 -> send it to interface eth1 starting with 127 -> send it to interface lo else send it to your router (192.168.0.1) The route command is a legacy command you should use the iproute tool instead. ...


11

You need install package net-tools.


10

So in your configuration, all the packets you try to send to the network initially originating from 10.0.0.1 (because they are going through tun0 interface and its local address is 10.0.0.1). You capture the packets, everything is fine so far. Now, tun0 sends the packets further. Source address is 10.0.0.1 and you want the packets to leave through a ...


9

route is the old traditional tool and available on numerous Unix systems. ip belongs to the iproute2 suite which is a Linux only tool and uses the Netlink API, which is a socket like interface for accessing kernel information about interfaces, address assignments and routes. It replaces most of the functionality of ifconfig, route, netstat and a few others. ...


9

The "command not found" error means you don't have the command installed. Using Debian's "search the contents of packages" page brings up: ... /sbin/route net-tools [not powerpc] .... So (providing your CPU isn't PowerPC) you should install the net-tools package.


8

What you found on Google is correct. You need to create a route-(ifname) file. The content needs to be like the "ip" command but only the last part. Like this: 192.168.1.0/24 via 192.168.2.1 More information can be found in the RHEL 7 Networking Guide.


8

You cannot use DHCPv4 to give out default IPv6 routes. You cannot even use DHCPv6 to give out default IPv6 routes. The reason is that IPv6 is different from IPv4 in many respects, and one of them is how routers behave: Every IPv6 router announces itself as gateway to the segment which can use it as gateway. And you can have multiple routers for segment, it'...


7

The solution is to set the Netfilter packet mark which can be used by advanced routing. There is no way to match by process id, but Netfilter allows to match on process UID or GID. In this case it seems to be the easiest solution to create a new system user especially for this task. iptables -t mangle -A OUTPUT -m owner --uid-owner wlanping -j MARK --set-...


7

To add a default gateway, and not one specific to an Ethernet interface (dev), use: route add default gw <GW IP Address> # For IPv4 route add -A inet6 default gw <GW IP Address> # For IPv6; you must specify the Address Family (AF) Notice, you don't have to specify the subnet mask, nor the outgoing Ethernet interface. To verify your work, list ...


7

There is an easy way to list all routes matchig prefix on linux : ip -6 route list match 2607:f8b0:4005:804::200e table all This will list all possible routes to specified target (including default, if no more specific is found) in all tables. Obviously, this works for IPv4 too. PS: I know that my answer is a bit too late, and most likely you have figured ...


7

For showing your default route source address: ip route get 8.8.8.8 | awk ' /^[0-9]/ { print $7 }' The { print $7 } is selecting the 7th field of the ip... output; The ^[0-9] is selecting lines starting with a number as ip generates two lines, to chose the correct line. Note: I prefer this first solution, however showing other alternatives for the sake ...


7

You could choose an arbitrary address which you believe will always be accessed via the default route, for example google DNS, and then print the source address for that route: ip route get 8.8.8.8 | awk '{ for (nn=1;nn<=NF;nn++) if ($nn~"src") print $(nn+1) }'


6

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 ...


6

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 ...


6

SOCKS5 is a protocol (i.e. in the application layer of OSI), so plain network-routing (e.g. via iptables) alone won't do. (It's probably necessary, but not sufficient.) What you need is a proxifier. Without having tried it, tun2socks, allowing you to "socksify TCP at the network layer", looks promising (as does proxychains, without iptables but prefixing ...


6

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 deprecated route) list the main table, but there’s a local table which has higher priority and lists all the routes involving the loopback interface; run ip route ...


5

Yes, you could mark all packets matches such policy, and control the route like this, # Set mark for out going packets iptables -t mangle -A OUTPUT -d mydynamicdns.afraid.org -j MARK --set-mark 1 # Route all packets with mark 1 through wlan0 ip rule add fwmark 1 table 1 ip route add XXX table 1 dev wlan0 P.S The rule would not work if DNS resolution fails


5

If you can reach something by IP but not by name, then something's wrong with DNS lookup: your machine cannot find the IP address by name. Other than that, your networking and routing setup seems fine. Things that could cause this: DNS server down Misconfigured of /etc/resolv.conf Misconfigured of /etc/nsswitch.conf ... And probably others, but the first ...


5

If you have this problem with every program you run, you should check your server firewall rule. Make sure that it only use NAT for external destination. Your route table make no sense if you have a wide NAT rule. After fixing firewall rule, for wget, you can use --bind-address option to chose what interface you want to use: wget --bind-address=192.168.1....


5

Add the route entry to your /etc/rc.local file (before exit 0): /sbin/route add -net xxx.xxx.xxx.xxx netmask 255.255.240.0 gw xxx.xxx.xx.xxx or add it to your crontab: @reboot /sbin/route add -net xxx.xxx.xxx.xxx netmask 255.255.240.0 gw xxx.xxx.xx.xxx Use the absolute path to route executable, on my system /sbin/route, change if needed. As a side note, ...


5

AFAICT Unfortunately providing several dhcp-options to dnsmasq results in the last being applied (not all). So, you need to supply only two IP addresses (network and gateway): dhcp-option=121,10.0.4.0/24,10.8.0.1 And, you also need to tell each server[123] to ask for the route. And, if your ISC DHCP client doesn’t have support for this option (one in ...


5

This is a bug in systemd, still present on version 240. Per the thread above, a workaround (or solution, I am not sure about the status since the bug is still open) is to add GatewayOnlink=yes in the [Route] section: [Match] Name=eth0 [Network] DHCP=yes [Route] Gateway=192.168.0.10 Destination=10.0.0.0/8 GatewayOnlink=yes This parameter is available ...


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