A-A+

Ubuntu实现单网卡双IP的方法

2011年09月01日 经验分享 暂无评论 阅读 8,811 次

ubuntu最近要用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

修改好之后,wq!退出并保存,然后重启网卡:

#/etc/init.d/networking restart

OK,搞定。

author avatar

给我留言

icon_question icon_razz icon_sad icon_evil icon_exclaim icon_smile icon_redface icon_biggrin icon_surprised icon_eek icon_confused icon_cool icon_lol icon_mad icon_twisted icon_rolleyes icon_wink icon_idea icon_arrow icon_neutral icon_cry icon_mrgreen

Copyright © 2009 - 2018 一米居 | All Rights Reserved | Powered By WordPress | Theme Designed By 知更鸟 | 赣ICP备09003747号-2

用户登录

分享到: