Configure Linux As a Router

How to setup linux as router
You need two network interfaces in system (One can be pppoe).
1. Setup system gateway
Edit /etc/sysconfig/network, add gateway or gateway device such as below.
GATEWAY=192.168.0.1
or
GATEWAYDEV=ppp0

2. Turn on IP packet forwarding.
Edit /etc/sysctl.conf, modify below line.
net.ipv4.ip_forward = 1

3. Setup iptable (Only if your LAN IP is private IP and will forward to public IP)
The following examples assume that you are masquerading all computers on your private LAN 10.0.0 (i.e. 10.0.0.1, 10.0.0.2, etc.) and routing packets from that LAN to the Internet over your dial-up (ppp0) interface.
For iptables, type the following as root user:
# iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
# iptables -A FORWARD -s 10.0.0.0/24 -j ACCEPT
# iptables -A FORWARD -d 10.0.0.0/24 -j ACCEPT
# iptables -A FORWARD -s ! 10.0.0.0/24 -j DROP
# cp /etc/sysconfig/iptables /etc/sysconfig/iptables.old
# iptables-save > /etc/sysconfig/iptables
# /etc/init.d/network restart
# /etc/init.d/iptables restart
# iptables -L -n


Refer: http://etutorials.org/Linux+systems/red+hat+linux+bible+fedora+enterprise+edition/Part+IV+Red+Hat+Linux+Network+and+Server+Setup/Chapter+16+Connecting+to+the+Internet/Setting+up+Red+Hat+Linux+as+a+Router/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值