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


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章