ubuntu 网络配置

1、网卡添加ip

  sudo ip -f inet addr add 192.168.1.197/24  dev eno1

2、删除路由

  route del -net 192.168.122.0 netmask 255.255.255.0

destination【网段地址】
mask【子网掩码】
gateway【网关地址】
metric 【路由跳数】
if【端口号】

 3、添加路由

  sudo route add -net 0.0.0.0 gateway xx.xx.xx.1

4、网络重启

  1、sudo service networking restart

  2、sudo /etc/init.d/networking restart

5、路由表查看

         1) 查看路由表

                sudo iptables -t nat -L -n

  2)   设置路由转发

    sudo iptables -t nat -A POSTROUTING -s [src ip address] -o [eth name] -j MASQUERADE

    sudo iptables-save

原文地址:https://www.cnblogs.com/Forwarderz/p/13710365.html