CentOS commands for viewing IP addresses, modifying IP addresses on ports, and activating ports
You know, you get used to ipconfig in windows, and it is a lot of trouble to view IP addresses in CentOS;
The information collected today focuses on IP port problems:
- View IP
Ifconfig eth0 → view the IP address, but the output information is more
Ifconfig | grep 'bcast' → the output information should be much clearer.
- Modify IP address and take effect
Edit/etc/sysconfig/network-scripts/ifcfg-eth0 and follow the settings below
DEVICE = eth0
BOOTPROTO = static
HWADDR =
ONBOOT = yes
TYPE = Ethernet
IPADDR = <your IP address>
NETMASK = 255.255.255.0
The MAC address can be viewed using the ifconfig eth0 command.
After setting, restart the network service:Service network restart
- After the CentOS system is installed, only port 22 is enabled by default. to open other ports, open the required ports.
Vi/etc/sysconfig/iptables
Then add the Java code to the CentOS system.
-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport 3001-j ACCEPT
-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport 3001-j ACCEPT
Finally, the CentOS system needs to restart the service Java code.
/Sbin/service iptables restart
/Sbin/service iptables restart
Check whether Java code is enabled on the port
/Sbin/iptables-L-n