iptables案例:使用iptables搭建路由器
生活随笔
收集整理的這篇文章主要介紹了
iptables案例:使用iptables搭建路由器
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
使用iptables搭建路由器
場景及原理
左邊的機器為A,右邊的機器為B
A和B在同一個自網路,B有兩個網卡。一個網卡和A同在一個網絡,另外一個網卡可以連接外網。
iptable配置
機器B
開啟內核路由轉發功能
[root@xuegod63 ~]# vim /etc/sysctl.conf #改:#net.ipv4.ip_forward = 0 #為: net.ipv4.ip_forward = 1 #改完使配置生效: [root@xuegod63 ~]# sysctl -piptables轉發配置
[root@xuegod63 ~]# iptables -t nat -A POSTROUTING -s 192.168.240.0/24 -j SNAT --to 192.168.1.250 或: [root@xuegod63 ~]#iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -o eth0 -j MASQUERADE # 拒絕訪問轉發機器本身 [root@xuegod63 ~]# iptables -A INPUT -s 192.168.2.2 -j DROP注:SNAT不明白可以參考:http://blog.csdn.net/wheat_ground/article/details/78510949
機器A
配置network
重啟network
總結
以上是生活随笔為你收集整理的iptables案例:使用iptables搭建路由器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 网上支付心案例payment
- 下一篇: 腾讯QQ企业邮箱POP3/SMTP设置