标签: gateway

Ubuntu 14.04 作为网关/路由器和防火墙

我当前的系统设置是 Ubuntu 14.04 桌面 64 位,我使用公共 IP 从路由器使用 Internet

eth0 - WAN Public IP 182.x.x.x  
eth1 - LAN private IP 192.168.0.1
Run Code Online (Sandbox Code Playgroud)

现在我想将此连接分发到使用我的系统作为Gateway,我的系统 IP 是192.168.0.1和网络上的其他计算机使用静态 IP192.168.0.2192.168.0.255 作为static和/或DHCP

另外我想在我的系统上设置防火墙,以便我可以监视和控制网络上其他系统的流量。

router gateway 14.04

16
推荐指数
1
解决办法
7万
查看次数

什么时候手动配置网络接口需要网络、广播和网关?

https://wiki.debian.org/NetworkConfiguration#Bridging_without_Switching

上面的网址说,下面。但是我不清楚它们什么时候是可选的,什么时候不是。你能给我提供一些描述这一点的参考文献的链接吗?谢谢。

如果您手动配置它,那么这样的事情将设置默认网关(网络、广播和网关是可选的):

auto eth0
iface eth0 inet static
    address 192.0.2.7
    netmask 255.255.255.0
    gateway 192.0.2.254
Run Code Online (Sandbox Code Playgroud)

networking gateway

10
推荐指数
1
解决办法
4万
查看次数

如何阻止 netplan 在每个接口上绑定默认网关

我全新安装了 ubuntu server 17.10,但是这个问题可能会影响以前的版本,但这是我第一次遇到这种情况。

服务器运行 2 个独立的网卡,一个用于内部本地网络通信(受信任),另一个是与 ISP 的互联网的公共(不受信任)连接。

过去,我总是将内部连接配置为静态,并且没有默认网关,因为外部卡将通过我的 ISP(静态租用)的 DHCP 提供。

/etc/netplan/00-netcfg.yaml

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: no
      dhcp6: no
      addresses: [192.168.1.xx/24]
      nameservers:
        addresses: [8.8.8.8,8.8.4.4]
    eth1:
      dhcp4: yes
      dhcp6: no
Run Code Online (Sandbox Code Playgroud)

现在这工作正常,因为我没有在 eth0 配置中提供gateway4线,所以它绑定了来自 ISP 的默认网关并且工作正常。

从那以后,我决定在我的 homelab 中为服务器使用静态租约,并在内部路由器上进行了配置。但是当我将两个设备的 netplan 配置设置为 dhcp 时,它会为两个接口添加默认网关(这是有道理的,因为两个 DHCP 服务器都提供了网关)。

> route -n

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    100    0        0 eth0
0.0.0.0         173.xxx.xxx.1   0.0.0.0         UG    100    0 …
Run Code Online (Sandbox Code Playgroud)

networking dhcp gateway netplan

10
推荐指数
1
解决办法
7161
查看次数

与其他 LAN 用户共享我的 VPN 连接

我有一台带有连接到 VPN 服务器的物理 LAN 适配器的 PC。有没有一种方法可以在同一个 LAN 适配器上设置(虚拟)网关接口,以便我网络上的其他设备可以将其用作网关并通过该接口和 VPN 连接运行其流量?

我的大部分 ifconfig:

enp0s21f5 Link encap:Ethernet  HWaddr 4c:cc:6a:d5:94:96  
      inet addr:192.168.1.120  Bcast:192.168.1.255  Mask:255.255.255.0
      inet6 addr: fe80::76e3:9399:187d:fdad/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
lo        Link encap:Local Loopback  
      inet addr:127.0.0.1  Mask:255.0.0.0
      inet6 addr: ::1/128 Scope:Host
      UP LOOPBACK RUNNING  MTU:65536  Metric:1
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
      inet addr:10.11.0.2  P-t-P:10.11.0.2  Mask:255.255.0.0
      inet6 addr: fdda:d0d0:cafe:1197::1000/64 Scope:Global
      inet6 addr: fe80::c9b:2e1b:882:1637/64 Scope:Link
      UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
virbr0    Link encap:Ethernet  HWaddr 00:00:00:00:00:00  
      inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0 …
Run Code Online (Sandbox Code Playgroud)

