|
|
|
|
@ -154,8 +154,8 @@ static int tun_set_ip(const char *ifname, const char *ip_addr) {
|
|
|
|
|
} |
|
|
|
|
// Формируем команду ifconfig с destination address (same as local for /32)
|
|
|
|
|
char cmd[512]; |
|
|
|
|
snprintf(cmd, sizeof(cmd), "ifconfig %s inet %s %s netmask %s up", |
|
|
|
|
ifname, ip_str, ip_str, mask_str); |
|
|
|
|
snprintf(cmd, sizeof(cmd), "ifconfig %s inet %s 192.0.2.1 netmask %s up", |
|
|
|
|
ifname, ip_str, mask_str); |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_TUN, "Executing: %s", cmd); |
|
|
|
|
int ret = system(cmd); |
|
|
|
|
if (ret != 0) { |
|
|
|
|
@ -189,7 +189,7 @@ static int tun_set_ip(const char *ifname, const char *ip_addr) {
|
|
|
|
|
strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); |
|
|
|
|
struct sockaddr_in *sin_dst = (struct sockaddr_in *)&ifr.ifr_dstaddr; |
|
|
|
|
sin_dst->sin_family = AF_INET; |
|
|
|
|
sin_dst->sin_addr = sin->sin_addr; // same as local
|
|
|
|
|
inet_pton(AF_INET, "192.0.2.1", &sin_dst->sin_addr); |
|
|
|
|
if (ioctl(sock, SIOCSIFDSTADDR, &ifr) < 0) { |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_TUN, "SIOCSIFDSTADDR failed: %s", strerror(errno)); |
|
|
|
|
close(sock); |
|
|
|
|
|