How to view and modify ip addresses and open ports in CentOS

Source: Internet
Author: User
You know, you get used to ipconfig in windows. it is a lot of trouble to view the IP address in CentOS. The information collected today focuses on solving the IP port problem: view IPifconfigeth0 → view the IP address, but the output information is more ifconfig | grepBcast → the output information should be clear. modify the IP address and edit/etc/sysconfig/. you know, I am 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 = <你的ip>
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
-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport3001-j ACCEPT
-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport3001-j ACCEPT

Finally, the CentOS system needs to restart the service.
/Sbin/service iptables restart
/Sbin/service iptables restart

Check whether the port is open
/Sbin/iptables-L-n
Use MysqlThis operation is required when the client connects to the server, opens port 3306, and configures Nginx. this obstacle is no longer available now. let's continue ......
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.