这是在实验室搭建局域网时的配置写在这里吧,等在回忆那段大学生活时还是很美好的!
环境:外网IP 202.206.249.186 子网掩码 255.255.255.0 默认网关 202.206.249.1
内网IP192.168.0.1 子网掩码 255.255.255.0网关不添
[root@localhost ~]# echo "1" > /proc/sys/net/ipv4/ip_forward
[root@localhost ~]# iptables -F
[root@localhost ~]# iptables -t nat -F
[root@localhost ~]# iptables -t mangle -F
[root@localhost ~]# iptables -X
[root@localhost ~]# iptables -t nat -X
[root@localhost ~]# iptables -t mangle -X
[root@localhost ~]# iptables -P INPUT ACCEPT
[root@localhost ~]# iptables -P OUTPUT ACCEPT
[root@localhost ~]# iptables -P FORWARD ACCEPT
[root@localhost ~]# iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j SNAT --to 202.206.249.186
保存
iptables-save>nat-1.1
service iptables save
本文详细记录了在实验室环境中搭建局域网的具体步骤,包括内外网IP设置、子网掩码配置、启用IP转发及使用iptables进行路由设置等内容。

2058

被折叠的 条评论
为什么被折叠?



