Sure! Here is a step-by-step guide on how to view IP addresses in Linux, along with two examples:
- Open a terminal:
- Press
Ctrl + Alt + T
to open a new terminal window. -
Alternatively, you can search for \"Terminal\" in the applications menu and click on it.
-
Use the
ifconfig
command: - Type
ifconfig
in the terminal and press Enter. - This command displays the network interfaces and their corresponding IP addresses.
Example 1:
```
$ ifconfig
eth0: flags=4163
inet 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::a00:27ff:fe8e:5e4a prefixlen 64 scopeid 0x20 ether 08:00:27:8e:5e:4a txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
```
In this example, the IP address of the eth0
interface is 192.168.1.10
, and the IP address of the lo
(loopback) interface is 127.0.0.1
.
- Use the
ip
command: - Type
ip addr show
orip a
in the terminal and press Enter. - This command provides detailed information about the network interfaces, including their IP addresses.
Example 2:
$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:8e:5e:4a brd ff:ff:ff:ff:ff:ff
inet 192.168.1.10/24 brd 192.168.1.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fe8e:5e4a/64 scope link
valid_lft forever preferred_lft forever
In this example, the IP address of the eth0
interface is 192.168.1.10
, and the IP address of the lo
(loopback) interface is 127.0.0.1
.
These are two common methods to view IP addresses in Linux using the ifconfig
and ip
commands. You can choose the method that suits your needs and preferences.
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:Linux查看ip的实例方法 - Python技术站