The host windows can be pinged but cannot access the tomcat service in the virtual machine Linux

After installing linux in wmware, install the database, and start the service after JDK and tomcat. The virtual machine can access it, but the host cannot access it, but at the same time, the host and the virtual machine can be pinged.

 The first workaround is to turn off the firewall service in the virtual machine. Desktop--Management--Security Level and Firewall, set the firewall to: disable. Or after logging in with root, execute service iptables stop --stop service iptables start --start the
second solution: The first solution is equivalent to opening all ports, which will inevitably reduce the security of the server. Therefore, since it is possible to change all ports, there is therefore also a setting to change partial port development off.    

Now we try to connect to the remote server under the Windows host - Linux in the virtual machine, remote link, everyone will definitely think of the telnet remote login command that has been used. There is no telnet command found under win7, this is because the xp system is installed by default, but the system under win7 does not install it for us, so it needs to be installed. The specific steps are as follows: Control Panel - Programs and Features to turn on and off Windows functions, select Telnet client, and then click OK.



 To access port 8080, it must be configured in the firewall configuration file

To modify the firewall configuration of the Linux system , you need to modify the file /etc/sysconfig/iptables. If you want to open which port, add a line in it

-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT

That's it, 8080 is the port number to be opened, and then service iptables restart restarts the Linux firewall service.

The default linux port 22 (SSH) is open

The content of the linux file that has been successfully configured by yourself

# sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 23 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

 It should be noted that the port must be placed in front of the rejection, otherwise it will not work


 

Summarize:

I can't access it when I close the firewall, but I can access it with an open port.

There is also a need to pay attention to if the firewall restarts, it is best to reopen a cmd window in the window

telnet 192.168.80.128 8080

 

service iptables stop --stop

service iptables start --start 

service iptables status -- view status

iptables -L lists all rules

 iptables -L lists all rules
iptables -F clears all
iptables -D chain rulenum clears a
rule such as INPUT with three rules, then
iptables -D INPUT 2  
will delete the second rule

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326712485&siteId=291194637