Route all trafic for specific ip over specific network interface

15

I have a linux server that needs to get some routing. I‘m fairly new at this and i don‘t find any clear source on google.

The setup should be simple:
All traffic to a server on ip 192.168.72.20 should be sent over interface 3.
All other interfaces don‘t matter at the moment.

Here you have the output for route -n

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.72.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.72.0    0.0.0.0         255.255.255.0   U     0      0        0 eth1
192.168.72.0    0.0.0.0         255.255.255.0   U     0      0        0 eth2
192.168.72.0    0.0.0.0         255.255.255.0   U     0      0        0 eth3
192.168.72.0    0.0.0.0         255.255.255.0   U     0      0        0 eth4
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
0.0.0.0         192.168.72.12   0.0.0.0         UG    0      0        0 eth0

linux networking routing

shareimprove this question

asked Mar 29 ‘13 at 13:29

Frederiek

17811 gold badge11 silver badge55 bronze badges

  • 1

    Are you using the old fashioned ifconfig and route command or the modern ip commands? (old ones would be something like route add -host 192.168.72.20 GW eth3_ip) – Hennes Mar 29 ‘13 at 13:48

add a comment

1 Answer

active oldest votes

20

Try:

ip route add 192.168.72.20/32 dev eth3

shareimprove this answer

answered Mar 29 ‘13 at 13:48

LawrenceC

62.2k1212 gold badges109109 silver badges189189 bronze badges

  • 3

    Just a note: to permanently keep this configuration make sure you add it to /etc/rc.local or your distro‘s equivalent. It won‘t persist between reboots. – LawrenceC Mar 29 ‘13 at 16:32

  • 1

    I tried this same format for mapping an IP to the wlan0 on Ubuntu 14.04 and got RTNETLINK answers: Invalid argument I had to remove the /** from the IP so I ended up with: sudo ip route add 192.168.50.15 dev wlan0 -- thought I‘d mention that in case anyone else ran into this issue. Thank you for your answer ultrasawblade, it was helpful. – mason81 Jul 10 ‘15 at 14:54

原文地址:https://www.cnblogs.com/oxspirt/p/11829714.html

时间: 2024-10-10 19:35:50

Route all trafic for specific ip over specific network interface的相关文章

Simulation of grooming in IP over optical network with fixed/flex-grid

该项目是在已有的固定栅格和灵活栅格节点混合组网的基本项目框架(eclipse项目)下修改的.使用的IDE是idea2018. 1.将eclipse项目导入idea中.https://www.jianshu.com/p/c96d63b8aa97 2.运行simulation函数中的main函数,报错如下: java.io.FileNotFoundException: nsf.txt (系统找不到指定的文件.)java.io.FileNotFoundException: nsf_k_paths.tx

Linux IP Alias

1. Abount IP Alias IP alias / IP aliasing is assigning multiple IP addresses to a single physical network interface. Alias network interface is configured on top of existing physical network interface. By IP aliasing we can make applications and serv

Ubuntu中设置静态IP和DNS(转载)

原文地址:http://blog.sina.com.cn/s/blog_669421480102v3bb.html VMware 中使用网络,对虚拟机设置静态IP: 在Ubuntu中设置静态IP共两步:1>设置IP:2>设置DNS 1>设置IP    编辑 /etc/network/interface文件:       sudo vi /etc/network/interface auto eth0    iface eth0 inet static              //  指

Java获取ip地址的几种方法

以下内容介绍下java获取ip地址的几种思路. 1.直接利用java.net.InetAddress类获取,不过这种方法只在windows环境下有效,在linux环境下只能获取localhost地址(即/etc/hosts文件内容) 代码如下: 1 import java.net.InetAddress; 2 3 /** 4 * This method works well in windows system. 5 * In Linux system it returns 127.0.0.1 t

AWS Intro - Static IP with ssh

Notes:  Please config static ip when launch instance. Because change dynamic public ip to static ip, it will cause ssh connect refused. The way for config static ip when launch instance is as the followings: new alloc static ip new alloc network inte

Vagrant搭建Ubuntu-JavaEE开发环境——Tomcat+JDK+MySql+dubbo+测试

Vagrant搭建(Tomcat8+JDK7+MySQL5+dubbo) JDK 1.下载jdk 2.解压JDK tar -xzvf jdk-7u79-linux-x64.tar.gz 3.设置环境变量 vim /home/vagrant/.bashrc 这里因为我用的vagrant所以提示: The program 'vim' can be found in the following packages: * vim * vim-gnome * vim-tiny * vim-athena *

Virtual Machine Definition File 2.2

http://archives.opennebula.org/documentation:archives:rel2.2:template#disks_device_mapping A template file consists of a set of attributes that defines a Virtual Machine. The syntax of the template file is as follows: Anything behind the pound or has

window 使用vagrant搭建开发开发环境

1.下载安装vagrant 2.下载安装 virtualbox 3.下载.box 4.初始化 vagrant box add {box-name} {box-url} 使用语句 vagrtant box list 查看创建的  name 5. 启动 vagrant up 6.修改Vagrantfile文件 如下 # -*- mode: ruby -*- # vi: set ft=ruby : # All Vagrant configuration is done below. The "2&qu

vagrant配置(假设已经安装好了vagrant并且下载好了box)

每个项目下面都可以配置一个. 在自己项目下面执行vagrant init,则会生成一个Vagrantfile文件,如果vagrant init -m 则会生成一个超简单的文件,-f会覆盖当前已有的 Options: --box-version VERSION Version of the box to add -f, --force Overwrite existing Vagrantfile -m, --minimal Create minimal Vagrantfile (no help c