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
    
    

    #gatway10.72.66.xxx\color{#FF3030}{注意第二個網關一定不能配置\#gatway 10.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網關
    

    eno2\color{#FF3030}{-- 手動添加 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
    
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章