pve系统盘扩容、网络IP设置、端口映射、DHCP服务器

随笔1个月前发布 赵禹钧
3 0 0

pve系统盘扩容

fdisk /dev/vda
输入n然后按几下回车直到提示Created a new partition
最后输入w退出

pvcreate /dev/vda4
vgextend pve /dev/vda4
vgs  #查看可用容量
lvresize -r -L+40G /dev/pve
lvs   #查看lv卷大小

在Datacenter -> pve -> System -> Network
Create一个新的Linux Bridge
设置好IP地址

iptables -t nat -A POSTROUTING -s 10.39.99.0/24 -o vmbr0 -j MASQUERADE

wget -q -O iptables-sync.sh https://api.xiangxisheng.cn/iptables/sync.sh && sh iptables-sync.sh 1
可以放到计划任务里自动执行

# m h  dom mon dow   command
* * * * * wget -q -O iptables-sync.sh https://api.xiangxisheng.cn/iptables/sync.sh && bash iptables-sync.sh 1 >>/tmp/iptables-sync.log

 

IPv4的DHCP

subnet 10.39.99.0 netmask 255.255.255.0 {
  range 10.39.99.101 10.39.99.199;
  option routers 10.39.99.1;
}

 用PHP编写一个能够生成静态IP绑定的脚本

<?php
$ipv4 = '10.39.99.1';
$aIpv4 = explode('.', $ipv4);
$aMAC = array();
$aMAC[] = '00';
$aMAC[] = '00';
foreach ($aIpv4 as $s) {
    $aMAC[] = str_pad(dechex(intval($s)), 2, '0', STR_PAD_LEFT);
}
for ($i = 1; $i <= 99; $i++) {
    $aMAC[5] = str_pad(dechex($i), 2, '0', STR_PAD_LEFT);
    $aIpv4[3] = $i;
?>
host host-<?=$i?> { hardware ethernet <?=implode(':', $aMAC)?>; fixed-address <?=implode('.', $aIpv4)?>;}
<?php
}

生成的结果如下

