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

1 Answer

 
20
 

Try:

ip route add 192.168.72.20/32 dev eth3

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

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

  1. How to block a specific IP Address using UFW

    How to block a specific IP Address using UFW The key to blocking a specific IP address with UFW is t ...

  2. Docker无法启动 Could not find a free IP address range for interface 'docker0' 最方便的解决办法

    阿里云的CentOS 6.5上安装Docker会无法启动,如果直接运行docker -d会看到错误提示:Could not find a free IP address range for inter ...

  3. do from a specific ip

    ping -S 192.168.240.1 sohu.com telnet -b 192.168.240.1 sohu.com 80

  4. VIP - virtual IP address

    virtual IP address (虚拟 IP 地址)1.是集群的ip地址,一个vip对应多个机器2.与群集关联的唯一 IP 地址 see wiki: A virtual IP address ( ...

  5. TCP/IP Protocol Architecture

    原文: https://technet.microsoft.com/en-sg/library/cc958821.aspx 1. 主机到网络层 2.网络互连层(互连这个翻译好) ----------- ...

  6. Ubuntu中设置静态IP和DNS

    在Ubuntu中设置静态IP共两步:1>设置IP:2>设置DNS1>设置IP    编辑 /etc/network/interface文件:       sudo vi /etc/n ...

  7. Java获取ip地址的几种方法

    以下内容介绍下java获取ip地址的几种思路. 1.直接利用java.net.InetAddress类获取,不过这种方法只在windows环境下有效,在linux环境下只能获取localhost地址( ...

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

    原文地址:http://blog.sina.com.cn/s/blog_669421480102v3bb.html VMware 中使用网络,对虚拟机设置静态IP:在Ubuntu中设置静态IP共两步: ...

  9. 树莓派(Debian)系统设置了静态IP之后还会获取动态IP的问题解决(scope global secondary eth0)

    解决方法: 1.配置好静态IP在/etc/network/interface 2.关闭dhcp服务(不知道这个服务是干嘛的,明明是客户端还需要这个) sudo systemctl stop dhcpc ...

随机推荐

  1. vscode添加vue文件模板

    文件->首选项->用户代码片段->输入vue,打开vue.json 添加模板json "Print to console": { "prefix&quo ...

  2. PHP设计模式 - 享元模式

    运用共享技术有效的支持大量细粒度的对象 享元模式变化的是对象的存储开销 享元模式中主要角色: 抽象享元(Flyweight)角色:此角色是所有的具体享元类的超类,为这些类规定出需要实现的公共接口.那些 ...

  3. 【剑指offer】面试题 24. 反转链表

    面试题 24. 反转链表

  4. spring框架学习(二)——注解方式IOC/DI

    什么是注解 传统的Spring做法是使用.xml文件来对bean进行注入或者是配置aop.事物,这么做有两个缺点: 1.如果所有的内容都配置在.xml文件中,那么.xml文件将会十分庞大:如果按需求分 ...

  5. noip2019集训测试赛(二十一)Problem A: Colorful Balls

    Problem A: Colorful Balls Description Snuke放了N个一排彩色的球.从左起第i个球的颜色是ci重量是wi她可以通过执行两种操作对这些球重新排序操作1:选择两个相 ...

  6. [基础]C++:名字的作用域

    每个名字都有自己的活动空间,同一个名字在不同的作用域可能指向不同的实体. 作用域:通常是以{}为分隔. 名字的有效区域开始于名字的声明,以声明语句所在的末端为结束. #include<iostr ...

  7. Sublime Text3安装LESS

    Sublime Text3安装LESS 1.Sublime Text3利用Package Control安装LESS插件.LESS2CSS插件 2.去node官网下载node.js http://no ...

  8. shell中通过eval执行一个字符串命令

    #!/bin/bash echo "Switch Directory : /home/pktgen-2.9.0" dir="/home/pktgen-2.9.0" ...

  9. git clone一个仓库下的单个文件【记录】

    注意:本方法会下载整个项目,但是,最后出现在本地项目文件下里只有需要的那个文件夹存在.类似先下载,再过滤. 有时候因为需要我们只想gitclone 下仓库的单个或多个文件夹,而不是全部的仓库内容,这样 ...

  10. HDU6037 Expectation Division 期望、高维前缀和

    传送门 设\(f_x\)表示答案,那么\(f_x = \frac{\sum\limits_{d \mid x} f_d}{\sigma_0(x)} + 1 = \frac{\sigma_0(x) + ...