修改Ubuntu IP和內網網段


遷移機房的時候,新機房只有一條線路,而且大多數內部服務的ip都配置好了,都是192.168.1.* 網段,所以首先要把內網網段改成1.,再把那台 3.的改成 1.*。

修改內網網段

在查看內網網段的時候,發現小米路由器默認的網段是10., 而1.的已經被光貓給占用,導致所有服務器都不能訪問。查了各種資料,問了移動的師傅,終於找到了解決方法,

  1. 把光貓的網線直接連路由器的vlan口而不要連wlan
  2. 修改路由器的設置,禁止DHCP, 並且修改路由器的IP為192.168.1.2
  3. 修改所有服務器的/etc/network/interfaces gateway為192.168.1.1。

修改Ubuntu IP

  1. ifconfig找到默認網卡, 一般是eth0
    ifconfig -a
  2. cd 到/etc/network/ sudo vim interfaces, 把address改為期望的ip。
xx@xx-virt-srv-r:~$ cat /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

auto eth0
iface eth0 inet static
address 192.168.1.13
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers  203.86.16.78 8.8.8.8
  1. 重啟網卡或服務器
    sudo /etc/init.d/networking restart 或者 sudo ifdown ens33 & sudo ifup ens33
    如果提示eth0找不到,那么先用ifconfig加進配置再重啟
sudo ifconfig eth0 down
sudo ifconfig eth0 up


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM