ubuntu系统绑定多个ip

  • A+
所属分类:未分类

修改ubuntu的网卡IP地址可以通过两种方式来修改.

第一种方式静态修改.

进入 /etc/network/ 目录下.修改interfaces文件.

# The primary network interface
auto eth0
iface eth0 inet static
address 110.25.*.*
netmask 255.255.255.0
gateway 110.25.*.1

#auto eth0:0
#iface eth0:0 inet static
#address 110.25.*.*
#netmask 255.255.255.0
蓝字部分是我添加的.eth0:0类似于数组下标.接下来想绑定多个就可以以此类推eth0:1,eth0:2,eth0:3........

第二种方式是动态修改.

这里直接使用 ifconfig 命令

sudo ifconfig eth0:0 110.25.*.* broadcast 110.25.*.255 netmask 255.255.255.0

注:

第一种方式在你修改重启之后不会失效.这种方式稍微操作不当,则会造成远程无法连接。
第二种方式虽然只对当前生效,重启之后就会失效.但是不会因为操作不当给自己造成的不便。

修改成功之后用ifconfig命令看一下
eth0
eth0:0 (多出一个eth0:0,查看与eth0的网关是否一样)
lo

比如:

auto eth0
auto eth0:0
auto eth0:1

iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.248
gateway 192.168.1.254

iface eth0:0 inet static
address 192.168.1.2
netmask 255.255.255.248
gateway 192.168.1.254

iface eth0:1 inet static
address 192.168.1.3
netmask 255.255.255.248
gateway 192.168.1.254
# add rest of alias / binds below

Save and close the file.

Now restart networking, enter:
# /etc/init.d/networking restart
OR
$ sudo /etc/init.d/networking restart

weinxin
我的QQ群
这是我的QQ群扫一扫

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: