CentOS / Redhat : Configure CentOS as a Software Router with two interfaces

 
Linux can be easily configured to share an internet connection using iptables. All you need to have is, two network interface cards as follows:

a) Your internal (LAN) network connected via eth0 with static ip address 192.168.0.1
b) Your external WAN) network is connected via eth1 with static ip address 10.10.10.1  ( public IP provided by ISP )
Please note that interface eth1 may have public IP address or IP assigned by ISP. eth1 may be connected to a dedicated DSL / ADSL / WAN / Cable router:

Step # 1: Enable Packet Forwarding

Login as the root user. Open /etc/sysctl.conf file
# vi /etc/sysctl.conf
 
Add the following line to enable packet forwarding for IPv4:
net.ipv4.conf.default.forwarding=1
 
Save and close the file. Restart networking:
# service network restart
 

Step # 2: Enable IP masquerading

 
In Linux networking, Network Address Translation (NAT) or Network Masquerading (IP Masquerading) is a technique of transceiving network traffic through a router that involves re-writing the source and/or destination IP addresses and usually also the TCP/UDP port numbers of IP packets as they pass through. In short, IP masquerading is used to share the internet connection.
 

Share internet connection

To share network connection via eth1, enter the following rule at command prompt (following useful for ppp0 or dial up connection):
 

# service iptables stop
# iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
# service iptables save
# service iptables restart
 
Make sure Iptables runs on boot
 
# chkconfig iptables on
 
 
Open your Windows / Mac / Linux computer networking GUI tool and point router IP to 192.168.0.1 (eth0 Linux IP). You also need to setup DNS IP such as 8.8.8.8 or to your local DNS server IP. You should now able to ping or browse the internet:
 
# ping google.com


Client Side Configuration

Now all you have to do is set the IP 192.168.0.1 as gateway on all your client machines in your network. You can enter  your default gateway in the file /etc/sysconfig/network as:- 
GATEWAY=192.168.0.1
or you can also put the same entry in your interface specific file at /etc/sysconfig/network-scripts/ifcfg-eth0 in case of RHEL/Centos or at /etc/network/interfaces in case of ubuntu.

- See more at: http://www.linuxtechtips.com/2013/12/configure-centos-as-a-router.html#.dpuf

CentOS / Redhat : Configure CentOS as a Software Router with two interfaces的更多相关文章

  1. IP Failover Setup using Keepalived on CentOS/Redhat 6

    source url:http://tecadmin.net/ip-failover-setup-using-keepalived-on-centos-redhat-6/ Keepalived is ...

  2. 定制CentOS (Redhat AS 5.1)安装盘

    CentOS(Redhat)提供了一套完整的自动化安装机制,利用该机制,我们可以自己定制无人值守的自动安装光盘,也可以进行系统裁减,甚至可以以CentOS为基础制作自己软件系统的系统安装盘.以下全部内 ...

  3. CentOS/RedHat安装Python3

    CentOS/RedHat安装Python3 摘自:https://blog.csdn.net/mvpboss1004/article/details/79377019 CentOS/RedHat默认 ...

  4. Ubuntu/centos/redhat/SUSE sipp安装(带rtp支持,3.5.1版本)

    1.ubuntu 12.04 apt-get install ncurses-dev apt-get install libpcap-dev ./configure --with-pcap make ...

  5. CentOS(RedHat) 6.2 Samba share权限拒绝访问

    在实现<CentOS(RedHat) 6.2下Samba配置>的过程中,发现CentOS 6.2的Samba share总是没有权限写文件,已经试过在Windows XP/Windows  ...

  6. Linux/centos/redhat下各种压缩解压缩方式详解

    1.zip命令 zip -r myfile.zip ./* 将当前目录下的所有文件和文件夹全部压缩成myfile.zip文件,-r表示递归压缩子目录下所有文件. 2.unzip unzip -o -d ...

  7. RedHat和CentOS使用本地yum源配置

    2013-04-01 11:38:30 标签:本地yum源 版权声明:原创作品,谢绝转载!否则将追究法律责任. 使用yum命令安装所需的软件,如果设备网络状况很好,当然也没必要去配置本地yum源,直接 ...

  8. 在Windows基础上(硬盘)安装Linux操作系统(CentOS/RedHat)

    注:该方法安装CentOS ,RedHat均没有问题,其它Linux操作系统,没有尝试过. 0.创建一个fat32的盘.我分了8G给这个盘,盘符为F.F盘以后的内存所有删除,作为未分配的内存.这个留用 ...

  9. redhat linux/CentOS 6/7 如何关闭防火墙?

    redhat linux/CentOS 6/7 如何关闭防火墙?关闭防火墙iptables的具体命令如下: 临时性的完全关闭防火墙,可以不重启机器(但是重启服务器后iptables防火墙服务会自动随系 ...

随机推荐

  1. 浅谈Android编码规范及命名规范

    前言: 目前工作负责两个医疗APP项目的开发,同时使用LeanCloud进行云端配合开发,完全单挑. 现大框架已经完成,正在进行细节模块上的开发 抽空总结一下Android项目的开发规范:1.编码规范 ...

  2. 数据库管理工具GUI - PremiumSoft Navicat Premium Enterprise 11.2.15 x86/x64 KEY

    转载自: 数据库管理工具GUI - PremiumSoft Navicat Premium Enterprise 11.2.15 x86/x64 KEY Navicat Premium(数据库管理工具 ...

  3. bitnami redmine版本由2.3.1升级至3.2.2过程

    环境: 操作系统为ubuntu13.**版本,非长期支持版. 安装目录:/opt/redmine-2.3.1-0/ 所有者用户:root 安装过程: 1. 备份2.3.1数据库 sudo /opt/r ...

  4. 树莓派 连接wifi与路由器ip绑定

    先推荐几个手机软件 在酷安网里应该能找到 1.JuiceSSH  橘子ssh软件  手机连上路由器 就可以控制局域网内的树莓派 2.VNC Viewer  远程桌面软件VNC 也是连接局域网的树莓派 ...

  5. vim 在linux下中如何设置显示行数

     在.vimrc(或/etc/vimrc)文件中输入如下文本: set tabstop=4  set softtabstop=4  set shiftwidth=4  set noexpandtab  ...

  6. openstack学习(一)kvm-libvirt

    准备工作: 操作系统:ubuntu 16.04 安装KVM Kernel-based Virtual Machine的简称,是一个开源的系统虚拟化模块,自Linux 2.6.20之后集成在Linux的 ...

  7. [LeetCode] Sort Characters By Frequency 根据字符出现频率排序

    Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Input: ...

  8. yii2使用小知识(连续补充)

    1,打印ar或者query的原始sql: $query = (new \yii\db\Query())->select(['a.username','b.item_name'])->fro ...

  9. 动态生成验证码———MVC版

    上面有篇博客也是写的验证码,但那个是适用于asp.net网站的. 今天想在MVC中实现验证码功能,弄了好久,最后还是看博友文章解决的,感谢那位博友. 首先引入生成验证码帮助类. ValidateCod ...

  10. C#之发送邮件【模板】+【封装】ZJ版

    PS: 为了弥补上篇博客的不足,正好周六闲着没事.所以进行优化下,来个终结版 功能实现:模板发送+自指定邮箱发送+解耦 总体预览如下: 各代码如下:(代码略多,所以都折叠了) 前台; @{ Layou ...