码迷,mamicode.com
首页 > 其他好文 > 详细

route 相关设置

时间:2019-11-14 09:48:57      阅读:98      评论:0      收藏:0      [点我收藏+]

标签:OWIN   vlan   root   outer   persist   you   scope   down   note   

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 相关设置

标签:OWIN   vlan   root   outer   persist   you   scope   down   note   

原文地址:https://www.cnblogs.com/saryli/p/11854686.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!