sharing vpn networking openvpn gateway

8
推荐指数
2
解决办法
1万
查看次数

如何使用 dhcp 获取默认网关

我有 ubuntu 12.04,我已经像这样配置了 /etc/network/interfaces

auto eth2
iface eth2 inet dhcp
Run Code Online (Sandbox Code Playgroud)

我也有

auto eth1
iface eth1 inet static
        address 60.60.60.1 
        netmask 255.255.255.0
        network 60.60.60.0
        broadcast 60.60.60.255 
Run Code Online (Sandbox Code Playgroud)

和 eth0 的配置类似。

当我执行 sudo route 时,我没有看到默认的 gw。我只是看到60.60.60.0 * 255.255.255.0 eth1 和类似

10.0.0.0  *   255.255.255.0   U     0      0        0 eth2
Run Code Online (Sandbox Code Playgroud)

由于默认的 gw 不存在,我有一个正确的 10.xxx IP 地址,但无法连接到外部。如何获得默认的 gw 自动设置。我可以使用 route add default gw 添加它,并且有效。但是当我移动位置时,我将不得不继续在每个地方手动设置路线添加

dhcp gateway

5
推荐指数
2
解决办法
4万
查看次数

Ubuntu 18.04 上的网络问题:没有网关

全新安装 Ubuntu 18.04 LTS 后,我按照此处在线提供的说明将 netplan 配置为使用静态 IP 地址:

https://www.tecmint.com/ifconfig-vs-ip-command-comparing-network-configuration/

问题是网关 IP 地址似乎被忽略了。这是 yaml 文件 (/etc/netplan/50-cloud-init.yaml):

network:
version: 2
renderer: networkd
ethernets:
    ens160:
        dhcp4: no
        dhcp6: no
        addresses: [172.20.0.109/24]
        gateway4: 172.20.3.254
        nameservers:
            addresses: [172.20.0.5,172.20.0.6]
Run Code Online (Sandbox Code Playgroud)

这是networkctl status ens160(执行后sudo netplan apply)的输出,您可以在其中看到网关丢失:

? 2: ens160
   Link File: /lib/systemd/network/99-default.link
Network File: /run/systemd/network/10-netplan-ens160.network
        Type: ether
       State: routable (configured)
        Path: pci-0000:03:00.0
      Driver: vmxnet3
      Vendor: VMware
       Model: VMXNET3 Ethernet Controller
  HW Address: 00:50:56:a9:bc:e5 (VMware, Inc.)
     Address: 172.20.0.109
              fe80::250:56ff:fea9:bce5
         DNS: 172.20.0.5
              172.20.0.6
Run Code Online (Sandbox Code Playgroud)

这是文件网络文件(/run/systemd/network/10-netplan-ens160.network):

[Match] …
Run Code Online (Sandbox Code Playgroud)

networking routing gateway netplan 18.04

3
推荐指数
1
解决办法
1万
查看次数

如何通过其他 Linux 机器将流量路由到 VPN

在这种情况下,我有两台机器 RasPi 和其他 Ubuntu 服务器。

我的 RasPi (192.168.100.105) 有 Debian 并且已经建立了 UDP openvpn 连接。RasPi 连接到远程 VPN 连接 172.16.199.99。

我尝试使用路由路由此流量:

ubuntu@server:~$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.100.254  0.0.0.0         UG    0      0        0 eth0
172.16.199.0    192.168.100.105  255.255.255.0   UG    0      0        0 eth0
192.168.100.0    *               255.255.255.0   U     0      0        0 eth0
Run Code Online (Sandbox Code Playgroud)

但不幸的是它不起作用。在 RasPi (192.168.100.105) 上,我可以 ping 172.16.199.99(在 openvpn 中远程 ip)但是在添加此路由后在 Ubuntu 服务器上:

mainframe@server:~$ sudo route add -net 172.16.199.0 netmask 255.255.255.0 gw 192.168.100.105 dev eth0 …
Run Code Online (Sandbox Code Playgroud)

routing gateway

1
推荐指数
1
解决办法
2万
查看次数

标签 统计

gateway ×7

networking ×4

dhcp ×2

netplan ×2

routing ×2

14.04 ×1

18.04 ×1

openvpn ×1

router ×1

sharing ×1

vpn ×1