`
emcome
  • 浏览: 296878 次
  • 性别: Icon_minigender_1
  • 来自: 重庆
社区版块
存档分类
最新评论

debian iptables学习

阅读更多


一.配置debian机器的双网卡IP,我设的是eth0为公网IP,eth1为内网IP,
vim /etc/network/interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 172.18.30.187
netmask 255.255.255.0
gateway 172.18.30.1

auto eth1
iface eth1 inet static
address 192.168.1.1
netmask 255.255.255.0


二、输入:echo 1 > /proc/sys/net/ipv4/ip_forward
当初学习的时候我记得是需要保存这一项的,不然重启后值会变成0。但忘了怎么保存了。再次郁闷,
后来我在/etc/sysct1.conf里添加了下面这一行:
net.ipv4.ip_forward = 1   重启后生效了。嘿嘿!!

 

三、输入: iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j SNAT --to 172.18.30.187

 

此时一个简单的路由器便成功了。

但是,一但系统重启,将不能转发。郁闷,GOOGLE了半天才找到了一个解决保存iptables的方法

 

四、保存iptables:iptables-save > /etc/network/iptables

 

五、在/etc/network/interface里的eth0配置下加入下面这一行,使系统启动时自动转入iptables

 

up /sbin/iptables-restore /etc/network/iptables

 

到此,简单LINUX路由器便做好了,但这个是不安全的,功能也很简单。继续研究!!

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics