遷移機房的時候,新機房只有一條線路,而且大多數內部服務的ip都配置好了,都是192.168.1.* 網段,所以首先要把內網網段改成1.,再把那台 3.的改成 1.*。
修改內網網段
在查看內網網段的時候,發現小米路由器默認的網段是10., 而1.的已經被光貓給占用,導致所有服務器都不能訪問。查了各種資料,問了移動的師傅,終於找到了解決方法,
- 把光貓的網線直接連路由器的vlan口而不要連wlan
- 修改路由器的設置,禁止DHCP, 並且修改路由器的IP為192.168.1.2
- 修改所有服務器的/etc/network/interfaces gateway為192.168.1.1。
修改Ubuntu IP
- ifconfig找到默認網卡, 一般是eth0
ifconfig -a
- 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
- 重啟網卡或服務器
sudo /etc/init.d/networking restart
或者sudo ifdown ens33 & sudo ifup ens33
如果提示eth0找不到,那么先用ifconfig加進配置再重啟
sudo ifconfig eth0 down
sudo ifconfig eth0 up