我對Gentoo的同樣的問題。
我使用NetworkManager
,dnsmasq
和dhclient
與systemd
。就我而言,我有一臺帶有雙局域網的PC,一臺連接到互聯網路由器,另一臺連接到媒體播放器。我想爲媒體播放器分配一個固定的IP,並允許通過其他局域網訪問互聯網。我已經讓玩家訪問互聯網,但沒有分配固定的IP。
/etc/NetworkManager/NetworkManager.conf:
[main]
plugins=keyfile
dns=dnsmasq
no-auto-default=*
的/ etc /網絡管理器/系統的連接/ VTEN(共享的連接/鏈路enp7s0):
[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已/系統連接/互聯網(互聯網/鏈接enp8s0)
[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
要激活的dnsmasq作爲DHCP服務器,我加入了這個文件,媒體播放器的MAC和IP是我想分配它。
/etc/NetworkManager/dnsmasq.d/servidor-dhcp:
interface=enp7s0
dhcp-range=192.168.2.2,192.168.2.50
dhcp-host=00:06:DC:89:74:36,192.168.2.2
要分配一個固定的IP局域網連接到我設置 的/ etc/DHCP/dhclient的媒體播放器。CONF:
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;
}
當我在systemd
開始NetworkManager
似乎所有的工作:
● 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
的enp7s0鏈路和媒體播放器有¿隨機的? IP?由NetworkManager分配? dnsmasq(dhcp)和dhclient(與enp7s0)都沒有完成他們的工作。
感謝您的評論,但這不是我所期待的。我試圖根據其MAC地址爲三個工作站分配靜態IP地址,而不是爲筆記本電腦上的eth0設備分配靜態地址。我想用NetworkManager來實現這一點。任何想法如何做到這一點? –