Linux常用命令库
apachectl
grep
openssl
mdadm
groupmems
grub2-mkconfig
grub2-set-default
accept
groupadd
passwd
apk
gpm
paste
7z
grpconv
patch
ag
groupmod
pathchk
ack
grub
perl
arp
groupdel
objdump
atrm
gunzip
pfctl
atq
grpck
pgrep
axel
grpunconv
parted
ab
groups
partprobe
badblocks
halt
php
apt-key
gzip
od
apt-get
head
pigz
apt-sortpkgs
gzexe
pico
apropos
history
pidof
atop
help
pidstat
break
lastlog
ping
aptitude
hexdump
pkill
bg
ldconfig
ntsysv
arch
host
pmap
arpd
hostid
rpm2cpio
arpwatch
htop
ppp-off
as
hostnamectl
poweroff
arptables
hping3
rsync
ar
lilo
pr
arping
ifcfg
script
bzip2recover
htdigest
pssh
cal
hostname
printf
cancel
id
reject
arj
htpasswd
protoize
cd
hwclock
popd
chcon
lpr
pstree
base64
lsblk
pv
batch
iconv
sftp
chgrp
indent
ps
basename
ifconfig
slocate
chmod
ifstat
pstack
bc
ifup
pushd
chown
hdparm
pvscan
blockdev
mkdir
pwd
at
mkinitrd
pwck
builtin
info
pvck
chpasswd
ifdown
pvchange
chroot
iptables
pwconv
bind
mpstat
pvs
bmodinfo
iostat
pvdisplay
cksum
iftop
pvcreate
bye
inotifywait
sshd
bzgrep
ip6tables-restore
pwunconv
chsh
ip
quotacheck
bzcmp
insmod
rcconf
bzcat
ip6tables-save
quota
bzdiff
iotop
rcp
col
init
repquota
clockdiff
install
pvremove
bzip2
ip6tables
restorecon
command
iptables-save
read
comm
ncftp
quotaoff
bzless
ipcrm
return
cmp
ipcs
rev
consoletype
iptstate
quotaon
bunzip2
ipcalc
rename
cat
iperf
resize
bzmore
netstat
readonly
cdrecord
iptables-restore
rmdir
blkid
nice
rexec
cp
jed
restore
cpio
ispell
reboot
chage
jobs
rm
chattr
joe
rlogin
cu
jq
rmmod
chkconfig
kexec
tee
cupsenable
join
rpmbuild
date
iptraf
runlevel
cupsdisable
kernelversion
rpmdb
clear
kill
rsh
clock
jwhois
rpm
chfn
journalctl
scp
dd
lastb
sar
declare
last
route
compress
ld
times
depmod
ln
tftp
alias
let
rpmverify
dc
killall
service
continue
ldd
rpmsign
df
lha
screen
convertquota
lftp
sesearch
dhclient
locate
semanage
dhcpd
less
seinfo
dhcrelay
lftpget
scriptreplay
diff
logger
seq
diffstat
local
setfacl
dig
logsave
readelf
diff3
lp
sed
csplit
logout
sendmail
crontab
logname
rpmquery
dirname
login
set
dirs
lsattr
sftp-server
cut
lvremove
renice
domainname
losetup
setpci
dos2unix
lpadmin
setsid
dpkg-deb
lpc
sysctl
colrm
lnstat
shift
dpkg-preconfigure
look
shutdown
dnsdomainname
logwatch
sh
dpkg-query
lynx
shuf
dpkg-reconfigure
lpq
updatedb
dpkg
lscpu
skill
dpkg-divert
logrotate
shopt
dpkg-statoverride
lpstat
setsebool
dpkg-trigger
lvresize
showmount
dmidecode
gpasswd
tcpreplay
dstat
lprm
slabtop
e2fsck
lvdisplay
squid
du
mail
sort
dircolors
lspci
speedtest-cli
disown
lsof
smbclient
e2label
mesg
vgscan
dump
mailq
split
egrep
ltrace
vdfuse
eject
lsusb
sleep
echo
make
ss
ed
lsmod
ssh-agent
elm
lvcreate
sudo
emacs
mkbootdisk
strings
edquota
lvreduce
spell
ex
lvscan
tmux
exec
mkfs
znew
enable
lsb_release
xrandr
ethtool
nethogs
unarj
elinks
nologin
swapoff
dmesg
neofetch
tar
dris
mke2fs
touch
expand
nslookup
zcat
dpkg-split
md5sum
ssh
export
man
ssh-add
exit
mknod
syslog
dnf
mii-tool
userdel
false
mysqladmin
ssh-copy-id
fdisk
mailstat
ssh-keyscan
find
modprobe
squidclient
fgrep
mkswap
smbpasswd
expr
mtools
source
finger
mkisofs
suspend
env
mapfile
ssh-keygen
fishshell
mktemp
startx
fmt
mysql
swapon
firewall-cmd
more
stty
fping
mv
tail
ftp
nc
talk
file
mount
systemctl
fold
named-checkzone
stat
fc
lvextend
supervisord
gcc
mysqlimport
systool
findfs
mysqldump
sync
fsck
nano
tailf
fg
nl
tac
exportfs
ngrep
su
get_module
newusers
tcpdump
gcov
mysqlshow
test
getsebool
nmcli
zipsplit
gdb
nisdomainname
telinit
free
nmap
tracepath
curl
ntpdate
sum
ftpcount
nm
timedatectl
getenforce
nproc
trap
ftpshut
nfsstat
unlink
ftpwho
nohup
unrar
git
ls
unprotoize
ftptop
type
awk
watch
fuser
ulimit
telnet
whatis
yum
xlsatoms
uucico
xz
tty
wget
uptime
xinit
whoami
xhost
xauth
uname
who
usernetctl
tree
vgreduce
vi
xclip
which
xset
zfore
tempfile
zipinfo
strace
tput
umask
time
umount
unalias
uncompress
whereis
usermod
unset
unexpand
users
uupick
ypdomainname
write
yes
xargs
useradd
uuto
true
unzip
vgdisplay
vgconvert
vgchange
vgremove
vgcreate
vgextend
vgrename
xlsfonts
zip
uniq
tload
xlsclients
traceroute
tr
volname
wall
vmstat
wait
top
w
wc
私有云知识库
-
+
首页
ifconfig
ifconfig === 配置和显示Linux系统网卡的网络参数 ## 补充说明 **ifconfig命令** 被用于配置和显示Linux内核中网络接口的网络参数。用ifconfig命令配置的网卡信息,在网卡重启后机器重启后,配置就不存在。要想将上述的配置信息永远的存的电脑里,那就要修改网卡的配置文件了。 ### 语法 ```shell ifconfig(参数) ``` ### 参数 ```shell 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地址; 网络设备:指定网络设备的名称。 ``` ### 实例 **显示网络设备信息(激活状态的):** ```shell [root@localhost ~]# ifconfig eth0 Link encap:Ethernet HWaddr 00:16:3E:00:1E:51 inet addr:10.160.7.81 Bcast:10.160.15.255 Mask:255.255.240.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:61430830 errors:0 dropped:0 overruns:0 frame:0 TX packets:88534 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:3607197869 (3.3 GiB) TX bytes:6115042 (5.8 MiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:56103 errors:0 dropped:0 overruns:0 frame:0 TX packets:56103 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:5079451 (4.8 MiB) TX bytes:5079451 (4.8 MiB) ``` 说明: **eth0** 表示第一块网卡,其中`HWaddr`表示网卡的物理地址,可以看到目前这个网卡的物理地址(MAC地址)是`00:16:3E:00:1E:51`。 **inet addr** 用来表示网卡的IP地址,此网卡的IP地址是`10.160.7.81`,广播地址`Bcast:10.160.15.255`,掩码地址`Mask:255.255.240.0`。 **lo** 是表示主机的回坏地址,这个一般是用来测试一个网络程序,但又不想让局域网或外网的用户能够查看,只能在此台主机上运行和查看所用的网络接口。比如把 httpd服务器的指定到回坏地址,在浏览器输入127.0.0.1就能看到你所架WEB网站了。但只是您能看得到,局域网的其它主机或用户无从知道。 * 第一行:连接类型:Ethernet(以太网)HWaddr(硬件mac地址)。 * 第二行:网卡的IP地址、子网、掩码。 * 第三行:UP(代表网卡开启状态)RUNNING(代表网卡的网线被接上)MULTICAST(支持组播)MTU:1500(最大传输单元):1500字节。 * 第四、五行:接收、发送数据包情况统计。 * 第七行:接收、发送数据字节数统计信息。 **启动关闭指定网卡:** ```shell ifconfig eth0 up ifconfig eth0 down ``` `ifconfig eth0 up`为启动网卡eth0,`ifconfig eth0 down`为关闭网卡eth0。ssh登陆linux服务器操作要小心,关闭了就不能开启了,除非你有多网卡。 **为网卡配置和删除IPv6地址:** ```shell ifconfig eth0 add 33ffe:3240:800:1005::2/64 #为网卡eth0配置IPv6地址 ifconfig eth0 del 33ffe:3240:800:1005::2/64 #为网卡eth0删除IPv6地址 ``` **用ifconfig修改MAC地址:** ```shell ifconfig eth0 hw ether 00:AA:BB:CC:dd:EE ``` **配置IP地址:** ```shell [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协议:** ```shell ifconfig eth0 arp #开启网卡eth0 的arp协议 ifconfig eth0 -arp #关闭网卡eth0 的arp协议 ``` **设置最大传输单元:** ```shell ifconfig eth0 mtu 1500 #设置能通过的最大数据包大小为 1500 bytes ``` **其它实例** ```shell ifconfig #处于激活状态的网络接口 ifconfig -a #所有配置的网络接口,不论其是否激活 ifconfig eth0 #显示eth0的网卡信息 ```
admin
2022年9月16日 07:00
59
0 条评论
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
Markdown文件
PDF文档
PDF文档(打印)
分享
链接
类型
密码
更新密码