Debian系统

查看路由表:

root@debian:~# ip route
default via 192.168.6.1 dev enp4s0
10.0.0.0/24 dev br0 proto kernel scope link src 10.0.0.1 linkdown
192.168.6.0/24 dev enp4s0 proto kernel scope link src 192.168.6.20

  

Debian / Ubuntu Linux static routing for two interfaces:

Here is a config file named /etc/network/interfaces:

auto lo
iface lo inet loopback auto eth0
iface eth0 inet static
address 10.9.38.76
netmask 255.255.255.240
network 10.9.38.64
broadcast 10.9.38.79
### static routing for eth0 that connects to the VLAN ###
post-up route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.9.38.65
pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 10.9.38.65 auto eth1
iface eth1 inet static
address 204.186.149.140
netmask 255.255.255.240
network 204.186.149.128
broadcast 204.186.149.143
## default gateway for eth1 and the server ##
gateway 204.186.149.129
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 10.0.80.11 10.0.80.12
dns-search nixcraft.in

  

ip command to set a default router to 192.168.1.254

# ip route add default via 192.168.1.254

  

route command to set a default router to 192.168.1.254

 route add default gw 192.168.1.254

  

Save routing information to a configuration file /etc/network/interfaces

Open /etc/network/interfaces file

# vi /etc/network/interfaces

Find eth0 or desired network interface and add following option

gateway 192.168.1.254 

Save and close the file. Restart networking:

# /etc/init.d/networking restart

 

A note about ip command and persistence static routing on a Debian/Ubuntu

Edit your /etc/network/interfaces file for say eth0:

# vi /etc/network/interfaces

Update it as follows:

auto eth0
iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.254
## static ip config START ##
up /sbin/ip route add 172.10.1.0/24 via 10.8.0.1 dev eth0
down /sbin/ip route delete 172.10.1.0/24 via 10.8.0.1 dev eth0
## static ip config END ##

  

 

Restart networking service when using a Debian or Ubuntu Linux

# systemctl restart networking

  

 

route 相关设置的更多相关文章

  1. Xcode 生成静态库相关设置:

    Xcode 生成静态库相关设置: #Build Setting1. Architectures ------- Architectures -----> $(ARCHS_STANDARD) -- ...

  2. Eclipse相关设置与优化

    原文:http://chaoxz2005.blog.163.com/blog/static/15036542013411105519685/ 一般在不对eclipse进行相关设置的时候,使用eclip ...

  3. zend studio 9.0.4 破解、汉化和字体颜色及快捷键相关设置

    转载:http://www.penglig.com/post-45.html 下载:http://www.geekso.com/component/zendstudio-downloads/ 破解:h ...

  4. 使用VIRTUALBOX安装ANDROID系统 | 图文教程 | 相关设置

    使用VIRTUALBOX安装ANDROID系统 | 图文教程 | 相关设置 http://icaoye.com/virtualbox-run-android/

  5. 关于myeclipse中maven项目转换相关设置

    关于myeclipse中maven项目转换相关设置 在myeclipse菜单中,Configure->Convert to Maven Project 这个菜单 如果没有的话,需要做如下设置: ...

  6. [Other] 自定义MIME类型支持FLV的相关设置

    刚测试知道为何服务器无法播放flv的原因,特此记录而已. 网络空间支持FLV的相关设置,就是自定义一个MIME类型,一般虚拟主机管理里面都有这个选项 自定义MIME类型 扩展名: .flv MIME类 ...

  7. NPOI 教程 - 3.2 打印相关设置

    转:http://www.cnblogs.com/wolfplan/archive/2013/01/13/2858991.html NPOI 教程 - 3.2 打印相关设置   打印设置主要包括方向设 ...

  8. 手机3D游戏开发:自定义Joystick的相关设置和脚本源码

    Joystick在手游开发中非常常见,也就是在手机屏幕上的虚拟操纵杆,但是Unity3D自带的Joystick贴图比较原始,所以经常有使用自定义贴图的需求. 下面就来演示一下如何实现自定义JoySti ...

  9. scale相关设置—手动设置

    在ggplot2 中,可以进行手动设置的函数有: scale_colour_manual(..., values).scale_fill_manual(..., values). scale_size ...

随机推荐

  1. 关于String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

    关于 String path = request.getContextPath(); String basePath = request.getScheme()+"://"+req ...

  2. redis启动错误: Warning: no config file specified, using the default config. In order to specify a config

    redis启动错误: Warning: no config file specified, using the default config. In order to specify a config ...

  3. [译]Vulkan教程(17)帧缓存

    [译]Vulkan教程(17)帧缓存 Framebuffers 帧缓存 We've talked a lot about framebuffers in the past few chapters a ...

  4. Jrebel实现tomcat热部署,遇到的问题以及解决办法,详解

    我的安装的详细过程: 下载Jrebel:  https://github.com/ilanyu/ReverseProxy/releases/tag/v1.4 我的是winx64,所以选择如下的: 下载 ...

  5. NIO零拷贝的深入分析

    深入分析通过Socket进行数据文件传递中的传统IO的弊端以及NIO的零拷贝实现原理,及用户空间和内核空间的切换方式 传统的IO流程 在这个过程中: 数据从磁盘拷贝进内核空间缓冲区 从内核空间缓冲区拷 ...

  6. VS2010到VS2019各个版本的密钥

    VS2019专业版和企业版的密钥 Visual Studio 2019 EnterpriseBF8Y8-GN2QH-T84XB-QVY3B-RC4DF Visual Studio 2019 Profe ...

  7. WPF customize DelegateCommand

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; usin ...

  8. 并发编程-多线程,GIL锁

    本章内容: 1.什么是GIL 2.GIL带来的问题 3.为什么需要GIL 4.关于GIL的性能讨论 5.自定义的线程互斥锁与GIL的区别 6.线程池与进程池 7.同步异步,阻塞非阻塞 一.什么是GIL ...

  9. ABAP 字符串换行符处理

    今天发现BW系统从K3系统数据库抽取会计科目的描述时,转换出错. 从监控器上看是值2KO 845 412D#有问题,但不知道有什么问题,检查后感觉是符号#的问题. 在转换中添加代码,替换#,发现没有起 ...

  10. ENDIAN的由来及BIG-EDIAN 和LITTLE-ENDIAN(转)

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/kingmax54212008/arti ...