Ubuntu服务器双网配置

Ubuntu服务器双网配置

内网:192.168.13.181
外网:10.72.66.249

  1. 进入网络配置

    sudo vim /etc/network/interfaces
    
    auto eno1
    iface eno1 inet dhcp
    iface eno1 inet static
    address 192.168.13.181
    netmask 255.255.255.0
    gateway 192.168.13.80
    
    auto eno2
    iface eno2 inet static
    address 10.72.66.249
    netmask 255.255.255.128
    #gatway 10.72.66.xxx
    
    

    注 意 第 二 个 网 关 一 定 不 能 配 置 # g a t w a y 10.72.66. x x x \color{#FF3030}{注意第二个网关一定不能配置\#gatway 10.72.66.xxx} #gatway10.72.66.xxx

  2. 添加DNS并使其生效

    sudo vim /etc/resolvconf/resolv.conf.d/base 
    
    nameserver 10.33.112.XX
    
    sudo resolvconf -u   -- 使dns生效
    
  3. 重启网卡

    sudo /etc/init.d/networking restart 
    
  4. 查看当前路由

    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    0.0.0.0         192.168.13.244  0.0.0.0         UG    0      0        0 eno1
    10.72.66.128    0.0.0.0         255.255.255.128 U     0      0        0 eno2
    192.168.13.0    0.0.0.0         255.255.255.0   U     0      0        0 eno1
    -- 无eno2网关
    

    − − 手 动 添 加 e n o 2 网 段 网 关 \color{#FF3030}{-- 手动添加 eno2网段网关} eno2

    	 sudo route add default gw 10.72.66.xxx
    	-- 再次查看  以添加  10.72.66.xxx
    	Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    	0.0.0.0         10.72.66.xxx    0.0.0.0         UG    0      0        0 eno2
    	0.0.0.0         192.168.13.244  0.0.0.0         UG    0      0        0 eno1
    	10.72.66.128    0.0.0.0         255.255.255.128 U     0      0        0 eno2
    	192.168.13.0    0.0.0.0         255.255.255.0   U     0      0        0 eno1
    	
    
  5. 测试是否成功

    -- 外网
    PING 11.71.15.xx (11.71.15.xx) 56(84) bytes of data.
    64 bytes from 11.71.15.xx: icmp_seq=1 ttl=250 time=1.59 ms
    64 bytes from 11.71.15.xx: icmp_seq=2 ttl=250 time=1.53 ms
    
    -- 内网
     ping 192.168.13.xx
    PING 192.168.13.134 (192.168.13.xx) 56(84) bytes of data.
    64 bytes from 192.168.13.xx: icmp_seq=1 ttl=128 time=0.786 ms
    64 bytes from 192.168.13.1xx: icmp_seq=2 ttl=128 time=0.394 ms
    
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值