Linux中ifconfig命令作用有哪些?

Linux中ifconfig命令作用有哪些?,第1张

linux中ifconfig命令属于网络配置命令ifconfig命令被用于配置和显示Linux内核中网络接口的网络参数。用ifconfig命令配置的网卡信息,在网卡重启后机器重启后,配置就不存在。要想将上述的配置信息永远的存的电脑里,那就要修改网卡的配置文件了。语法ifconfig(参数)参数add<地址>:设置网络设备IPv6的ip地址;del<地址>:删除网络设备IPv6的IP地址;down:关闭指定的网络设备;<hw<网络设备类型><硬件地址>:设置网络设备的类型与硬件地址;io_addr<I/O地址>:设置网络设备的I/O地址;irq<IRQ地址>:设置网络设备的IRQ;media<网络媒介类型>:设置网络设备的媒介类型;mem_start<内存地址>:设置网络设备在主内存所占用的起始地址;metric<数目>:指定在计算数据包的转送次数时,所要加上的数目;mtu<字节>:设置网络设备的MTU;netmask<子网掩码>:设置网络设备的子网掩码;tunnel<地址>:建立IPv4与IPv6之间的隧道通信地址;up:启动指定的网络设备;-broadcast<地址>:将要送往指定地址的数据包当成广播数据包来处理;-pointopoint<地址>:与指定地址的网络设备建立直接连线,此模式具有保密功能;-promisc:关闭或启动指定网络设备的promiscuous模式;IP地址:指定网络设备的IP地址;网络设备:指定网络设备的名称。使用功能示例启动关闭指定网卡:ifconfig eth0 upifconfig eth0 downifconfig eth0 up为启动网卡eth0,ifconfig eth0 down为关闭网卡eth0。ssh登陆linux服务器 *** 作要小心,关闭了就不能开启了,除非你有多网卡。为网卡配置和删除IPv6地址:ifconfig eth0 add 33ffe:3240:800:1005::2/64#为网卡eth0配置IPv6地址ifconfig eth0 del 33ffe:3240:800:1005::2/64#为网卡eth0删除IPv6地址用ifconfig修改MAC地址:ifconfig eth0 hw ether 00:AA:BB:CC:dd:EE配置IP地址:[root@localhost ~]# ifconfig eth0 192.168.2.10[root@localhost ~]# ifconfig eth0 192.168.2.10 netmask 255.255.255.0[root@localhost ~]# ifconfig eth0 192.168.2.10 netmask 255.255.255.0 broadcast 192.168.2.255启用和关闭arp协议:ifconfig eth0 arp#开启网卡eth0 的arp协议ifconfig eth0 -arp #关闭网卡eth0 的arp协议设置最大传输单元:ifconfig eth0 mtu 1500#设置能通过的最大数据包大小为 1500 bytes

Linux *** 作系统Ifconfig命令详细解析无论是Linux 自动安装还是我们手工安装,Linux 都会向你询问有关网络的问题并配置相关的软件。这个用于配置网卡的基本命令就是ifconfig。 在执行ifconfig 命令后,系统将在内核表中设置必要的参数,这样Linux 就知道如何与网络上的网卡通信。ifconfig 命令有以下两种格式: ※ifconfig [interface] ※ifconfig interface [aftype] option | address … ifconfig 的第一种格式(或使用不带任何参数的ifconfig 命令)可以用来查看当前系统的网络配置情况。 在刚刚安装完系统之后,实际上是在没有网卡或者网络连接的情况下使用Linux,但通过ifconfig 可以使用回绕方式工作,使计算机认为自己工作在网络上。 现在我们运行一下ifconfig 命令,不带参数的ifconfig 命令可以显示当前启动的网络接口,其输出结果为:

[root@machine1 /sbin]#ifconfig eth0 Link encap:Ethernet Hwaddr 52:54:AB:DD:6F:61 inet addr:210.34.6.89 Bcast:210.34.6.127 Mask:255.255.255.128 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:46299 errors:0 dropped:0 overruns:0 frame:189 TX packets:3057 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:100 Interrupt:5 Base address:0xece0 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:3924 Metric:1 RX packets:44 errors:0 dropped:0 overruns:0 frame:0 TX packets:44 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0

其中以eth0 为首的部分是本机的以太网卡配置参数,这里显示了网卡在下的设备名/dev/eth0 和硬件的MAC 地址52:54:AB:DD:6F:61,MAC 地址是生产厂家定的,每个网卡拥有的唯一地址。 不过我们可以手工改动网卡的MAC 地址,只要我们在/etc/rc.d/init.d/中的network 中加入: ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx 然后重启,此时再用ifconfig 命令查看一下,我们就会发现网卡的MAC 地址已经变成xx:xx:xx:xx:xx:xx了。

后继 常用网卡ip设置方法:

直接通过setup 进行设置。

配置多个网卡 ifconfig -a 查看网络设备 eth0 / eth1 / lo (回路)。

ifconfig eth1 //设备1

ifconfig eth1 192.168.1.10 netmask 255.255.255.0 //设置网卡子网及ip

man ifconfig

ifconfig --help(T002)

ifconfig在linux下可设置网络设备的状态,或是显示当前的设置。

相关参数:

配置网卡相关命令:

1、配置网卡的IP地址:

ifconfig eth0 192.168.0.1 netmask 255.255.255.0

在eth0上配置上192.168.0.1 的IP地址及24位掩码。若想再在eth0上在配置一个192.168.1.1/24 的IP地址,用下面的命令

ifconfig eth0:0 192.168.1.1 netmask 255.255.255.0

这时再用ifconifg命令查看,就可以看到两个网卡的信息了,分别为:eth0和eth0:0.若还想再增加IP,那网卡的命名就接着是:eth0:1、eth0:2……想要几个就填几个。

2、配置网卡的硬件地址:

ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx就将网卡的硬件地址更改了,此时就可以骗过局域网内的IP地址绑定了。

3、将网卡禁用

ifconfig eth0 down/4、将网卡启用

ifconfig eth0 up


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/8665194.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-19
下一篇2023-04-19

发表评论

登录后才能评论

评论列表(0条)

    保存