
正文
linux中pf命令 f linux命令
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
如何使用Linux命令dhclient
如何使用Linux命令
dhclient
The
Internet Systems Consortium DHCP Client, dhclient, provides a means for
configuring one or more network interfaces using the Dynamic Host Configuration
Protocol, BOOTP protocol, or if these protocols fail, by statically assigning an
address.
linux
dhclient 的语法
dhclient
[ -p port ] [ -d ] [ -e VAR=value ] [ -q ] [ -1 ] [ -r ] [ -lf lease-file ] [
-pf pid-file ] [ -cf config-file ] [ -sf script-file ] [ -e ENVVAR=value ] [ -s
server ] [ -g relay ] [ -n ] [ -nw ] [ -w ] [ if0 [ ...ifN ] ]
-p port
If the DHCP client should listen and transmit on a port other
than the standard (port 68), the -p flag may used. It should be followed by the
udp port number that dhclient should use. This is mostly useful for debugging
purposes. If a different port is specified for the client to listen on and
transmit on, the client will also use a different destination port - one greater
than the specified destination port.
-s
The DHCP client normally transmits any protocol messages it sends
before acquiring an IP address to, 255.255.255.255, the IP limited broadcast
address. For debugging purposes, it may be useful to have the server transmit
these messages to some other address. This can be specified with the -s flag,
followed by the IP address or domain name of the destination.
-g
For testing purposes, the giaddr field of all packets that the
client sends can be set using the -g flag, followed by the IP address to send.
This is only useful for testing, and should not be expected to work in any
consistent or useful way.
-d
The DHCP client will normally run in the foreground until it has
configured an interface, and then will revert to running in the background. To
run force dhclient to always run as a foreground process, the -d flag should be
specified. This is useful when running the client under a debugger, or when
running it out of inittab on System V systems.
-e
The dhclient daemon creates its own environment when executing
the dhclient-script to do the grunt work of interface configuration. To define
extra environment variables and their values, use the -e flag, followed by the
environment variable name and value assignment, just as one would assign a
variable in a shell. Eg: -e IF_METRIC=1
-r
The client normally doesn't release the current lease as it is
not required by the DHCP protocol. Some cable ISPs require their clients to
notify the server if they wish to release an assigned IP address. The -r flag
explicitly releases the current lease, and once the lease has been released, the
client exits.
-1
The -1 flag cause dhclient to try once to get a lease. If it
fails, dhclient exits with exit code two.
-cf, -lf, -pf, and -sf
The DHCP client normally gets its configuration information from
/etc/dhcp3/dhclient.conf, its lease database from
/var/lib/dhcp3/dhclient.leases, stores its process ID in a file called
/var/run/dhclient.pid, and configures the network interface using
/sbin/dhclient-script To specify different names and/or locations for these
files, use the -cf, -lf, -pf and -sf flags, respectively, followed by the name
of the file. This can be particularly useful if, for example, /var/lib/dhcp3 or
/var/run has not yet been mounted when the DHCP client is started.
-w
The DHCP client normally exits if it isn't able to identify any
network interfaces to configure. On laptop computers and other computers with
hot-swappable I/O buses, it is possible that a broadcast interface may be added
after system startup. The -w flag can be used to cause the client not to exit
when it doesn't find any such interfaces. The omshell (1) program can then be
used to notify the client when a network interface has been added or removed, so
that the client can attempt to configure an IP address on that
interface.
-n
The DHCP client can be directed not to attempt to configure any
interfaces using the -n flag. This is most likely to be useful in combination
with the -w flag.
-nw
The client can also be instructed to become a daemon immediately,
rather than waiting until it has acquired an IP address. This can be done by
supplying the -nw flag.
-e
The client runs child processes (scripts) with a clean
environment. Use the -e flag to specify additional environment variables to pass
to child processes.
linux
dhclient 的演示示例:
dhclient
eth0
Renews
the IP address.
Linux
renew ip command
$
sudo dhclient -r //release ip 释放IP
$
sudo dhclient //获取IP
相关问答
Q1: 在MacOS上使用1024以下端口
MacOS和Linux一样,需要root权限使用低于1024以下端口。因此要在Mac机器上监听80端口或443端口,要么以root用户启动应用,要么使用端口转发。
在Linux系统中可以通过 sudo setcap cap_net_bind_service=+ep app name 来让非root用户使用1024以下端口(app name指要授权监听端口的程序)。
MacOS没有 setcap 命令,所以需要通过端口转发来达到目的。新版的MacOS操作系统使用pf(packet filter)设置端口转发。
⚠️注意,以下示例端口有重复。
示例一:
/etc/pf.anchors/http
示例二:
/etc/pf.anchors/tomcat
示例三:
/etc/pf.anchors/virtualbox
pf启动时会自动装载 /etc/pf.conf 文件,因此将anchor文件链接到 /etc/pf.conf ,转发规则就会自动建立了。 pf.conf 对指令的顺序有严格要求,相同的指令需要放在一起,否则会报错 Rules must be in order: options, normalization, queueing, translation, filtering.
pf默认是关闭的。可以使用以下命令启动pf:
使用 -e 命令启用 pf 服务。使用 -E 命令强制重启 pf 服务:
使用 -d 命令关闭 pf:
修改 LaunchDaemons ( 《了解LaunchDaemons》 )来使 pf 开机自动打开
添加的为-e参数,即enable。 有一点一定要注意,-f和 etc/pf.conf 这两个参数不能被打断,因为-f必须紧跟一个文件参数,所以说添加-e参数时不要打断-f参数,否则开机不会自动启动pf,切记。
如果需要跨接口转发,则需设置系统参数: /etc/sysctl.conf
开机启动配置,需以 root 身份添加或修改 /etc/sysctl.conf 文件,加入以下两行:
开启端口转发之后,即可配置端口转发规则。你可以跟着手册来:
Q2: 在Linux中,如何从ext3文件系统转至ext4文件系统.(不破坏数据).
您好: Linux文件系统从ext3升级到ext4
尽管
ext4
出来已经有一段时间linux中pf命令了linux中pf命令,由于有一些
bug
还没被大量应用到服务器生产环境中linux中pf命令,不过对于桌面用户来说
ext4
已经足够成熟了。去年发布linux中pf命令的最新
RHEL
5.4
版本默认文件系统依然是
ext3。
最近
Linux
内核开发人员、ext4
文件系统的维护者
Ted
Ts’o
跳槽到
Google,并在
继续从事
ext4
的研发和
Linux
kernel
方面的工作。在一篇
mailing
list
里,Google
工程师
Michael
Rubin
也提到了一些
内部使用
ext4
的情况。经过
内部测试,ext4
和高性能的
xfs
文件系统性能很接近,Google
选择
ext4
而不是
xfs
的主要原因是因为他们的现有系统是
ext2,这样升级到
ext4
会更容易一些。还有一个有意思的地方是,大多数人对
dbench
很信任,选用
dbench
来做文件系统的测试工具。如何从
ext3
升级到
ext4linux中pf命令?首先需要确保
Linux
kernel
是支持
ext4
的,其次要注意
/boot
分区最好使用
ext3,因为现在系统上的
grub
很可能不支持
ext4,需要有这个
commit
的特别版本
grub
才能支持
ext4.
用下面的命令转换:#
cd
/;
umount
/dev/sda1#
tune2fs
-O
extents,uninit_bg,dir_index
/dev/sda1记住,转换成
ext4
后必须用
fsck
扫描,否则不能
mount,-p
参数说明
“自动修复”
文件系统:#
fsck
-pf
/dev/sda1挂载
ext4
文件系统:#
mount
-t
ext4
/dev/sda1
/path/to/
Q3: 用c语言编写一个linux程序:通过find一个文件名,系统给一个路径,然后用c语言展开这个路径
#include stdio.h
#include stdlib.h
#include string.h
int main(int argc, char *argv[])
{
char file_name[64] = {0};
char file_path[128] = {0};
char dir_path[64] = {0};
char cmd[256] = {0};
int re = 0;
FILE *pf = NULL;
char *p = NULL;
printf("请输入文件名:\n");
scanf("%s", file_name);
snprintf(cmd, 256, "find -name %s tmp.txt", file_name);//如果文件不在程序运行的本地目录(或者子目录)下,则需要改成find / -name xxxx 但耗时会很长
system(cmd);
//文件中取绝对路径
pf = fopen("tmp.txt", "r");
if (pf)
{
re = fscanf(pf, "%s", file_path);//只取第一行 也就是默认不存在同名文件
if (-1 == re)
{
printf("err0\n");
return 0;
}
else
{
flcose(pf);
pf = NULL;
}
}
else
{
printf("err1\n");
return 0;
}
if (0 == strlen(file_path))
{
printf("err2\n");
return 0;
}
//获取目录名
p = strstr(file_path, file_name);
if (p)
{
*p = '\0';
strcpy(dir_path, file_path);//也可以不cp直接用file_path
}
//通过c语言展开ls这个路径c语言变量 其实我没有理解这句话... 先这么做吧
snprintf(cmd, 256, "ls %s", dir_path);
system(cmd);
return 0;
}
如果哪里有异常就加printf打印出来各个变量
Q4: 怎么结束 linux /pfdump
dump命令用于备份ext2或者ext3文件系统。可将目录或整个文件系统备份至指定的设备,或备份成一个大文件。 命令格式:dump [选项] [参数] 需要备份的文件 常用选项即参数: -[0-9]:备份的层级 -f 设备名称:指定备份设备
Q5: 如何在Linux系统下,用PF
这些是tar打包工具的选项,现在tar都集成了gzip和bzip的功能 没有zxpf吧。 -c 建立新的归档文件 -r 向归档文件末尾追加文件 -x 从归档文件中解出文件 -O 将文件解开到标准输出 -v 处理过程中输出相关信息 -f 对普通文件操作 -z 调用gzip来压缩归...
linux中pf命令的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于f linux命令、linux中pf命令的信息别忘了在本站进行查找喔。







