DHCP

In large enterprise network architecture ,Routers usually cannot assign ip, because that don’t support a service named DHCP.

What does the DHCP mean? That is a service assign ip to every network equipment. We don’t need to config ip to each network equipment.

Knowledge

What does IP?

IP like a network equipment’s ID card. Every equipment have different IP(In public network).Sometimes, we can find some network equipment use the same IP, Why?

  1. They use keepalived to set up Virtual IP (VIP)
  2. They are don’t in the same lan.

For the frist point, That is a HA solution. If one server shut down, another server will preemption that VIP.

Keepalived cluster is depend an agreement named VRRP. If master is normal operation,master will send a VRRP broadcast package ,the slave cant’t preemption that VIP.

For the second point. If you want understand this sentence ,you need get to know what is VLAN and LAN.

VLAN is similar to LAN.LAN can divide to many VLAN. Each vlan cannot be connected to each other. LAN is same ad VLAN ,too.

What does gateway mean?

Gateway is a equipment,which can forward data to Internet.In lan,there is always have one gateway.All network enquiment send data to gateway.so,gateway is the necessary(必须的) part.

What does netmask?

As we know,IP is divided into four segments,they can be expressed as a 32-bit binary number.We can use netmask to regulation which is segment number,which is host number.

What does MAC?

MAC is ethernet drive’s physical address .Like 00:0C:29:E3:2A:D1.Every network equimpent have different MAC.

Install DHCP service

We can use yum to install DHCP.

yum install dhcp

Let me see the dhcp’s config file tree.

[root@localhost network-scripts]# tree /etc/dhcp/
/etc/dhcp/
├── dhclient.d
│   └── chrony.sh
├── dhclient-exit-hooks.d
│   └── azure-cloud.sh
├── dhcpd6.conf
├── dhcpd.conf
└── scripts
    └── README.scripts

We should copy default config file in this directory.

cp /usr/share/doc/dhcp*/dhcpd.conf.example ./dhcpd.conf

Edit that file:

option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;

default-lease-time 600;
max-lease-time 7200;

log-facility local7;

subnet 192.168.89.0 netmask 255.255.255.0 {
  range 192.168.89.100 192.168.89.200;
  option domain-name-servers ns1.internal.example.org;
  option domain-name "internal.example.org";
  option routers 192.168.89.2;
  option broadcast-address 192.168.89.255;
  default-lease-time 600;
  max-lease-time 7200;
}

There is some import key:

“option domain-name” and “option domain-name-services” is bind a domain-name to dhcp service.

lease-time: That is the ip lease time.If the lease expires,DHCP will assign again.

subnet 192.168.89.0 netmask 255.255.255.0: There set the network segment and netmask.

range: That is ip’s range.

option routersand option broadcast-address: There routes have the same mean with gateway.and ,broadcast-address we always use this network segment’s the last ip.

OK,base environment install success.

Bind static ip

We always bind ip to ethernet (MAC).Add a model to dhcpd.conf.

host xp {
hardware ethernet 00:0C:29:E3:2A:D1;
fixed-address 192.168.89.111;
}

We can use any host name you want.but ,that is only allowed to be used once.

hardware ethernetis bind a MAC address.fixed-addressis bind a ip to that MAC.

Restart dhcp and restart slave copmouter network.We can find that IP was changed.

That’s all.

Thanks.

Reference:

[1] Liu Chuan.Linux 就该这么学[M].北京:人民邮电出版社出版,2017年∶270-276

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值