如何通过firewalld启用协同24800(或其他一些端口)

在升级到Fedora 18,Synergy之后,键盘共享系统默认被阻止。 罪魁祸首是firewalld,它高兴地忽略了我之前在Fedora GUI中进行的设置,由iptables支持。

~]$ ps aux | grep firewall root 3222 0.0 1.2 22364 12336 ? Ss 18:17 0:00 /usr/bin/python /usr/sbin/firewalld --nofork david 3783 0.0 0.0 4788 808 pts/0 S+ 20:08 0:00 grep --color=auto firewall ~]$ 

好的,如何解决这个问题? 我做了几个星期的sudo killall firealld ,但是每次重新启动都会让人讨厌。 是时候寻找一些线索了。 有几个衬里,但他们没有为我工作。 他们不停地吐出帮助文字。 例如:

 ~]$ sudo firewall-cmd --zone=internal --add --port=24800/tcp [sudo] password for auser: option --add not a unique prefix 

此外,声明这个命令的post也表示这是暂时的,无法在重新启动后继续存在。 我结束了添加一个文件到configuration目录在启动时加载。

任何人都可以看看,看看我错过了什么吗? 虽然协同作用,当我运行列表命令,我得不到结果:

 ~]$ sudo firewall-cmd --zone=internal --list-services ipp-client mdns dhcpv6-client ssh samba-client ~]$ sudo firewall-cmd --zone=internal --list-ports ~]$ 

这是如何打开与firewalld港口。 我没有find像旧的防火墙程序那样的gui,并且意识到firewalld忽略了我之前的协同规则。

Firewalld安装了一些默认configuration文件,可用于通过系统允许服务或端口。

 ~]$ sudo ls -l /usr/lib/firewalld/zones total 36 -rw-r-----. 1 root root 256 Feb 20 10:37 block.xml -rw-r-----. 1 root root 293 Feb 20 10:37 dmz.xml -rw-r-----. 1 root root 226 Feb 20 10:37 drop.xml -rw-r-----. 1 root root 319 Feb 20 10:37 external.xml -rw-r-----. 1 root root 400 Feb 20 10:37 home.xml -rw-r-----. 1 root root 415 Feb 20 10:37 internal.xml -rw-r-----. 1 root root 340 Feb 20 10:37 public.xml -rw-r-----. 1 root root 179 Feb 20 10:37 trusted.xml -rw-r-----. 1 root root 367 Feb 20 10:37 work.xml 

我决定采取internal.xml进行旋转,并将其从安装目录复制到/ etc / firewalld /中的加载目录中,然后编辑它以添加我的端口以实现协同。

 ~]$ sudo cp /usr/lib/firewalld/zones/internal.xml /etc/firewalld/zones ~]$ sudo vi /etc/firewalld/zones/internal.xml <?xml version="1.0" encoding="utf-8"?> <zone> <short>Internal</short> <description>For use on internal networks. You mostly trust the other computers on the networks to not harm your computer. Only selected incoming connections are accepted.</description> <service name="ssh"/> <service name="ipp-client"/> <service name="mdns"/> <service name="samba-client"/> <service name="dhcpv6-client"/> <port port="24800" protocol="tcp"/> <-- Here is my addition. </zone> 

我保存了文件,重新启动了firewalld,我的协同应用程序又重新启动了。

 ~]$ sudo service firewalld restart 

我不太经常使用其他服务,但是我确实在这里共享文件夹,并且可能会在蓝色的月亮中login一次,所以id并没有打扰其他人。

为了使它坚持下来,我把firewalld.conf的默认值更改为internal。

 ~]$ sudo vi /etc/firewalld/firewalld.conf # firewalld config file # default zone # The default zone used if an empty zone string is used. # Default: public DefaultZone=internal <-- changed this line 

总而言之,我认为编辑configuration非常简单。 像我这样的noob比iptables规则更容易理解。

我希望它能帮助你继续使用新的Fedora。

更新:原来我input了错误的add命令。 要使用临时添加端口或服务,它是这样的:

 ~]$ sudo firewall-cmd --add-port=24800/tcp ~]$ sudo firewall-cmd --list-all internal interfaces: eth0 services: ipp-client mdns dhcpv6-client ssh samba-client ports: 24800/tcp forward-ports: icmp-blocks: 

你想添加的东西被附加到–add命令后面加一个 – 。

现在在手册页中,我也看到了一个永久选项。 所以,我试试看:

 ~]$ sudo firewall-cmd --permanent --add-port=24800/tcp ~]$ sudo firewall-cmd --complete-reload ~]$ sudo firewall-cmd --list-all internal interfaces: eth0 services: ipp-client mdns dhcpv6-client samba-client ssh ports: 24800/tcp forward-ports: icmp-blocks: 

到现在为止还挺好。 重启后,我会看到我有什么。 同时我发现区域目录中的更改:

 ~]$ sudo ls /etc/firewalld/zones internal.xml internal.xml.old ~]$ sudo cat /etc/firewalld/zones/internal.xml <?xml version="1.0" encoding="utf-8"?> <zone> <short>Internal</short> <description>For use on internal networks. You mostly trust the other computers on the networks to not harm your computer. Only selected incoming connections are accepted.</description> <service name="ipp-client"/> <service name="mdns"/> <service name="dhcpv6-client"/> <service name="samba-client"/> <service name="ssh"/> <port protocol="tcp" port="24800"/> </zone> 

读完man firewall-cmd我跑了;

sudo firewall-cmd --permanent --add-port=24800/tcp

并重新启动了我的伎俩