UBuntu8.04 Server设置路由器

这篇博客详细介绍了如何在Ubuntu 8.04 Server上设置路由器,包括网卡配置、路由设定、IP包转发、端口映射以及FTP设置。此外,还涉及到限制部分用户上网、保存IPTables设置、限制访问特定网站、控制上网时间和流量等网络管理措施。
摘要由CSDN通过智能技术生成
UBuntu8.04 Server设置路由器
    Linux作为路由器的好处是相比专业的路由器设备,费用节省很多,因为硬件通常都是使用旧电脑加上几块网卡,而Linux系统有很多免费的可以使用。并且由于可以自己定制,可以针对企业网络的情况指定灵活的网络管理规则。但是这种做法需要学习很多知识,往往令人生畏。本文总结了自己的个人经验,试图帮助更多的Linux爱好者。
    我的设置路由器的方法主要用到了UBuntu设置网卡地址、route命令和iptables的相关知识。用eth0直接连接在Internet上,另外两个通过IP包转发的方式和其他子网通信并因此可以连接Internet。

设置网卡

    首先给我的三块网卡分配不同的地址:(通过sudo身份编辑/etc/network/interfaces文件)文件内容如下:

File Edit Options Buffers Tools Help                                                                                                                        
# 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 58.246.17.2
        netmask 255.255.255.248
        network 58.246.17.0
        broadcast 58.246.17.7
        gateway 58.246.17.1
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 210.22.70.3
        dns-search longday.com
# The sencond network interface
auto eth1
iface eth1 inet static
        address 192.168.10.244
        netmask 255.255.255.0
        network 192.168.10.0
        broadcast 192.168.10.255
        gateway 192.168.10.244
        #dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 192.168.10.244


    编辑好上面的文件后,执行sudo /etc/init.d/networking restart 重启网络服务。
    修改/etc/resolv.conf文件下的DNS为210.22.70.3,重启计算机。

设置路由

    现在我们要通过route命令设置路由,使得:
1)所有发往58.246.17.0网段的数据包经过eth0网卡
2)所有发往192.168.10.0网段的数据包经过eth1网卡

    route命令可以用来查看当前路由表的设置,route del用于删除某条路由设置,route add用于添加某条路由设置.最后设置好的路由表如下:
/etc/network # route
Kernel IP routing table
Destination     Gateway         Genmask  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值