博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
RHEL/CentOS 6 (command line) Networking
阅读量:7263 次
发布时间:2019-06-29

本文共 4439 字,大约阅读时间需要 14 分钟。

参考:

Interface configuration files contol the software interfaces for individual network devices.

RHEL/CentOS 6 does not configure network interfaces on default installation. Also, it is configured to use NetworkManager. To enable networking interface and disable NetworkManager please follow instructions below.

The /etc/sysconfig/network-scripts/ifcfg-eth0 content looks as follows on default installation.

DEVICE=”eth0″

HWADDR=specifc mac address
NM_CONTROLLED=”yes”
ONBOOT=”no

For DHCP, configure the interface as follows.

DEVICE=”eth0″

HWADDR=specifc mac address
NM_CONTROLLED=”no”
ONBOOT=”yes”
BOOTPROTO=”dhcp”

Restart the network after configuration.

/etc/init.d/network restart

or
service network restart

For Static ip, configure it as follows

DEVICE=”eth0″(the name of device that the configuration controls)

HWADDR=specifc mac address(ensure that the interfaces assigned the correct device names regardless of the configured load order for each NIC's module.)
NM_CONTROLLED=”no”(NetworkManager is permitted to configure this device.)
ONBOOT=”yes”(this device should activated at boot-time.)
BOOTPROTO=”static”(boot time protocol.)
IPADDR=ip address here.(IPv4 address.)
NETMASK=netmask here.(netmask value.)

Change the /etc/sysconfig/network to have the GATEWAY.

NETWORKING=yes (networking should be configured)

HOSTNAME=www.linuxbyanish.com
GATEWAY=gateway address here.

Restart the network after configuration.

/etc/init.d/network restart(init.d contains scripts used by System V init tools---SystemVinit.)

To see current ip address information for eth0:-

# ip addr show eth0

To see routing information:

# ip route show

ifconfig command example

Simply type the ifconfig command as follows to display eth0 IP information:

# ifconfig eth0

eth0 Link encap:Ethernet HWaddr b8:ac:6f:65:31:e5

inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::baac:6fff:fe65:31e5/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:308560 errors:0 dropped:0 overruns:0 frame:0
TX packets:217836 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:431112624 (431.1 MB) TX bytes:20994801 (20.9 MB)
Interrupt:17
type the following command to display an IP and its netmask:
# ifconfig eth0 | grep ‘inet addr:’
Sample outputs:
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0

 

What is the difference between /etc/init/ and /etc/init.d/?

/etc/init.d contains scripts used by the System V init tools (SysVinit). This is the traditional service management package for Linux, containing the init program (the first process that is run when the kernel has finished initializing¹) as well as some infrastructure to start and stop services and configure them. Specifically, files in /etc/init.d are shell scripts that respond to start, stop, restart, and (when supported) reload commands to manage a particular service. These scripts can be invoked directly or (most commonly) via some other trigger (typically the presence of a symbolic link in /etc/rc?.d/).

/etc/init contains configuration files used by Upstart. Upstart is a young service management package championed by Ubuntu. Files in /etc/init are configuration files telling Upstart how and when to start, stop, reload the configuration, or query the status of a service. As of lucid, Ubuntu is transitioning from SysVinit to Upstart, which explains why many services come with SysVinit scripts even though Upstart configuration files are preferred. In fact, the SysVinit scripts are processed by a compatibility layer in Upstart.

.d in directory names typically indicates a directory containing many configuration files or scripts for a particular situation (e.g. /etc/apt/sources.list.d contains files that are concatenated to make a virtual sources.list; /etc/network/if-up.d contains scripts that are executed when a network interface is activated). This structure is usually used when each entry in the directory is provided by a different source, so that each package can deposit its own plug-in without having to parse a single configuration file to reference itself. In this case, it just happens that “init” is a logical name for the directory, SysVinit came first and used init.d, and Upstart used plain init for a directory with a similar purpose (it would have been more “mainstream”, and perhaps less arrogant, if they'd used /etc/upstart.d instead).

转载于:https://www.cnblogs.com/qike/p/4657461.html

你可能感兴趣的文章
无盘技术项目案例总结
查看>>
(教学思路 C#之类四)构造方法(静态构造方法、this、方法重载)、析构方法(修改新增)...
查看>>
利用Hibernate Validator实现对Bean的参数验证
查看>>
Android开发学习笔记:浅谈3大类菜单
查看>>
Are you sure you want to continue connecting etc ssh ssh_config StrictHostKeyChecking no
查看>>
分享Silverlight/WPF/Windows Phone一周学习导读(3月14日-3月19日)
查看>>
CPython 和IronPython的基准测试
查看>>
MongoDB assertion: 18 { code: 18, ok: 0.0, errmsg: "auth fails" }
查看>>
CIO想做好信息化头领 不妨学学梁山宋江
查看>>
DOM方法操作HTML属性
查看>>
利用ntdsutil创建活动目录安装媒体
查看>>
配置MVC模式WebApplication及应用上下文关联的方法
查看>>
Asp.net中的AJAX学习记录之二 体会AJAX页面刷新的不同(初体验)
查看>>
输入的命令集锦
查看>>
非域环境下安装并配置Project Server 2007(四)
查看>>
Oracle 11g RAC安装注意事项杂记
查看>>
Nginx替换apache的实施方案二
查看>>
防止死机二十四招
查看>>
使用C#获取CPU及硬盘序列号的源代码
查看>>
网络编程释疑之:TCP半开连接的处理
查看>>