你好,游客 登录 注册 搜索
背景:
阅读新闻

Ubuntu实现单网卡双IP的方法

[日期:2015-04-04] 来源:Linux社区  作者:Linux [字体:大 中 小]

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

本文永久更新链接地址:http://www.linuxidc.com/Linux/2015-04/115785.htm

linux
相关资讯       Ubuntu双IP 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款