我有Ubuntu 13.10(内核3.11.0-19-通用).启动时,网络配置如下:

dor@ubuntu:~$sudo ifconfig -a

em1 Link encap:Ethernet HWaddr 44:37:e6:4c:ca:0a

inet addr:10.1.0.102 Bcast:10.1.7.255 Mask:255.255.248.0

inet6 addr: fe80::4637:e6ff:fe4c:ca0a/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:732 errors:0 dropped:0 overruns:0 frame:0

TX packets:79 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:68789 (68.7 KB) TX bytes:12907 (12.9 KB)

Interrupt:20 Memory:fe600000-fe620000

eth5 Link encap:Ethernet HWaddr 00:0a:5e:50:cf:1e

BROADCAST MULTICAST MTU:1500 Metric:1

RX packets:0 errors:0 dropped:0 overruns:0 frame:0

TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

Interrupt:20 Base address:0xa000

lo Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

inet6 addr: ::1/128 Scope:Host

UP LOOPBACK RUNNING MTU:65536 Metric:1

RX packets:101 errors:0 dropped:0 overruns:0 frame:0

TX packets:101 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:8485 (8.4 KB) TX bytes:8485 (8.4 KB)

p4p1 Link encap:Ethernet HWaddr 00:15:17:0b:6d:1c

inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0

inet6 addr: fe80::215:17ff:fe0b:6d1c/64 Scope:Link

inet6 addr: fc00::215:17ff:fe0b:6d1c/64 Scope:Global

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:41 errors:0 dropped:0 overruns:0 frame:0

TX packets:100 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:4062 (4.0 KB) TX bytes:15981 (15.9 KB)

Interrupt:16 Memory:fe540000-fe560000

dor@ubuntu:~$sudo route -n

[sudo] password for dor:

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 p4p1

10.1.0.0 0.0.0.0 255.255.248.0 U 0 0 0 em1

192.168.1.0 0.0.0.0 255.255.255.0 U 1 0 0 p4p1

互联网的门户是10.1.0.1.所以我手动执行以下内容:

dor@ubuntu:~$sudo route del default

dor@ubuntu:~$sudo route add default gw 10.1.0.1

这就是我设法上网的方式.

但是,不是每次手动执行此操作,我如何使其永久化?

/ etc / network / interfaces的内容(删除了一些注释行):

dor@ubuntu:~$cat /etc/network/interfaces

# The loopback network interface

auto lo

iface lo inet loopback

# The primary network interface

auto em1

iface eth5 inet static

address 10.90.90.91

netmask 255.255.255.0

gateway 10.90.90.90

iface em1 inet static

address 10.1.0.102

netmask 255.255.248.0

gateway 10.1.0.1

我已经阅读了很多次接口和路由手册以及许多谷歌搜索结果,但无法弄清楚这一点.谢谢.

编辑#1,17 Apr 2014 12:11 UTC:

(回应响应者Sobrique)

我编辑文件/ etc / network / interfaces以获得以下内容:

# This file describes the network interfaces available on your system

# and how to activate them. For more information,see interfaces(5).

# The loopback network interface

auto lo

iface lo inet loopback

# The primary network interface

auto em1

#iface em1 inet dhcp

iface eth5 inet static

address 10.90.90.91

netmask 255.255.255.0

# gateway 10.90.90.90

iface p4p1 inet static

address 192.168.1.32

netmask 255.255.255.0

# gateway 192.168.1.22

iface em1 inet static

address 10.1.0.102

netmask 255.255.248.0

gateway 10.1.0.1

现在启动时可立即访问Internet,无需执行任何命令.

问题是我无法访问网络192.168.1.X.

早些时候有一个访问权限.我怎样才能解决这个问题?一些数据:

dor@ubuntu:~$route -n

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

0.0.0.0 10.1.0.1 0.0.0.0 UG 0 0 0 em1

10.1.0.0 0.0.0.0 255.255.248.0 U 0 0 0 em1

dor@ubuntu:~$ifconfig -a

em1 Link encap:Ethernet HWaddr 44:37:e6:4c:ca:0a

inet addr:10.1.0.102 Bcast:10.1.7.255 Mask:255.255.248.0

inet6 addr: fe80::4637:e6ff:fe4c:ca0a/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:30356 errors:0 dropped:0 overruns:0 frame:0

TX packets:329 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:2752089 (2.7 MB) TX bytes:43904 (43.9 KB)

Interrupt:20 Memory:fe600000-fe620000

eth5 Link encap:Ethernet HWaddr 00:0a:5e:50:cf:1e

BROADCAST MULTICAST MTU:1500 Metric:1

RX packets:0 errors:0 dropped:0 overruns:0 frame:0

TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

Interrupt:20

lo Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

inet6 addr: ::1/128 Scope:Host

UP LOOPBACK RUNNING MTU:65536 Metric:1

RX packets:97 errors:0 dropped:0 overruns:0 frame:0

TX packets:97 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:8463 (8.4 KB) TX bytes:8463 (8.4 KB)

p4p1 Link encap:Ethernet HWaddr 00:15:17:0b:6d:1c

BROADCAST MULTICAST MTU:1500 Metric:1

RX packets:0 errors:0 dropped:0 overruns:0 frame:0

TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

Interrupt:16 Memory:fe540000-fe560000

编辑#2,2014年4月20日08:05 UTC:

最后我编辑文件/ etc / network / interfaces以具有以下配置:

auto em1

iface em1 inet dhcp

auto eth5

iface eth5 inet static

address 10.90.90.91

netmask 255.255.255.0

up route add -net 10.90.90.0/24 dev eth5

auto p4p1

iface p4p1 inet static

address 192.168.1.32

netmask 255.255.255.0

