大网数据广告活动
服务器运维问答

Shorewall - Allow Remote Client to Ping the Internet

· 52CE 我爱测

My network address is 192.168.5.0 . My host machine is 192.168.5.1 and my client machine is 192.168.5.2 . Currently, my client is unable to use the internet browser and even ping the internet. The client can ping the host machine…

问题原文

原帖链接 · alyssaeliyah · CC BY-SA 4.0

My network address is 192.168.5.0. My host machine is 192.168.5.1 and my client machine is 192.168.5.2. Currently, my client is unable to use the internet browser and even ping the internet. The client can ping the host machine in the local network.

How will I enable my client to ping the internet through a terminal and restrict it to use the browser or port 80 using Shorewall? Below are my configuration files:

/etc/shorewall/interfaces file:

#ZONE     INTERFACE
net      eth0

loc      eth1

The eth0 interface is the one connected to the internet while eth1 is connected to the local network.

/etc/shorewall/zones file:

#ZONE    TYPE
fw       firewall
net      ipv4
loc      ipv4

/etc/shorewall/policy file:
#SOURCE     DEST     POLICY     LOGLEVEL
loc         net      ACCEPT
net         all      DROP       $LOG_LEVEL

all         all      REJECT     $LOG_LEVEL

/etc/shorewall/rules file:

?SECTION  ALL
?SECTION  ESTABLISHED
?SECTION  RELATED
?SECTION  INVALID

?SECTION UNTRACKED

?SECTION NEW


DNS(ACCEPT)     $FW    net

SSH(ACCEPT)     loc    $FW

PING(ACCEPT)    loc    $FW

PING(DROP)      net    $FW


ACCEPT    $FW    loc    icmp

ACCEPT    $FW    net    icmp

Any help would be very much appreciated.

已采纳解答

原帖链接 · Diamond · CC BY-SA 4.0

I would recommend you to check this page if you haven't done it already:

http://www.shorewall.org/two-interface.htm

The basics are explained here with examples.

Depending on your version, there are also sample files you can copy and customize from:

 /usr/share/doc/shorewall/examples/two-interfaces

From the quick look, it seems to me, the following are missing:

  1. Masquerading/NAT (snat or masq file depending on your version).
  2. IP_Forwarding=ON in shorewall.conf.
  3. Service Shorewall to start automatically on boot.

Addition1: Please also check the correct spelling for the shorewall macros you are using. For example:

Ping (and not PING)

Addition2: You have the default policy for local to internet is all allowed:

/etc/shorewall/policy file:
#SOURCE     DEST     POLICY     LOGLEVEL
loc         net      ACCEPT

This means by default everything from local network to internet will be allowed through the firewall. Now if you want to block something, lets say port 80, you will need to put a block rule on top. For example:

HTTP(DROP)    loc    net

And you don't need any extra allow rule for ping from lan to net.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-03-21)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。