zoukankan      html  css  js  c++  java
  • ubuntu配置多网,网关不起作用的问题

    在/etc/network/interfaces 中设置网络

    auto eth0
    iface eth0 inet static
    address 192.168.50.1
    gateway 192.168.50.1
    netmask 255.255.255.0
    
    
    auto eth1
    iface eth1 inet static
    address 192.168.100.150
    gateway 192.168.100.1
    netmask 255.255.255.0
    dns-nameservers 114.114.114.114

    结果启动之后默认网关为192.168.50.1

    $route

    显示如下

    $default 192.168.50.1 。。。

    真正需要的网关是192.168.100.1

    将上述代码修改一下即可

    auto eth0
    iface eth0 inet static
    address 192.168.50.1
    #gateway 192.168.50.1
    netmask 255.255.255.0
    
    
    auto eth1
    iface eth1 inet static
    address 192.168.100.150
    gateway 192.168.100.1
    netmask 255.255.255.0
    dns-nameservers 114.114.114.114

    另外一种配置方式为:

    auto eth0
    iface eth0 inet static
    address 192.168.50.1
    #gateway 192.168.50.1
    netmask 255.255.255.0
    
    
    auto eth1
    iface eth1 inet static
    address 192.168.100.150
    #gateway 192.168.100.1
    netmask 255.255.255.0
    #dns-nameservers 114.114.114.114
    
    up route add -net 192.168.50.0 netmask 255.255.255.0 gw 192.168.100.1 dev eth1
    up route add -net 192.168.100.0 netmask 255.255.255.0 gw 192.168.100.1 dev eth1
  • 相关阅读:
    Windows常用命令
    路由器命令基础使用
    《计算机网络》-CCNA命令大全
    Cisco 2960交换机配置
    vscode使用技巧
    Luogu 3321 [SDOI2015]序列统计
    Luogu 3702 [SDOI2017]序列计数
    CF 990 Educational Codeforces Round 45
    Luogu 4705 玩游戏
    CF 438E The Child and Binary Tree
  • 原文地址:https://www.cnblogs.com/yasmi/p/4860758.html
Copyright © 2011-2022 走看看