up route add -net 192.168.1.0/24 dev p4p1

它奏效了!看到:

dor@ubuntu:~$route -n

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

0.0.0.0 10.1.0.1 0.0.0.0 UG 0 0 0 em1

10.1.0.0 0.0.0.0 255.255.248.0 U 0 0 0 em1

10.90.90.0 0.0.0.0 255.255.255.0 U 0 0 0 eth5

10.90.90.0 0.0.0.0 255.255.255.0 U 0 0 0 eth5

192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 p4p1

192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 p4p1

唯一的问题是那些重复.但它不会干扰任何事情,它仍然有效.

编辑#3,2014年4月20日09:57 UTC:

事实上,正如我所怀疑的,重复是由以下命令引起的:

up route add -net 192.168.1.0/24 dev p4p1

所以我删除了它们.现在一切都很完美.

linux 添加网关 多张,linux – 更改默认网关,多个NIC相关推荐

  1. 网关 可用计算机 掩码,电脑默认网关不可用

    我们在使用电脑的时候,经常遇见很多默认网关的问题,比如电脑默认网关不可用怎么办,默认网关不在由ip地址和子网掩码定义的同一网络段上,默认网关总是掉线怎么办,以及各种各样的问题.那么我们该如何解决这些问 ...

  2. linux添加永久路由方法,Linux添加永久静态路由的方法

    Linux添加永久静态路由的方法 一.使用 route 命令添加使用route 命令添加的路由,机器重启或者网卡重启后路由就失效了,方法:A.添加到主机的路由# route add –host 192 ...

  3. linux添加服务命令行,Linux系统自有服务(上)

    系统自有服务(上).md Linux系统自有服务 自有服务,即不需要用户独立去安装的软件的服务,而是当系统安装好之后就可以直接使用的服务(内置) 学习目标 1.了解Linux的7种运行模式 2.了解用 ...

  4. linux添加ipv6地址命令,Linux下配置IPv6地址的方法

    Linux在内核版本2.2.0以后就支持IPv6了,可查看/proc/net/if_inet6文件是否存在以确定你的系统是否支持IPv6 如果没有,可尝试如下命令加载IPv6模组: # modprob ...

  5. linux添加include环境变量,Linux添加环境变量与GCC编译器添加INCLUDE与LIB环境变量

    Linux添加环境变量与GCC编译器添加INCLUDE与LIB环境变量 15:12) 标签: 编译器 Linux 分类: 转载一些有用的文章 (2012-01-31 对所有用户有效在/etc/prof ...

  6. linux添加用户user1命令,Linux添加用户命令useradd

    简单讲述下Linux添加用户命令useradd的使用方法. 1.用户添加命令useradd [root@localhost user1]# useradd [选项] 用户名 选项: -u UID:手工 ...

  7. linux添加静态路由生效,linux常识:添加静态路由

    方法一:使用命令route //添加路由 # route add -host 192.168.0.221 dev eth0 # route add -host 192.168.1.221 gw 192 ...

  8. linux添加删除用户命令,Linux命令之useradd和userdel(添加、删除用户)

    一.[useradd]:添加用户命令 1.作用 useradd或adduser命令用来建立用户帐号和创建用户的起始目录,使用权限是超级用户. 2.格式 useradd [-d home] [-s sh ...

  9. linux添加新用户;linux常见命令;linux自定义终端命令

    1.linux添加新用户 1.useradd **用户名* 增加用户 2.passwd **用户名* 添加密码 3.su - **用户名* 切换到用户 4.exit 退出用户 切换到用户后只显示$问题 ...

  10. linux添加黑体和宋体,linux添加字体

    其实很早就对 方法如下: C:\Windows\Fonts目录下有所有的windows的字体  将字体复制到/usr/share/fonts/xpfonts/ 第一步:将windows下喜欢的字体文件 ...

最新文章

  1. 被字节跳动T4级大佬鄙视了:让你10倍提升认知效率,就这3个方法!
  2. 基于TransformerFusion的单目场景重构
  3. Linux下用户组、文件权限详解
  4. 五、linux总线中设备和驱动注册流程详解
  5. vmstat命令使用
  6. JUnit与TestNG:您应该选择哪种测试框架?
  7. java运算级别_java运算符优先级别
  8. WCF,Net remoting,Web service
  9. 勇者斗恶龙UVa11292 - Dragon of Loowater
  10. python 制作聊天程序-python实现点对点聊天程序
  11. java中通过正则表达式提取数字
  12. 有哪些论文降重的方法?
  13. Kubeadm部署单Master节点
  14. python怎么检查页面边距_Matplotlib页边距
  15. mysql中删除两条重复的数据,只保留一条
  16. 想不到吧,实体类能自己CRUD,MyBatis-Plus AR模式了解下
  17. 学习Nisy作者c语言教程笔记1
  18. PIAO网址PIAO
  19. macbook 如何稳定的使用第三方鼠标
  20. win10系统编辑服务器在哪个文件夹,文件夹选项在哪里,小编教你Win10文件夹选项在哪...

热门文章

  1. 【spring】【转】Spring 框架的设计理念与设计模式分析
  2. 用户眼中的银行信息化-我的开博感言
  3. 前后落差大用什么词语_形容落差很大的成语_四字词语 - 成梦词典
  4. java swing removeall_java中JFrame中函数removeAll的用法 | 学步园
  5. 训练日志 2019.7.26
  6. 图论 —— 图的连通性 —— 有桥连通图加边变边双连通图
  7. VMweare 典型创建 Kali Linux 虚拟机
  8. 信息学奥赛C++语言:时间转换
  9. 信息学奥赛C++语言:三位数的求和
  10. 47 FI配置-财务会计-固定资产-一般评估-定义资产分类中的折旧范围