首页 / 操作系统 / Linux / Ubuntu实现单网卡双IP的方法
最近要用Ubuntu Linux的iptables NAT功能来映射端口,但是接口机只有一个网卡,要实现既能访问内网又能访问外网,于是就要用到本文下面要说到的方法:1、假设内网的IP信息为:address 192.168.100.6netmask 255.255.255.0gateway 192.168.100.12、假设外网的IP信息为:address 192.168.200.188netmask 255.255.255.0gateway 192.168.200.13、假设系统中网卡为:eth04、那么,可以直接修改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 interfaceauto loiface lo inet loopback# The primary network interfaceauto eth0iface eth0 inet staticaddress 192.168.100.6netmask 255.255.255.0#gateway 192.168.100.1# 下面是外网IP的设置auto eth0:1iface eth0:1 inet staticaddress 192.168.200.188netmask 255.255.255.0gateway 192.168.200.1修改好之后,wq!退出并保存,然后重启网卡:#/etc/init.d/networking restart更多Ubuntu相关信息见Ubuntu 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=2本文永久更新链接地址