我使用旧笔记本电脑作为无线网桥将三个工作站连接到互联网。我在笔记本电脑上安装了Scientific Linux 6.6,并使用NetworkManager将它的eth0设备共享到工作站。
我想知道是否有一种优雅的方法可以确保NetworkManager根据其MAC地址为每个工作站分配静态IP地址?
我的理解是NetworkManager使用dnsmasq作为dhcp服务器。我曾与/etc/dnsmasq.conf
玩过但没有任何成功。启动dnsmasq时,NetworkManager似乎使用了一些其他配置文件。
我们将不胜感激。
答案 0 :(得分:0)
我使用Ubuntu,其中可以通过reorder.show();
Scientific Linux似乎是从RedHat派生的,而RedHat则使用/etc/network/interfaces
配置文件。
以下是我通过/etc/sysconfig/network-scripts/ifcfg-eth0
静态IP的示例:
/etc/network/interfaces
供参考,您可以查看此链接: http://blog.shineservers.com/linux-static-ip-address-configuration/
答案 1 :(得分:0)
我在Gentoo上遇到同样的问题
我将dnsmasq
,dhclient
和systemd
与[main]
plugins=keyfile
dns=dnsmasq
no-auto-default=*
一起使用。就我而言,我有一台带有双LAN的PC,一台连接到Internet路由器,另一台连接到媒体播放器。我想为媒体播放器分配固定IP,并允许通过其他LAN访问Internet。我让玩家访问互联网,但没有分配固定的IP。
<强> /etc/NetworkManager/NetworkManager.conf 强>:
[connection]
id=VTEN
uuid=1a887e17-8d8b-460f-8cda-8ca22e5b2f28
type=ethernet
permissions=
secondaries=
[ethernet]
mac-address=1C:6F:65:35:4E:24
mac-address-blacklist=
[ipv4]
dns-search=
may-fail=false
method=shared
[ipv6]
dns-search=
method=ignore
/ etc / NetworkManager / system-connections / VTEN (共享连接/链接enp7s0 ):
[connection]
id=enp8s0 (Internet)
uuid=39559adb-4564-423a-805e-d12229f22845
type=ethernet
autoconnect=true
permissions=
secondaries=
[ethernet]
mac-address=1C:6F:65:35:4E:34
mac-address-blacklist=
[ipv4]
dns-search=
method=auto
[ipv6]
dns-search=
method=ignore
/ etc / NetworkManager / system-connections / Internet ( Internet / link enp8s0 )
interface=enp7s0
dhcp-range=192.168.2.2,192.168.2.50
dhcp-host=00:06:DC:89:74:36,192.168.2.2
要将dnsmasq激活为dhcp服务器,我已将此文件添加到媒体播放器的MAC和我要分配的IP。
的 /etc/NetworkManager/dnsmasq.d/servidor-dhcp 强>:
alias {
interface "enp7s0";
fixed-address 192.168.2.1;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.2.255;
option domain-name-servers 127.0.0.1;
}
为连接到我设置的媒体播放器的LAN分配固定IP 的 /etc/dhcp/dhclient.conf 强>:
NetworkManager
当我在systemd
上启动● NetworkManager.service - Network Manager
Loaded: loaded (/usr/lib64/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
Active: active (running) since mar 2015-12-08 01:51:15 CET; 59s ago
Main PID: 25570 (NetworkManager)
CGroup: /system.slice/NetworkManager.service
├─25570 /usr/sbin/NetworkManager --no-daemon
├─25579 /sbin/dhclient -d -q -sf /usr/libexec/nm-dhcp-helper -pf /var/run/dhclient-enp8s0.pid -lf /var/lib/NetworkManager/dhclient-3382e7d4-c7a1-41a1-9b12-a7fa20bb3aa4-enp8s0.lease -cf /var/lib/NetworkManager/dhclient-enp8s0.conf enp8s0
└─26336 /usr/sbin/dnsmasq --no-resolv --keep-in-foreground --no-hosts --bind-interfaces --pid-file=/var/run/NetworkManager/dnsmasq.pid --listen-address=127.0.0.1 --conf-file=/var/run/NetworkManager/dnsmasq.conf --cache-size=400 --proxy-dnssec --conf-dir=/etc/NetworkManager/dnsmasq.d
dic 08 01:51:21 localhost NetworkManager[25570]: <info> Executing: /sbin/iptables --table filter --delete FORWARD --destination 10.42.0.0/255.255.255.0 --out-interface enp7s0 --match state --state ESTABLISHED,RELATED --jump ACCEPT
dic 08 01:51:21 localhost NetworkManager[25570]: <info> Executing: /sbin/iptables --table filter --delete FORWARD --source 10.42.0.0/255.255.255.0 --in-interface enp7s0 --jump ACCEPT
dic 08 01:51:21 localhost NetworkManager[25570]: <info> Executing: /sbin/iptables --table filter --delete FORWARD --in-interface enp7s0 --out-interface enp7s0 --jump ACCEPT
dic 08 01:51:21 localhost NetworkManager[25570]: <info> Executing: /sbin/iptables --table filter --delete FORWARD --out-interface enp7s0 --jump REJECT
dic 08 01:51:21 localhost NetworkManager[25570]: <info> Executing: /sbin/iptables --table filter --delete FORWARD --in-interface enp7s0 --jump REJECT
dic 08 01:51:21 localhost NetworkManager[25570]: <info> Executing: /sbin/iptables --table filter --delete INPUT --in-interface enp7s0 --protocol udp --destination-port 67 --jump ACCEPT
dic 08 01:51:21 localhost NetworkManager[25570]: <info> Executing: /sbin/iptables --table filter --delete INPUT --in-interface enp7s0 --protocol tcp --destination-port 67 --jump ACCEPT
dic 08 01:51:21 localhost NetworkManager[25570]: <info> Executing: /sbin/iptables --table filter --delete INPUT --in-interface enp7s0 --protocol udp --destination-port 53 --jump ACCEPT
dic 08 01:51:21 localhost NetworkManager[25570]: <info> Executing: /sbin/iptables --table filter --delete INPUT --in-interface enp7s0 --protocol tcp --destination-port 53 --jump ACCEPT
dic 08 01:51:26 localhost NetworkManager[25570]: <info> startup complete
时,似乎一切正常:
$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
.....
2: enp7s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 1c:6f:65:35:4e:24 brd ff:ff:ff:ff:ff:ff
inet 10.42.0.1/24 brd 10.42.0.255 scope global enp7s0
valid_lft forever preferred_lft forever
inet6 fe80::1e6f:65ff:fe35:4e24/64 scope link tentative
valid_lft forever preferred_lft forever
3: enp8s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 1c:6f:65:35:4e:34 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.2/24 brd 192.168.1.255 scope global dynamic enp8s0
valid_lft 86401sec preferred_lft 86401sec
inet6 fe80::1e6f:65ff:fe35:4e34/64 scope link
valid_lft forever preferred_lft forever
可是:
Name Account Department
Kiran 1100 CSC
Subbu 900 CSC
Ram 500 CSC
Raj 800 CSC
Joy 400 CSC
enp7s0链接和媒体播放器有¿随机? IP¿由NetworkManager分配? dnsmasq( dhcp )和dhclient(与enp7s0 )都不能完成它们的工作。