Centos/Linux下如何查看网关地址/Gateway地址? Linux下查看网关的命令还是很多的,不过如果IP是DHCP获取,那么有些命令是不适用的,当然也有通用的查询网关命令.
1.ifconfig -a 和 cat /etc/resolv.conf (主要查看ip/netmask和dns)
2.netstat -rn
3.cat /etc/sysconfig/network
4.cat /etc/sysconfig/network-scripts/ifcfg-eth0
5.traceroute 第一行就是自己的网关
6.ip route show
7.route -n
以上几个是比较常用的查询网关的命令。下面是范例:
[root@localhost]# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
184.82.152.96 0.0.0.0 255.255.255.248 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 184.82.152.97 0.0.0.0 UG 0 0 0 eth0
[root@localhost]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Intel Corporation 82567V-2 Gigabit Network Connection
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:1c:c0:f8:a1:ac
ONBOOT=yes
NETMASK=255.255.255.248
IPADDR=184.82.152.98
GATEWAY=184.82.152.97
TYPE=Ethernet
[root@localhost]# ip route show
184.82.152.96/29 dev eth0 proto kernel scope link src 184.82.152.98
169.254.0.0/16 dev eth0 scope link
default via 184.82.152.97 dev eth0
[root@localhost]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
184.82.152.96 0.0.0.0 255.255.255.248 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 184.82.152.97 0.0.0.0 UG 0 0 0 eth0
[root@localhost]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:1C:C0:F8:A1:AC
inet addr:184.82.152.98 Bcast:184.82.152.103 Mask:255.255.255.248
8、开启/关闭IPv6功能:
[root@ ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.112.141 netmask 255.255.255.0 broadcast 192.168.112.255
inet6 fe80::bf36:72fd:ae66:3183 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:0b:28:95 txqueuelen 1000 (Ethernet)
RX packets 18149 bytes 1189590 (1.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2382 bytes 219015 (213.8 KiB)
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 68 bytes 5908 (5.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 68 bytes 5908 (5.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@ ~]#
[root@ ~]#echo 1 >/proc/sys/net/ipv6/conf/all/disable_ipv6 #"1"表示关闭,"0"表示开启
[root@ ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.112.141 netmask 255.255.255.0 broadcast 192.168.112.255
ether 00:0c:29:0b:28:95 txqueuelen 1000 (Ethernet)
RX packets 18316 bytes 1203647 (1.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2474 bytes 229999 (224.6 KiB)
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
loop txqueuelen 1 (Local Loopback)
RX packets 68 bytes 5908 (5.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 68 bytes 5908 (5.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@ ~]#
echo 1 >/proc/sys/net/ipv6/conf/all/disable_ipv6 #"1"表示关闭,"0"表示开启 该方法是临时生效,一旦机器重启就失效,如果要使系统永久生效,则需要修改grub文件,
具体操作如下:
然后执行命令"grub2-mkconfig -o /boot/grub2/grub.cfg",重启系统,再验证ipv6模块是否启用
[root@server02 ~]# lsmod|grep ipv6
[root@server02 ~]#
[root@server02 ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.112.141 netmask 255.255.255.0 broadcast 192.168.112.255
ether 00:0c:29:0b:28:95 txqueuelen 1000 (Ethernet)
RX packets 409 bytes 40194 (39.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 299 bytes 41149 (40.1 KiB)
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
loop txqueuelen 1 (Local Loopback)
RX packets 4 bytes 340 (340.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4 bytes 340 (340.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@server02 ~]#
通过以上操作即达到永久禁止ipv6模块使用。
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com