折腾:
期间,想要了解此处买到的百度的云服务器的CentOS中的内网IP和外网IP
再去搜:
centos 查看ip
参考:
CentOS 查看IP,端口 修改IP,打开端口生效 – lhj588 – 博客园
去试试:
[root@instance-jb4q99qd ~]# ifconfig | grep broadcast
inet 192.168.0.4 netmask 255.255.240.0 broadcast 192.168.15.255
[root@instance-jb4q99qd ~]#
[root@instance-jb4q99qd ~]# ifconfig -a
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1400
inet 192.168.0.4 netmask 255.255.240.0 broadcast 192.168.15.255
inet6 fe80::f816:3eff:fe65:1b39 prefixlen 64 scopeid 0x20<link>
ether fa:16:3e:65:1b:39 txqueuelen 1000 (Ethernet)
RX packets 15232 bytes 22401678 (21.3 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 11971 bytes 3707501 (3.5 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Local Loopback)
RX packets 6 bytes 518 (518.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 6 bytes 518 (518.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@instance-jb4q99qd ~]# curl ifconfig.me
106.12.26.141
另外,本地电脑直接打开:
What Is My IP Address? – ifconfig.me
也可以看到类似信息:
所以再去BCC主机中试试其他命令:
[root@instance-jb4q99qd ~]# curl ifconfig.me
106.12.26.141
[root@instance-jb4q99qd ~]# curl ifconfig.me/host
[root@instance-jb4q99qd ~]# curl ifconfig.me/ua
curl/7.29.0
[root@instance-jb4q99qd ~]# curl ifconfig.me/port
43114
[root@instance-jb4q99qd ~]# curl ifconfig.me/lang
[root@instance-jb4q99qd ~]# curl ifconfig.me/mime
*/*
[root@instance-jb4q99qd ~]# curl ifconfig.me/all
ip_addr: 106.12.26.141
remote_host:
user_agent: curl/7.29.0
port: 48866
lang:
connection:
keep_alive:
encoding:
mime: */*
charset:
via:
forwarded:
[root@instance-jb4q99qd ~]# curl ifconfig.me/all.json
{“connection”:””,”ip_addr”:”106.12.26.141″,”lang”:””,”remote_host”:””,”user_agent”:”curl/7.29.0″,”charset”:””,”port”:”43124″,”via”:””,”forwarded”:””,”mime”:”*/*”,”keep_alive”:””,”encoding”:””}
[root@instance-jb4q99qd ~]# curl ifconfig.me/all.xml
<info>
<charset></charset>
<connection></connection>
<encoding></encoding>
<forwarded></forwarded>
<ip_addr>106.12.26.141</ip_addr>
<keep_alive></keep_alive>
<lang></lang>
<mime>*/*</mime>
<port>48870</port>
<remote_host></remote_host>
<user_agent>curl/7.29.0</user_agent>
<via></via>
</info>
[root@instance-jb4q99qd ~]#
【总结】
CentOS 7中查看当前主机:
内网IP:
ifconfig -a
输出结果中的broadcast的部分
此处结果是:192.168.15.255
外网IP:通过访问别的查询网站而获得当前的外网IP,比如:
curl ifconfig.me
或:curl icanhazip.com
此处结果是:106.12.26.141
转载请注明:在路上 » 【已解决】CentOS中如何查看主机的内网IP和外网IP