UBUNTU实现单网卡多IP

原文地址:http://www.yimiju.com/articles/505.html

最近要用Linux的iptables NAT功能来映射端口,
但是接口机只有一个网卡,要实现既能访问内网又能访问外网,
于是就要用到本文下面要说到的方法:
1、假设内网的IP信息为:
address 192.168.100.6
netmask 255.255.255.0
gateway 192.168.100.1
2、假设外网的IP信息为:
address 192.168.200.188
netmask 255.255.255.0
gateway 192.168.200.1
3、假设系统中网卡为:eth0
4、那么,可以直接修改Ubuntu的IP配置文件:
#vim /etc/network/interfaces
然后参考下面的内容,相信懂Linux的童鞋都能看懂~

# 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
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.100.6
netmask 255.255.255.0
#gateway 192.168.100.1
# 下面是外网IP的设置
auto eth0:1
iface eth0:1 inet static
address 192.168.200.188
netmask 255.255.255.0
gateway 192.168.200.1

5、重启网卡

#/etc/init.d/networking restart


你可能感兴趣的:(配置文件,单网卡,双IP)