host host-1 { hardware ethernet 00:00:0a:27:63:01; fixed-address 10.39.99.1;}
host host-2 { hardware ethernet 00:00:0a:27:63:02; fixed-address 10.39.99.2;}
host host-3 { hardware ethernet 00:00:0a:27:63:03; fixed-address 10.39.99.3;}
host host-4 { hardware ethernet 00:00:0a:27:63:04; fixed-address 10.39.99.4;}
host host-5 { hardware ethernet 00:00:0a:27:63:05; fixed-address 10.39.99.5;}
host host-6 { hardware ethernet 00:00:0a:27:63:06; fixed-address 10.39.99.6;}
host host-7 { hardware ethernet 00:00:0a:27:63:07; fixed-address 10.39.99.7;}
host host-8 { hardware ethernet 00:00:0a:27:63:08; fixed-address 10.39.99.8;}
host host-9 { hardware ethernet 00:00:0a:27:63:09; fixed-address 10.39.99.9;}
host host-10 { hardware ethernet 00:00:0a:27:63:0a; fixed-address 10.39.99.10;}
host host-11 { hardware ethernet 00:00:0a:27:63:0b; fixed-address 10.39.99.11;}
host host-12 { hardware ethernet 00:00:0a:27:63:0c; fixed-address 10.39.99.12;}
host host-13 { hardware ethernet 00:00:0a:27:63:0d; fixed-address 10.39.99.13;}
host host-14 { hardware ethernet 00:00:0a:27:63:0e; fixed-address 10.39.99.14;}
host host-15 { hardware ethernet 00:00:0a:27:63:0f; fixed-address 10.39.99.15;}
host host-16 { hardware ethernet 00:00:0a:27:63:10; fixed-address 10.39.99.16;}
host host-17 { hardware ethernet 00:00:0a:27:63:11; fixed-address 10.39.99.17;}
host host-18 { hardware ethernet 00:00:0a:27:63:12; fixed-address 10.39.99.18;}
host host-19 { hardware ethernet 00:00:0a:27:63:13; fixed-address 10.39.99.19;}
host host-20 { hardware ethernet 00:00:0a:27:63:14; fixed-address 10.39.99.20;}
host host-21 { hardware ethernet 00:00:0a:27:63:15; fixed-address 10.39.99.21;}
host host-22 { hardware ethernet 00:00:0a:27:63:16; fixed-address 10.39.99.22;}
host host-23 { hardware ethernet 00:00:0a:27:63:17; fixed-address 10.39.99.23;}
host host-24 { hardware ethernet 00:00:0a:27:63:18; fixed-address 10.39.99.24;}
host host-25 { hardware ethernet 00:00:0a:27:63:19; fixed-address 10.39.99.25;}
host host-26 { hardware ethernet 00:00:0a:27:63:1a; fixed-address 10.39.99.26;}
host host-27 { hardware ethernet 00:00:0a:27:63:1b; fixed-address 10.39.99.27;}
host host-28 { hardware ethernet 00:00:0a:27:63:1c; fixed-address 10.39.99.28;}
host host-29 { hardware ethernet 00:00:0a:27:63:1d; fixed-address 10.39.99.29;}
host host-30 { hardware ethernet 00:00:0a:27:63:1e; fixed-address 10.39.99.30;}
host host-31 { hardware ethernet 00:00:0a:27:63:1f; fixed-address 10.39.99.31;}
host host-32 { hardware ethernet 00:00:0a:27:63:20; fixed-address 10.39.99.32;}
host host-33 { hardware ethernet 00:00:0a:27:63:21; fixed-address 10.39.99.33;}
host host-34 { hardware ethernet 00:00:0a:27:63:22; fixed-address 10.39.99.34;}
host host-35 { hardware ethernet 00:00:0a:27:63:23; fixed-address 10.39.99.35;}
host host-36 { hardware ethernet 00:00:0a:27:63:24; fixed-address 10.39.99.36;}
host host-37 { hardware ethernet 00:00:0a:27:63:25; fixed-address 10.39.99.37;}
host host-38 { hardware ethernet 00:00:0a:27:63:26; fixed-address 10.39.99.38;}
host host-39 { hardware ethernet 00:00:0a:27:63:27; fixed-address 10.39.99.39;}
host host-40 { hardware ethernet 00:00:0a:27:63:28; fixed-address 10.39.99.40;}
host host-41 { hardware ethernet 00:00:0a:27:63:29; fixed-address 10.39.99.41;}
host host-42 { hardware ethernet 00:00:0a:27:63:2a; fixed-address 10.39.99.42;}
host host-43 { hardware ethernet 00:00:0a:27:63:2b; fixed-address 10.39.99.43;}
host host-44 { hardware ethernet 00:00:0a:27:63:2c; fixed-address 10.39.99.44;}
host host-45 { hardware ethernet 00:00:0a:27:63:2d; fixed-address 10.39.99.45;}
host host-46 { hardware ethernet 00:00:0a:27:63:2e; fixed-address 10.39.99.46;}
host host-47 { hardware ethernet 00:00:0a:27:63:2f; fixed-address 10.39.99.47;}
host host-48 { hardware ethernet 00:00:0a:27:63:30; fixed-address 10.39.99.48;}
host host-49 { hardware ethernet 00:00:0a:27:63:31; fixed-address 10.39.99.49;}
host host-50 { hardware ethernet 00:00:0a:27:63:32; fixed-address 10.39.99.50;}
host host-51 { hardware ethernet 00:00:0a:27:63:33; fixed-address 10.39.99.51;}
host host-52 { hardware ethernet 00:00:0a:27:63:34; fixed-address 10.39.99.52;}
host host-53 { hardware ethernet 00:00:0a:27:63:35; fixed-address 10.39.99.53;}
host host-54 { hardware ethernet 00:00:0a:27:63:36; fixed-address 10.39.99.54;}
host host-55 { hardware ethernet 00:00:0a:27:63:37; fixed-address 10.39.99.55;}
host host-56 { hardware ethernet 00:00:0a:27:63:38; fixed-address 10.39.99.56;}
host host-57 { hardware ethernet 00:00:0a:27:63:39; fixed-address 10.39.99.57;}
host host-58 { hardware ethernet 00:00:0a:27:63:3a; fixed-address 10.39.99.58;}
host host-59 { hardware ethernet 00:00:0a:27:63:3b; fixed-address 10.39.99.59;}
host host-60 { hardware ethernet 00:00:0a:27:63:3c; fixed-address 10.39.99.60;}
host host-61 { hardware ethernet 00:00:0a:27:63:3d; fixed-address 10.39.99.61;}
host host-62 { hardware ethernet 00:00:0a:27:63:3e; fixed-address 10.39.99.62;}
host host-63 { hardware ethernet 00:00:0a:27:63:3f; fixed-address 10.39.99.63;}
host host-64 { hardware ethernet 00:00:0a:27:63:40; fixed-address 10.39.99.64;}
host host-65 { hardware ethernet 00:00:0a:27:63:41; fixed-address 10.39.99.65;}
host host-66 { hardware ethernet 00:00:0a:27:63:42; fixed-address 10.39.99.66;}
host host-67 { hardware ethernet 00:00:0a:27:63:43; fixed-address 10.39.99.67;}
host host-68 { hardware ethernet 00:00:0a:27:63:44; fixed-address 10.39.99.68;}
host host-69 { hardware ethernet 00:00:0a:27:63:45; fixed-address 10.39.99.69;}
host host-70 { hardware ethernet 00:00:0a:27:63:46; fixed-address 10.39.99.70;}
host host-71 { hardware ethernet 00:00:0a:27:63:47; fixed-address 10.39.99.71;}
host host-72 { hardware ethernet 00:00:0a:27:63:48; fixed-address 10.39.99.72;}
host host-73 { hardware ethernet 00:00:0a:27:63:49; fixed-address 10.39.99.73;}
host host-74 { hardware ethernet 00:00:0a:27:63:4a; fixed-address 10.39.99.74;}
host host-75 { hardware ethernet 00:00:0a:27:63:4b; fixed-address 10.39.99.75;}
host host-76 { hardware ethernet 00:00:0a:27:63:4c; fixed-address 10.39.99.76;}
host host-77 { hardware ethernet 00:00:0a:27:63:4d; fixed-address 10.39.99.77;}
host host-78 { hardware ethernet 00:00:0a:27:63:4e; fixed-address 10.39.99.78;}
host host-79 { hardware ethernet 00:00:0a:27:63:4f; fixed-address 10.39.99.79;}
host host-80 { hardware ethernet 00:00:0a:27:63:50; fixed-address 10.39.99.80;}
host host-81 { hardware ethernet 00:00:0a:27:63:51; fixed-address 10.39.99.81;}
host host-82 { hardware ethernet 00:00:0a:27:63:52; fixed-address 10.39.99.82;}
host host-83 { hardware ethernet 00:00:0a:27:63:53; fixed-address 10.39.99.83;}
host host-84 { hardware ethernet 00:00:0a:27:63:54; fixed-address 10.39.99.84;}
host host-85 { hardware ethernet 00:00:0a:27:63:55; fixed-address 10.39.99.85;}
host host-86 { hardware ethernet 00:00:0a:27:63:56; fixed-address 10.39.99.86;}
host host-87 { hardware ethernet 00:00:0a:27:63:57; fixed-address 10.39.99.87;}
host host-88 { hardware ethernet 00:00:0a:27:63:58; fixed-address 10.39.99.88;}
host host-89 { hardware ethernet 00:00:0a:27:63:59; fixed-address 10.39.99.89;}
host host-90 { hardware ethernet 00:00:0a:27:63:5a; fixed-address 10.39.99.90;}
host host-91 { hardware ethernet 00:00:0a:27:63:5b; fixed-address 10.39.99.91;}
host host-92 { hardware ethernet 00:00:0a:27:63:5c; fixed-address 10.39.99.92;}
host host-93 { hardware ethernet 00:00:0a:27:63:5d; fixed-address 10.39.99.93;}
host host-94 { hardware ethernet 00:00:0a:27:63:5e; fixed-address 10.39.99.94;}
host host-95 { hardware ethernet 00:00:0a:27:63:5f; fixed-address 10.39.99.95;}
host host-96 { hardware ethernet 00:00:0a:27:63:60; fixed-address 10.39.99.96;}
host host-97 { hardware ethernet 00:00:0a:27:63:61; fixed-address 10.39.99.97;}
host host-98 { hardware ethernet 00:00:0a:27:63:62; fixed-address 10.39.99.98;}
host host-99 { hardware ethernet 00:00:0a:27:63:63; fixed-address 10.39.99.99;}

 

 

 IPv6

subnet6 fe80:1::/64 {
        range6 fe80:1::/64;
}

 

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...