내 우분투 컴퓨터와 두 번째 컴퓨터 사이에 이더넷 케이블을 연결한 다음 "IPv4"를 "다른 컴퓨터와 공유"로 설정하여 내 우분투 14.04와 다른 컴퓨터 사이에 네트워크를 만들 수 있습니다. 생성된 네트워크에는 10.42.0.x와 같은 IP가 있습니다. 나는 인터넷을 공유하기 위해 이것을 하는 것이 아니라 두 컴퓨터 사이에 네트워크를 만들기 위해 이것을 하고 있는데 이것은 매우 잘 작동합니다.
두 시스템이 호스트 이름을 사용하여 서로 주소를 지정하려면 해당 IP로 /etc/hosts를 편집합니다. 최신 라우터에서 볼 수 있는 MAC-IP 매핑을 사용하여 이것이 더 간단해지기를 바랍니다. 이를 달성하는 가장 쉬운 방법은 무엇입니까?
답변1
일반적으로 MAC 기반 IP 주소 할당은 다음을 통해 이루어집니다.DHCP 서버및 해당 구성 파일은 /etc/dhcp/dhcpd.conf
. 아래 예에서는 게스트를 위한 IP 주소 풀을 예약하고 나머지는 MAC를 기반으로 할당됩니다.
# The ddns-updates-style parameter controls whether or not the server will
# attempt to do a DNS update when a lease is confirmed. We default to the
# behavior of the version 2 packages ('none', since DHCP v2 didn't
# have support for DDNS.)
ddns-update-style none;
# option definitions common to all supported networks...
default-lease-time 86400;
max-lease-time 93000;
option domain-name "xxxxxx.com";
option domain-name-servers 192.168.111.1;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.111.255;
option routers 192.168.111.1;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;
# The Basic DHCP allocated addresses
subnet 192.168.111.0 netmask 255.255.255.0 {
range 192.168.111.3 192.168.111.50;
}
# Some specifically declared static IP addresses
host Wireless-R {
hardware ethernet 00:22:6B:82:01:55;
fixed-address 192.168.111.57;
}
host Doug-XPS {
hardware ethernet 00:23:4d:a6:ed:c4;
fixed-address 192.168.111.100;
}
host Doug-XPS {
hardware ethernet 00:23:4d:a6:ed:c4;
fixed-address 192.168.111.100;
}
host Doug-XPS2 {
hardware ethernet 00:21:9B:F9:21:26;
fixed-address 192.168.111.101;
}
host S10 {
hardware ethernet A0:F3:C1:10:22:EA;
fixed-address 192.168.111.102;
}
또는 dnsmasq 사용을 선호하거나 이미 기본적으로 사용하고 있는 경우 다음을 통해 MAC을 통해 지정할 수 있습니다 /etc/dnsmasq.conf
.
doug-xps=00:23:4d:a6:ed:c4,192.168.111.100
면책 조항: 저는 실제로 dnsmasq에 익숙하지 않지만 DHCP 예제는 제 시스템에서 직접 가져온 것입니다.