In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces some common commands for setting network parameters in linux, which can be used for reference by friends who need them. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.
Three commands related to network settings:
Ifconfig: query and set Nic, ip, subnet mask and other parameters (need to install net-tools tool first)
Ifup, ifdown: starting and shutting down network interfaces
Route: view and configure routing information
Ifconfig
First, let's look at the ifconfig command.
Ifconfig [Nic name] [options] up, down: enable or disable the network interface mtu: set mtu value netmask: set subnet mask broadcast: set broadcast address
First, take a look at the first example. Check all the network cards on the system. Just enter the ifconfig command without adding any parameters.
# ifconfigeth0: flags=4163 mtu 1500 inet 192.168.2.220 netmask 255.255.255.0 broadcast 192.168.2.255 inet6 fe80::1733:cf21:906d:57af prefixlen 64 scopeid 0x20 ether 00:0c:29:84:5b:d0 txqueuelen 1000 (Ethernet) RX packets 9946 bytes 10315936 (9.8 MiB) RX errors 0 dropped 3 frame 0 TX packets 2208 bytes 186213 (181.8 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73 mtu 65536.
From the output information of this command, we can get a lot of information, such as network card name, ip address, subnet mask, broadcast address and so on.
Let's take a look at a few examples.
# modify ip address # ifconfig eth0 192.168.1.222
You will find that you have only modified the ip address, but the broadcast address will also be changed.
# simultaneously modify ip, subnet mask and Mtu value ifconfig eth0 192.168.2.222 netmask 255.255.240.0 mtu 1000
Please rest assured to practice as soon as possible. In the end, you only need to restart network to restore the settings of the previous configuration file.
Ifup ifdown
When we modify the network configuration file / etc/sysconfig/network-scripts/eth0, we want to take effect immediately. Then you need to use the
Ifdown eth0ifup eth0
In addition to this method, we usually use
/ etc/init.d/network restart
To restart all network cards.
Route
The route command can be used to view the routing table and to set up routes.
View routing information route [- nee]
-n: do not display the hostname, but directly display it with ip, which is faster. This option has a lot of commands about the network.
-ee: displays more detailed information
# route-nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface0.0.0.0 172.19.255.253 0.0.0.0 UG 00 0 eth0169.254.0.0 0.0.0.0 255.255.0.0 U 1002 00 eth0172.19.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
Destination: network addr
Genmask: subnet mask, Destination and Genmask form a network
Gateway: gateway address (0.0.0.0 indicates that the route is sent directly by the local machine, that is, it can be sent directly over the local area network. If the ip address is displayed, the route needs to be sent with the help of the router (gateway).
Flag: flag, the common U indicates that the route is enabled, and G indicates that the route needs to pass packets through an external host.
Thank you for reading this article carefully. I hope it will be helpful for everyone to share some common commands for setting network parameters in linux. At the same time, I also hope that you will support us, pay attention to the industry information channel, and find out if you encounter problems. Detailed solutions are waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
# Flush all policyiptables-Fiptables-Xiptables-Ziptables-t nat-Fiptables-t nat-Xiptables-t n
© 2024 shulou.com SLNews company. All rights reserved.