修改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
posted @ 2021-06-02 14:25  水天需  阅读(1345)  评论(0编辑  收藏  举报